|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problems with vbCtrlMaskCTRLClick is a set option. The movement works fine when CTRLClick = 0, but not when CTRLClick = 1. I searched and found the Shift = vbCtrlMask thing, but that doesn't work. Please help: 'For window dragging (http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_thread/thread/1a6101384e44a017/078e00c3bacb5370?hl=en#078e00c3bacb5370) If CTRLClick = 1 Then If Button = vbLeftButton And Shift = vbCtrlMask Then ReleaseCapture SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0& End If ElseIf CTRLClick = 0 Then 'just a left-click, no keys If Button = vbLeftButton Then ReleaseCapture SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0& End If End If Thanks! >I would like to determine if CTRL is pressed to activate a form move. You shouldn't compare the value directly since it's a bit-flag rather than a > > CTRLClick is a set option. > The movement works fine when CTRLClick = 0, but not when CTRLClick = 1. > > I searched and found the Shift = vbCtrlMask thing, but that doesn't > work. value, you want something like: *** If (Shift And vbShiftMask) Then ' Shift is down End If If (Shift And vbCtrlMask) Then ' Ctrl is down End If If (Shift And vbAltMask) Then ' Alt is down End If *** Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ On 29 Jan 2006 08:58:57 -0800, MatthewBr***@gmail.com wrote:
>... Because the Shift param may contain multiple mask flags you need to> If Button = vbLeftButton And Shift = vbCtrlMask Then use the And bit-wise operator to test for an individual flag. (Note the same is actually true of the Button param as well, though typically you'd not want to do anything if more than one mouse button were down.) If Button = vbLeftButton Then If (Shift And vbCtrlMask) = vbCtrlMask Then End If End If -Tom MVP - Visual Basic (please post replies to the newsgroup) Thanks! Final and functional:
'For window dragging (http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_thread/thread/1a6101384e44a017/078e00c3bacb5370?hl=en#078e00c3bacb5370) If Button = vbLeftButton Then If CTRLClick = True Then If (Shift And vbCtrlMask) = vbCtrlMask Then ReleaseCapture SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0& End If ElseIf CTRLClick = False Then 'just a left-click, no keys ReleaseCapture SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0& End If End If For future reference, (Shift And vbCtrlMask) and VBCtrlMask both = 2 when active. MatthewBr***@gmail.com wrote:
> If (Shift And vbCtrlMask) = vbCtrlMask Then since the flag is a single bit, it should be safe and slightly more efficient to simplify:> > ReleaseCapture > SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0& > End If > If (Shift And vbCtrlMask) Then Bob
Why sending email programmatically must be so complicated?
VB 2005 Express..NOT OT...really! File Copy Without Win Buffering Proper way to resize a Form VB6---.NET Passing data from a dll to the main VB program can't use a function from dll built in delphi VB crash on .PopupMenu .zmnuDemo Defaultmenu cRegistry problems read/writing to (Default) Help - What is the best approach? |
|||||||||||||||||||||||