July 10th, 2009, 01:32 PM
[RESOLVED] UserControl Property Limitations
I need a Control that is Arrayable for muti-instancing, contains a picture with a stretch property, and can be dynamically positioned at runtime with the mouse. In order to satisfy these conditions it needs the following minimum properties, events and methods:
Left and Top Properties
Height and Width Properties
Move Method (or at least movable via the VB Move Command)
All of these can be satisfied by the PictureBox except for Stretch
All can be satisfied by the Image Control except for the hWnd Property.
My objective was to create a UserControl that contained only an Image Control and expose the hWnd of the UserControl so that a ReleaseCapture and SendMessage could dynamically move the control on the form at runtime. However the Move is invalid with the UserControl, and the UserControl has no Left or Top properties.
The UserControl has CurrentX and CurrentY which can be implemented with the ReleaseCapture and SendMessage without the Move Command as;
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Dim bMoveSwitch as Boolean 'For MoveSwitch Property
Private Sub imgSelectorSwitch(Button As Integer, Shift As Integer, x As Single, y As Single) 'This is an Image Control
If Button = vbLeftButton And bMoveSwitch Then 'bMoveSwitch is a Bool turned on and off to permit functioning of the imgSelectorSwitch_Click event, and to lock controls on the form.
SendMessage UserControl.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
'UserControl.Move UserControl.Left, UserControl.Top (Won't work with UserControl)
UserControl.CurrentX = X 'This works with
UserControl.CurrentY = Y 'UserControl
ElseIf Button = vbRightButton Then
ElseIf Button = 4 Then
Private Sub imgSelectorSwitch_Click()
If Not bMoveSwitch then
Public Property Get MoveSwitch() as Boolean
MoveSwitch = bMoveSwitch
Public Property Let MoveSwitch(bUser_MoveSwitch as Boolean)
bMoveSwitch = bUser_MoveSwitch
I hope someone else finds this useful.
Last edited by arkansascontrols; July 10th, 2009 at 11:13 PM.
Reason: By Request of dglienna
July 10th, 2009, 06:20 PM
Re: UserControl Property Limitations
Put your question back, along with the answer, to help the next person
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.