home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / messag / movectl.fr_ / movectl.fr (.txt)
Encoding:
Visual Basic Form  |  1995-01-14  |  10.7 KB  |  318 lines

  1. VERSION 2.00
  2. Begin Form MoveCtl 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Moving Controls..."
  6.    ClientHeight    =   3555
  7.    ClientLeft      =   1035
  8.    ClientTop       =   1500
  9.    ClientWidth     =   7350
  10.    Height          =   3960
  11.    Left            =   975
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   3555
  16.    ScaleWidth      =   7350
  17.    Top             =   1155
  18.    Width           =   7470
  19.    Begin PictureBox PictureBack 
  20.       BackColor       =   &H00C0C0C0&
  21.       BorderStyle     =   0  'None
  22.       Height          =   3435
  23.       Left            =   60
  24.       ScaleHeight     =   3435
  25.       ScaleWidth      =   7215
  26.       TabIndex        =   2
  27.       Top             =   60
  28.       Width           =   7215
  29.       Begin PictureBox Picture1 
  30.          BackColor       =   &H00C0C0C0&
  31.          Height          =   1635
  32.          Left            =   1320
  33.          ScaleHeight     =   107
  34.          ScaleMode       =   3  'Pixel
  35.          ScaleWidth      =   123
  36.          TabIndex        =   5
  37.          Top             =   1680
  38.          Width           =   1875
  39.          Begin Message Message1 
  40.             Left            =   1860
  41.             Top             =   1680
  42.          End
  43.          Begin Label LblTitle1 
  44.             Alignment       =   2  'Center
  45.             BackColor       =   &H00800000&
  46.             BorderStyle     =   1  'Fixed Single
  47.             Caption         =   "Resize/Move Me"
  48.             ForeColor       =   &H00FFFFFF&
  49.             Height          =   255
  50.             Left            =   0
  51.             TabIndex        =   0
  52.             Top             =   120
  53.             Width           =   1635
  54.          End
  55.          Begin Image Image1 
  56.             Height          =   1590
  57.             Left            =   60
  58.             Picture         =   MOVECTL.FGX:0000
  59.             Stretch         =   -1  'True
  60.             Top             =   420
  61.             Width           =   1695
  62.          End
  63.       End
  64.       Begin PictureBox Picture2 
  65.          BackColor       =   &H00C0C0C0&
  66.          Height          =   1515
  67.          Left            =   3660
  68.          ScaleHeight     =   99
  69.          ScaleMode       =   3  'Pixel
  70.          ScaleWidth      =   167
  71.          TabIndex        =   3
  72.          Top             =   1740
  73.          Width           =   2535
  74.          Begin Message Message2 
  75.             Left            =   2100
  76.             Top             =   1560
  77.          End
  78.          Begin TextBox Text1 
  79.             Height          =   975
  80.             Left            =   120
  81.             MultiLine       =   -1  'True
  82.             ScrollBars      =   2  'Vertical
  83.             TabIndex        =   4
  84.             Text            =   "Type some text in this box and then resize the control as you would any form..."
  85.             Top             =   360
  86.             Width           =   2295
  87.          End
  88.          Begin Label LblTitle2 
  89.             Alignment       =   2  'Center
  90.             BackColor       =   &H00800000&
  91.             BorderStyle     =   1  'Fixed Single
  92.             Caption         =   "Resize/Move Me"
  93.             ForeColor       =   &H00FFFFFF&
  94.             Height          =   255
  95.             Left            =   0
  96.             TabIndex        =   6
  97.             Top             =   0
  98.             Width           =   1635
  99.          End
  100.       End
  101.       Begin Label LabelMsg 
  102.          Alignment       =   2  'Center
  103.          BackStyle       =   0  'Transparent
  104.          Caption         =   "LabelMsg"
  105.          ForeColor       =   &H00800000&
  106.          Height          =   1515
  107.          Left            =   60
  108.          TabIndex        =   1
  109.          Top             =   0
  110.          Width           =   6975
  111.       End
  112.    End
  113. Sub Form_Load ()
  114.     DisplayedMoveCtl = True
  115.     Message1.hWindow = Picture1.hWnd
  116.     Message1.Status(WM_NChitTest) = True
  117.     Message1.Status(WM_NClButtonDblClk) = True
  118.     Message1.Status(WM_GetMinMaxInfo) = True
  119.     Message2.hWindow = Picture2.hWnd
  120.     Message2.Status(WM_NChitTest) = True
  121.     Message2.Status(WM_NClButtonDblClk) = True
  122.     Message2.Status(WM_GetMinMaxInfo) = True
  123.     msg$ = "By intercepting messages with Message.VBX," + nl
  124.     msg$ = msg$ + "you can subclass controls to perform" + nl
  125.     msg$ = msg$ + "functions they normally couldn't under VB." + nl
  126.     msg$ = msg$ + "The PictureBox can be moved and resized in Run Mode!!!" + nl
  127.     msg$ = msg$ + "It's like having child windows inside other child windows." + nl
  128.     msg$ = msg$ + "And ... this is just scratching the surface of the" + nl
  129.     msg$ = msg$ + "possibilities you have with Message.VBX."
  130.     LabelMsg.Caption = msg$
  131.     Picture1_Resize
  132.     Picture2_Resize
  133.     Screen.MousePointer = 0
  134. End Sub
  135. Sub Form_Paint ()
  136.     DoForm3D Me, "raised", 2, 0
  137.     DoForm3D Me, "sunken", 2, 2
  138. End Sub
  139. Sub Form_Unload (Cancel As Integer)
  140.     DisplayedMoveCtl = False
  141. End Sub
  142. Sub Message1_Receive (msg As Integer, wParam As Integer, lParam As Long, UseRetVal As Integer, RetVal As Long)
  143.     Dim CsrPos As PointAPI
  144.     If msg = WM_NChitTest Then  'allow it to move and resize
  145.         CsrPos.x = CInt(GetLowWord(lParam))
  146.         CsrPos.y = CInt(GetHighWord(lParam))
  147.         ScreenToClient Picture1.hWnd, CsrPos
  148.         PicWide = Picture1.ScaleWidth
  149.         PicHigh = Picture1.ScaleHeight
  150.         
  151.         If CsrPos.y > 4 And CsrPos.y < 19 And CsrPos.x > 4 And CsrPos.x < PicWide - 4 Then
  152.             RetVal = HTCAPTION
  153.             UseRetVal = 1
  154.             Exit Sub
  155.             End If
  156.         If CsrPos.y < 8 And CsrPos.x < 8 Then
  157.             RetVal = HTTOPLEFT
  158.             UseRetVal = 1
  159.             Exit Sub
  160.             End If
  161.         If CsrPos.y < 8 And CsrPos.x > PicWide - 8 Then
  162.             RetVal = HTTOPRIGHT
  163.             UseRetVal = 1
  164.             Exit Sub
  165.             End If
  166.         If CsrPos.y > PicHigh - 8 And CsrPos.x < 8 Then
  167.             RetVal = HTBOTTOMLEFT
  168.             UseRetVal = 1
  169.             Exit Sub
  170.             End If
  171.         If CsrPos.y > PicHigh - 8 And CsrPos.x > PicWide - 8 Then
  172.             RetVal = HTBOTTOMRIGHT
  173.             UseRetVal = 1
  174.             Exit Sub
  175.             End If
  176.         If CsrPos.y < 4 Then
  177.             RetVal = HTTOP
  178.             UseRetVal = 1
  179.             End If
  180.         If CsrPos.y > PicHigh - 4 Then
  181.             RetVal = HTBOTTOM
  182.             UseRetVal = 1
  183.             End If
  184.         If CsrPos.x < 4 Then
  185.             RetVal = HTLEFT
  186.             UseRetVal = 1
  187.             End If
  188.         If CsrPos.x > PicWide - 4 Then
  189.             RetVal = HTRIGHT
  190.             UseRetVal = 1
  191.             End If
  192.         End If
  193.         
  194.     If msg = WM_NClButtonDblClk Then  'stop dbl-click from maximizing
  195.         RetVal = 0
  196.         UseRetVal = 1
  197.         Exit Sub
  198.         End If
  199.     If msg = WM_GetMinMaxInfo Then  'set resize limits
  200.         Dim MinMax As MinMaxInfo
  201.         MessageDataGet lParam, Len(MinMax), MinMax
  202.             MinMax.ptMaxSize.x = 320
  203.             MinMax.ptMaxSize.y = 240
  204.             MinMax.ptMaxPosition.x = 0
  205.             MinMax.ptMaxPosition.y = 0
  206.             MinMax.ptMaxTrackSize.x = 320
  207.             MinMax.ptMaxTrackSize.y = 240
  208.             MinMax.ptMinTrackSize.x = 120
  209.             MinMax.ptMinTrackSize.y = 64
  210.         MessageDataSet lParam, Len(MinMax), MinMax
  211.         UseRetVal = 1
  212.         RetVal = 0
  213.         End If
  214. End Sub
  215. Sub Message2_Receive (msg As Integer, wParam As Integer, lParam As Long, UseRetVal As Integer, RetVal As Long)
  216.     Dim CsrPos As PointAPI
  217.     If msg = WM_NChitTest Then  'allow it to move and resize
  218.         CsrPos.x = CInt(GetLowWord(lParam))
  219.         CsrPos.y = CInt(GetHighWord(lParam))
  220.         ScreenToClient Picture2.hWnd, CsrPos
  221.         PicWide = Picture2.ScaleWidth
  222.         PicHigh = Picture2.ScaleHeight
  223.         
  224.         If CsrPos.y > 4 And CsrPos.y < 19 And CsrPos.x > 4 And CsrPos.x < PicWide - 4 Then
  225.             RetVal = HTCAPTION
  226.             UseRetVal = 1
  227.             Exit Sub
  228.             End If
  229.         If CsrPos.y < 8 And CsrPos.x < 8 Then
  230.             RetVal = HTTOPLEFT
  231.             UseRetVal = 1
  232.             Exit Sub
  233.             End If
  234.         If CsrPos.y < 8 And CsrPos.x > PicWide - 8 Then
  235.             RetVal = HTTOPRIGHT
  236.             UseRetVal = 1
  237.             Exit Sub
  238.             End If
  239.         If CsrPos.y > PicHigh - 8 And CsrPos.x < 8 Then
  240.             RetVal = HTBOTTOMLEFT
  241.             UseRetVal = 1
  242.             Exit Sub
  243.             End If
  244.         If CsrPos.y > PicHigh - 8 And CsrPos.x > PicWide - 8 Then
  245.             RetVal = HTBOTTOMRIGHT
  246.             UseRetVal = 1
  247.             Exit Sub
  248.             End If
  249.         If CsrPos.y < 4 Then
  250.             RetVal = HTTOP
  251.             UseRetVal = 1
  252.             End If
  253.         If CsrPos.y > PicHigh - 4 Then
  254.             RetVal = HTBOTTOM
  255.             UseRetVal = 1
  256.             End If
  257.         If CsrPos.x < 4 Then
  258.             RetVal = HTLEFT
  259.             UseRetVal = 1
  260.             End If
  261.         If CsrPos.x > PicWide - 4 Then
  262.             RetVal = HTRIGHT
  263.             UseRetVal = 1
  264.             End If
  265.         End If
  266.         
  267.     If msg = WM_NClButtonDblClk Then  'stop dbl-click from maximizing
  268.         RetVal = 0
  269.         UseRetVal = 1
  270.         Exit Sub
  271.         End If
  272.     If msg = WM_GetMinMaxInfo Then  'set resize limits
  273.         Dim MinMax As MinMaxInfo
  274.         MessageDataGet lParam, Len(MinMax), MinMax
  275.             MinMax.ptMaxSize.x = 400
  276.             MinMax.ptMaxSize.y = 200
  277.             MinMax.ptMaxPosition.x = 0
  278.             MinMax.ptMaxPosition.y = 0
  279.             MinMax.ptMaxTrackSize.x = 400
  280.             MinMax.ptMaxTrackSize.y = 200
  281.             MinMax.ptMinTrackSize.x = 120
  282.             MinMax.ptMinTrackSize.y = 64
  283.         MessageDataSet lParam, Len(MinMax), MinMax
  284.         UseRetVal = 1
  285.         RetVal = 0
  286.         End If
  287. End Sub
  288. Sub Picture1_Paint ()
  289.     Picture1.Cls
  290.     DoPicture3D Picture1, "raised", 2, 0
  291.     DoPicture3D Picture1, "sunken", 2, 2
  292. End Sub
  293. Sub Picture1_Resize ()
  294.     Picture1.AutoRedraw = True
  295.     LblTitle1.Top = 4
  296.     LblTitle1.Left = 4
  297.     LblTitle1.Width = Picture1.ScaleWidth - 8
  298.     Image1.Top = LblTitle1.Height + 6
  299.     Image1.Left = 8
  300.     Image1.Width = Picture1.ScaleWidth - 16
  301.     Image1.Height = Picture1.ScaleHeight - LblTitle1.Height - 12
  302.     Picture1.AutoRedraw = False
  303. End Sub
  304. Sub Picture2_Paint ()
  305.     Picture2.Cls
  306.     DoPicture3D Picture2, "raised", 2, 0
  307.     DoPicture3D Picture2, "sunken", 2, 2
  308. End Sub
  309. Sub Picture2_Resize ()
  310.     LblTitle2.Top = 4
  311.     LblTitle2.Left = 4
  312.     LblTitle2.Width = Picture2.ScaleWidth - 8
  313.     Text1.Top = LblTitle2.Height + 6
  314.     Text1.Left = 8
  315.     Text1.Width = Picture2.ScaleWidth - 16
  316.     Text1.Height = Picture2.ScaleHeight - LblTitle2.Height - 12
  317. End Sub
  318.