I need to create a utility to drag windows from outside of the application.

Started by
14 comments, last by MarkS 14 years, 1 month ago
Sorry for the confusing title, but here is what I'm after and why. I work for a large family entertainment restaurant/game room. We use a very poorly designed (and I'm assuming cheap) point of sale (POS) software system. It would appear that the user interface was designed by trained monkeys. The main window for the new administrator software we just upgraded to requires a monitor with a resolution of 1024x768. The window can be resized, but nothing in the window resizes or reconfigures, and most odd, there are no scroll bars. Anyway, our tech manager uses a small netbook to diagnose games, but the screen size is less than 1024x768. Because of this, he can no longer get to the parts of the interface to do some of the work he needs to do. The company that wrote the software just doesn't seem to care to answer inquiries about the issues we are having. What he needs is a utility where he can press a hot key and then be able to click and drag the window to where he needs it, from any point in the window (title bar is out since it will need to be moved off screen). How to do this without hacking the program is what stumps me. I need to write a background app that sits and waits for a hot key to be pressed and then takes control of any mouse events in the active window until another hot key is pressed. I'm just too new to Windows programming. I'm still learning event handling, and this goes beyond my knowledge. MSDN is not too helpful since it requires you to know what you're looking for and I really have no idea. Any ideas would be appreciated.

No, I am not a professional programmer. I'm just a hobbyist having fun...

Advertisement
Tried Alt+Space+M? ;)

Edit: As for what you're trying to do.. How about using SetWindowsHookEx with WH_CALLWNDPROC and then intercepting WM_MOUSEMOVE/WM_LBUTTONDOWN/WM_LBUTTONUP? You could probably use WindowFromPoint to test whether you're in the client area of the window or over a child/control in the window and then MoveWindow appropriately.
But you will have to pay attention not to cause a deadlock; WindowFromPoint might send WM_NCHITTEST and MoveWindow will of course also send messages to the window, so you need to make sure never to call these in response to messages that they can cause.
Quote:Original post by pablo24
Tried Alt+Space+M? ;)


I wasn't aware of such a feature, but doing so forces the mouse to the title bar. That will not work as the window will need to be dragged from within the client rect.

Quote:Original post by pablo24
Edit: As for what you're trying to do.. How about using SetWindowsHookEx with WH_CALLWNDPROC and then intercepting WM_MOUSEMOVE/WM_LBUTTONDOWN/WM_LBUTTONUP? You could probably use WindowFromPoint to test whether you're in the client area of the window or over a child/control in the window.


Thanks, I'll look into that.

No, I am not a professional programmer. I'm just a hobbyist having fun...

Quote:I wasn't aware of such a feature, but doing so forces the mouse to the title bar. That will not work as the window will need to be dragged from within the client rect.

I find myself using this method to bring back windows to the desktop after I switched from a dual-monitor setup at home/office on a regular basis.

I am usually able to move any window type, even those without a title bar (unnecessary fancy GUIs etc.) using the cursor keys - you should at least give it a try.
Ah. Arrow keys. Now it makes sense. That will work perfectly. I'll let him know about this today. Thanks guys!

No, I am not a professional programmer. I'm just a hobbyist having fun...

Quote:Original post by maspeir

uses a small netbook


My EEE came with a tool that allows resolution to be full 1024x768, and will automatically scroll.

Some drivers also allow desktop to be larger than physical screen, check the display settings.

Google for "scrolling virtual desktop".
I don't think alt+space+m will work (I hope it does though), because Windows will automatically move the window back when you press enter to ensure at least a small part of its title bar remains within the work area. However, this doesn't happen when you use something like SetWindowPos().
Quote:Original post by Amr0
I don't think alt+space+m will work (I hope it does though), because Windows will automatically move the window back when you press enter to ensure at least a small part of its title bar remains within the work area. However, this doesn't happen when you use something like SetWindowPos().


Yep. I'm at work and just verified this. :( Looks like I'll be writing a utility...

No, I am not a professional programmer. I'm just a hobbyist having fun...

Couple quick thoughts.

Try remote desktop from the small screen system to a large screen desktop running the app. I think it will give you the ability to scroll the whole desktop/window.

Or, simply re-parent the window into your own application window and add scroll bars. Should be trivial with a bit of C# and a few interop calls.
Quote:Original post by pjcast
Or, simply re-parent the window into your own application window and add scroll bars. Should be trivial with a bit of C# and a few interop calls.


I tried this and it seemed simple. It worked perfectly while under development in Visual C++ 2008, but the moment I tried the app from the desktop, it failed to work.

The problem is that I do not have the application on my home computer and it requires serves on our server to run, so I cannot get a copy. On top of that, I cannot install Visual Studio at work. As such, I'm trying to parent the top most window when my program runs. However, clicking on an icon on the desktop actives the desktop window and the program ends up parenting it instead.

I've tried just about every "GetXXWindow" function I can and none of them work. I'm guessing that the window list is tied to the current process.

Any idea how to get a handle to the window of another application under my main window?

No, I am not a professional programmer. I'm just a hobbyist having fun...

This topic is closed to new replies.

Advertisement