TWCMIL
asked on
Moving other application's windows
I have an application that's a Shell App bar that runs at the top of the screen.
We have a poorly written app that we use for our customer database... problem is, this application slowly moves upwards in increments at screen resolutions of 1024x768 or higher for some reason. Eventually, it works its way underneath my app bar.
So, I want my app bar to "bump" windows down X pixels if they take over (or under technically) its space. I'll probably fire it when a user moves their mouse over my App Bar or even clicks it; I think I'd need to scan for all open windows, and if their window hwnd is within the top X pixels, bump them down Y pixels...
Here's the abstract code of what I'm trying to do:
Sub MoveWindowsAtTheTop()
For Each Window that's not maximized
If The Top Position of the Window is within X pixels of the top of the screen Then
Move this window down Y pixels
End If
Next
End Sub
I'm no API expert and I can't get past Enumerating Unmaximized, open windows. I would think I would need to use EnumWindows ; IsWindowVisible() ; GetWindowText ; GetWindowRect ; ClientToScreen ; ScreenToClient ; MoveWindow ; SetWindowPos.
Can anyone convert this to real, working VB6 code (NOT using .NET!)?
We have a poorly written app that we use for our customer database... problem is, this application slowly moves upwards in increments at screen resolutions of 1024x768 or higher for some reason. Eventually, it works its way underneath my app bar.
So, I want my app bar to "bump" windows down X pixels if they take over (or under technically) its space. I'll probably fire it when a user moves their mouse over my App Bar or even clicks it; I think I'd need to scan for all open windows, and if their window hwnd is within the top X pixels, bump them down Y pixels...
Here's the abstract code of what I'm trying to do:
Sub MoveWindowsAtTheTop()
For Each Window that's not maximized
If The Top Position of the Window is within X pixels of the top of the screen Then
Move this window down Y pixels
End If
Next
End Sub
I'm no API expert and I can't get past Enumerating Unmaximized, open windows. I would think I would need to use EnumWindows ; IsWindowVisible() ; GetWindowText ; GetWindowRect ; ClientToScreen ; ScreenToClient ; MoveWindow ; SetWindowPos.
Can anyone convert this to real, working VB6 code (NOT using .NET!)?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
TWCMIL,
If the database app is so "poorly written", you would probably be better off rewriting it in VB. If the app is encountering such severe problems, how trustworthy is the data being manipulated by it? VB is very string at communicating with databases.
Just a thought.
Dang123
If the database app is so "poorly written", you would probably be better off rewriting it in VB. If the app is encountering such severe problems, how trustworthy is the data being manipulated by it? VB is very string at communicating with databases.
Just a thought.
Dang123
ASKER
Well I've tried this:
I like the philosophy that zzzzzooc has... fix my app instead of messing with others, but from my expiriments, it's not possible to prevent every window from moving above a point on the screen. I did add the SetWindowPos() code but the problem is the application would be under the App Bar, not over it. For some reason the DB application thinks it can go under the App Bar. Quite frankly I can manually drag anything under it... it's just that this DB app strangely moves up all by itself.
I'd love to get rid of this DB application, but it's not feasible... we paid $120K+ for it, and it's a GUI front-end of our AS400, and re-training 700+ employees is just not going to happen.
I think I'll stick with the original request... lmckenzie is on track, but since my Windows API knowledge is pretty much non-existent, I just need the code to get a list of window handles so I can pass it to the function lmckenzie posted above to close & award points.
I like the philosophy that zzzzzooc has... fix my app instead of messing with others, but from my expiriments, it's not possible to prevent every window from moving above a point on the screen. I did add the SetWindowPos() code but the problem is the application would be under the App Bar, not over it. For some reason the DB application thinks it can go under the App Bar. Quite frankly I can manually drag anything under it... it's just that this DB app strangely moves up all by itself.
I'd love to get rid of this DB application, but it's not feasible... we paid $120K+ for it, and it's a GUI front-end of our AS400, and re-training 700+ employees is just not going to happen.
I think I'll stick with the original request... lmckenzie is on track, but since my Windows API knowledge is pretty much non-existent, I just need the code to get a list of window handles so I can pass it to the function lmckenzie posted above to close & award points.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The combo of the 2 worked beautifully.
Thanks for all the help... points given for code writers!
Thanks for all the help... points given for code writers!
>> this application slowly moves upwards in increments at screen resolutions of 1024x768 or higher for some reason
I suggest you resolve that issue instead of looking for a solution such as what you asked for. If you'd still like an example of enumerating through all maximized windows, I can come up with something.