|
-
Aug 5th, 2000, 08:56 PM
#1
I am able to subclass my form and create a move event. However I don't know how to stop the form from being moved after its left property is let say 1000? For now it looks like the user can drag it beyond the 1000 point (it comes back to 1000 but it looks ugly - I want to stop it completely).
Thanks for ANY help.
-
Aug 6th, 2000, 07:14 AM
#2
Fanatic Member
I've seen this done somewhere before:
Code:
'WARNING: IF THIS CODE DOES NOT WORK DO NOT KILL / MAME /
'MUTILATE / INJUR ME
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, source As Any, ByVal numBytes As Long)
Type POINTAPI
X As Long
Y As Long
End Type
Type MINMAXINFO
ptReserved As POINTAPI
ptMaxSize As POINTAPI
ptMaxPosition As POINTAPI
ptMinTrackSize As POINTAPI
ptMaxTrackSize As POINTAPI
End Type
'Subclassing
'Blah, blah
Case WM_GETMINMAXINFO
' Windows is querying the window for its MinMaxInfo
'As the name so cleverly suggests
Dim mmInfo As MINMAXINFO, Whatever As Long
CopyMemory mmInfo, ByVal lParam, Len(mmInfo)
With mmInfo
.ptMaxTrackSize.X = 400 'Max Width (Pixels)
.ptMaxTrackSize.Y = 400 'Max Height (Pixels)
.ptMinTrackSize.X = 100 'Min width (Pixels)
.ptMinTrackSize.Y = 100 'Min Height (Pixels)
.ptMaxPosition.X = 0 'Coords when maximised (X)
.ptMaxPosition.Y = 0 'Coords when maximised (Y)
.ptMaxSize = .ptMaxTrackSize 'Sets the max
'size when the Max-button is pressed to equal
'the max size while manually sizing
End With
CopyMemory ByVal lParam, mmInfo, Len(mmInfo)
'Keep subclassing
Hope this is pretty self-explanatory,
me
-
Aug 6th, 2000, 08:30 PM
#3
quote:
Originally posted by V(ery) Basic
'WARNING: IF THIS CODE DOES NOT WORK DO NOT KILL / MAME /
'MUTILATE / INJUR ME
BUT I HAVE TO. I HAD SUCH NICE PLANS. I WANTED TO DO SO MUCH WITH THAT CODE. AND WHAT YOU GAVE ME???? NOTHING you [beep][beep][beep][crying].
But now seriously. It doesn't stop the form from being moved beyond a certain point on the screen. It works for setting the left and top coordinates while in the maximized mode, but not for moving the form (and I use the exact same code for stopping the resize event).
So ANY ideas are still being accepted
Thanks for help V(ery) Basic
-
Aug 6th, 2000, 09:33 PM
#4
Frenzied Member
This Works
Code:
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type WINDOWPOS
hwnd As Long
hWndInsertAfter As Long
x As Long
y As Long
cx As Long
cy As Long
flags As Long
End Type
Private Const WM_WINDOWPOSCHANGING = &H46
Dim hDefWinProc As Long
Public Sub Subclass(hwnd As Long)
hDefWinProc = SetWindowLong(hwnd, -4, AddressOf WndProc)
End Sub
Public Function WndProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim apiNewPosition As WINDOWPOS
WndProc = CallWindowProc(hDefWinProc, hwnd, wMsg, wParam, lParam)
If wMsg = WM_WINDOWPOSCHANGING Then
Call CopyMemory(apiNewPosition, ByVal lParam, LenB(apiNewPosition))
If apiNewPosition.x > 200 Then _
apiNewPosition.x = 200
If apiNewPosition.y > 200 Then _
apiNewPosition.y = 200
Call CopyMemory(ByVal lParam, apiNewPosition, LenB(apiNewPosition))
End If
End Function
-
Aug 6th, 2000, 09:48 PM
#5
The problem still occurs. The method you've posted is very similar to WM_MOVE event I've created. It allows the user to move an outline of a window to any place, but doesn't move the window. I want to stop the user from moving the outline.
Thanks for your help so far
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
|