|
-
May 2nd, 2003, 08:31 PM
#1
Thread Starter
Hyperactive Member
not allow program to move off screen?
in what event would i put code to check if the form is being moved off the desktop screen? i know how to code it once i figure out where to put it
thanks
-
May 2nd, 2003, 08:40 PM
#2
VB doesn't raise an event when a form is moved (unfortunatly). You'll need to subclass the Form and check for the WM_MOVE or WM_MOVING message.
-
May 2nd, 2003, 08:54 PM
#3
I would go with WM_MOVING, personally. That way you can bound (or clip, or whatever the right word is) the window rect instead of moving it back and forth, which causes a lot of flickering.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 2nd, 2003, 09:11 PM
#4
Here's a sample. It keeps the form completely on the screen at all times...
VB Code:
'** In your form
Option Explicit
Private Sub Form_Load()
Call Hook(Me.hwnd)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Unhook(Me.hwnd)
End Sub
'** In a standard module
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 Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, _
ByVal wMsg 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 Const GWL_WNDPROC = (-4)
Private Const WM_MOVING = &H216
Private Const WMSZ_LEFT = 1
Private Const WMSZ_RIGHT = 2
Private Const WMSZ_TOP = 3
Private Const WMSZ_TOPLEFT = 4
Private Const WMSZ_TOPRIGHT = 5
Private Const WMSZ_BOTTOM = 6
Private Const WMSZ_BOTTOMLEFT = 7
Private Const WMSZ_BOTTOMRIGHT = 8
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private mPrevProc As Long
Public Sub Hook(ByVal hwnd As Long)
mPrevProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndProc)
End Sub
Public Sub Unhook(ByVal hwnd As Long)
Call SetWindowLong(hwnd, GWL_WNDPROC, mPrevProc)
mPrevProc = 0&
End Sub
Private Function PScreenWidth() As Long
PScreenWidth = (Screen.Width \ 15)
End Function
Private Function PScreenHeight() As Long
PScreenHeight = (Screen.Height \ 15)
End Function
Public Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) _
As Long
On Error Resume Next
Dim r As RECT
Dim lTemp As Long
If uMsg = WM_MOVING Then
Call CopyMemory(r, ByVal lParam, Len(r))
If r.Left < 0 Then
lTemp = r.Right - r.Left
r.Left = 0
r.Right = lTemp
End If
If r.Right > PScreenWidth Then
lTemp = r.Right - r.Left
r.Right = PScreenWidth
r.Left = r.Right - lTemp
End If
If r.Top < 0 Then
lTemp = r.Bottom - r.Top
r.Top = 0
r.Bottom = lTemp
End If
If r.Bottom > PScreenHeight Then
lTemp = r.Bottom - r.Top
r.Bottom = PScreenHeight
r.Top = r.Bottom - lTemp
End If
Call CopyMemory(ByVal lParam, r, Len(r))
End If
If mPrevProc& Then
WndProc = CallWindowProc(mPrevProc, hwnd, uMsg, wParam, lParam)
Else
WndProc = DefWindowProc(hwnd, uMsg, wParam, lParam)
End If
End Function
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 3rd, 2003, 01:43 AM
#5
Member
similar
I have a similar question...
how do you manage to create a fullscreen form AND have your computer seeing all of it in the development stage?
------------------------------------------
Private Sub Problem()
If resolved.Value = True Then
MsgBox "Resolved Query", vbInformation, "Resolved"
End If
End Sub
------------------------------------------
Public Sub aspnow()
Me.DoingASPNow = true
End Sub
------------------------------------------
-
May 3rd, 2003, 05:14 PM
#6
Thread Starter
Hyperactive Member
ica what do you mean by seeing all of it in development stage?
-
May 3rd, 2003, 07:40 PM
#7
I think he means not having to use the sliders to see the form in the IDE. I think the only way to do this is to change ur computers resolution to a higher setting. MAKE SURE UR MONITOR CAN HANDLE IT
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
May 3rd, 2003, 07:48 PM
#8
Originally posted by <ABX
I think he means not having to use the sliders to see the form in the IDE. I think the only way to do this is to change ur computers resolution to a higher setting. MAKE SURE UR MONITOR CAN HANDLE IT
If this is what you mean you can set the "SDI Development Environment" option on the Advanced tab of the Tools > Options dialog box. You have to restart VB for this to take effect though.
-
May 14th, 2003, 05:25 AM
#9
Member
------------------------------------------
Private Sub Problem()
If resolved.Value = True Then
MsgBox "Resolved Query", vbInformation, "Resolved"
End If
End Sub
------------------------------------------
Public Sub aspnow()
Me.DoingASPNow = true
End Sub
------------------------------------------
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
|