-
July 10th, 2009, 01:32 PM
#1
[RESOLVED] UserControl Property Limitations
My Dilemma:
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:
Picture Property
Stretch Property
Index Property
hWnd Property
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.
[Resolved]
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.
ReleaseCapture
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
Exit Sub
ElseIf Button = vbRightButton Then
ElseIf Button = 4 Then
End If
End Sub
Private Sub imgSelectorSwitch_Click()
If Not bMoveSwitch then
RaiseEvent Click
end if
End Sub
Public Property Get MoveSwitch() as Boolean
MoveSwitch = bMoveSwitch
End Property
Public Property Let MoveSwitch(bUser_MoveSwitch as Boolean)
bMoveSwitch = bUser_MoveSwitch
End Property
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
#2
Re: UserControl Property Limitations
Put your question back, along with the answer, to help the next person
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|