|
-
May 6th, 2001, 12:52 AM
#1
Thread Starter
Fanatic Member
Always on top + Resize. its a tricky one. (good one 4 u matt...)
How do i get a form to:
A) on load move to the top-RIGHT of the form.
B) When the mouse comes off of the form, the form shrinks to
Width = 200
Height = 10
And moves to the top-RIGHT
C) If the mouse comes back on the form it goes back to normal (resizes back to Width = 5670, Height = 3855)
any help is good. (I only have a short time, 20 mins, till i get off the net, so... make it quick!!)
Thanx. Tim
/: Tim :\____________________
\: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/
-
May 6th, 2001, 01:15 AM
#2
Try this:
Code:
'Module Code:
Option Explicit
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal ndx As Long, ByVal _
NewValue 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
Public Declare Function SetWindowPos _
Lib "user32" (ByVal hWnd As _
Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Const GWL_WNDPROC = -4
Public Const WM_ACTIVATEAPP = &H1C
Dim saveHWnd As Long
Dim oldProcAddr As Long
Sub StartSubclassing(ByVal hWnd As Long)
saveHWnd = hWnd
oldProcAddr = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WndProc)
End Sub
Sub StopSubclassing()
SetWindowLong saveHWnd, GWL_WNDPROC, oldProcAddr
End Sub
Function WndProc(ByVal hWnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
WndProc = CallWindowProc(oldProcAddr, hWnd, uMsg, wParam, lParam)
Select Case uMsg
Case WM_ACTIVATEAPP
If wParam Then
Form1.Width = 5670
Form1.Height = 3855
Else
Form1.Width = 200
Form1.Height = 10
End If
End Select
End Function
'Form Code:
Private Sub Form_Load()
SetWindowPos hWnd, -1, 0, 0, 0, 0, 3
Me.Move Screen.Width - Me.Width, 0
StartSubclassing Me.hWnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
StopSubclassing
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
|