|
-
Apr 22nd, 2002, 05:28 PM
#1
Thread Starter
New Member
Question on setting top window and reseting all other windows
I have a question. I'm new to VB so I hope to be able to describe my question correctly. I created a form and set its dimensions to automatically fill the width of the screen and set the height at just over my text size. The purpose of this is to have a scrolling text run across the screen. Everything works fine, but I want my form/window as the top most window, always visible. I have gotten this to work with SetWindowPos. But my question is.....
How can I make all my other windows/programs resize automatically to begin just under my top form. I don’t want my top form to cut off the title bars of my other programs. Kind of like docking - how AOLIM does on the side of the screen. Any ideas anyone?? Please?!?!?!
Could I have been anyone different?
-
Apr 22nd, 2002, 11:47 PM
#2
Frenzied Member
Use EnumWindows API to get the handler of all the top level windows, use isWindowVisible API Function to check for the window's visibility and then use SetWindowRect API to set the coordinates of all the windows except of yours.
Tell me If you can't understand.. I'll paste the code.
-
Apr 24th, 2002, 10:25 AM
#3
Thread Starter
New Member
I will take a look and try to figure it out for myself. Thanks for the help.
Could I have been anyone different?
-
Apr 24th, 2002, 10:56 AM
#4
Thread Starter
New Member
ok.... I could use some help now. I'm getting a little confused. I don't fully understand this process. Can you please give me a little more help/code
Thanks
Could I have been anyone different?
-
Apr 24th, 2002, 02:59 PM
#5
Thread Starter
New Member
Anyone??
Please
Could I have been anyone different?
-
Apr 24th, 2002, 03:54 PM
#6
Frenzied Member
Following code is not the best one.. lil buggy rather..but I've written it just now and i hope it'll atleast give you the understanding
Add this code to a Module
VB Code:
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private 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
Private Const HWND_DESKTOP = 0
Private Const SWP_SHOWWINDOW = &H40
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim mainRect As RECT
Public Function EnumWindowsProc(ByVal thWnd As Long, ByVal lParam As Long) As Long
Dim FHwnd As Long
Dim txtLen As Long
Dim tRect As RECT
If Form1.hwnd <> thWnd Then
If IsWindowVisible(thWnd) Then
GetWindowRect thWnd, tRect
If tRect.Top < mainRect.Bottom Then
SetWindowPos thWnd, HWND_DESKTOP, tRect.Left, mainRect.Bottom, tRect.Right - tRect.Left, tRect.Bottom - tRect.Top, SWP_SHOWWINDOW
End If
End If
End If
EnumWindowsProc = True
End Function
Public Sub SetWindows()
GetWindowRect Form1.hwnd, mainRect
EnumWindows AddressOf EnumWindowsProc, 0
End Sub
And this on the form with a command button
VB Code:
Private Sub Command1_Click()
SetWindows
End Sub
Private Sub Form_Load()
Me.Left = 0
Me.Top = 0
Me.Width = Screen.Width * Screen.TwipsPerPixelX
Me.Height = 1000 'I liked it to be like that
End Sub
I hope it helps
-
Apr 24th, 2002, 05:13 PM
#7
Thread Starter
New Member
Awsome!!!
Thanks!!!
but... how do i get everything to reset to normal when I close that window??
And....
why do i have to run the SetWindow funtion of a command button, why cant I run it off of Form_Load()???
Thanks again for all your help.
Could I have been anyone different?
-
Apr 24th, 2002, 05:29 PM
#8
Frenzied Member
To reset the windows to their previous dimensions.. you'll have to save their previous settings and on Form's QueryUnload Event or Unload Event reset them all by calling the Functions say ResetWindow(u'll make this)..
I coded on CommandButton for testing... you can/must code it on Load Event.
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
|