Moving Windows 
Author Message
 Moving Windows

So call me old, but I am having a problem.  My moniter is quite old and only
supports 640 X 480.  I have a program (made by another company) which is
suppose to help with clocks.  The problem is, the programmer has the forms
off my screen.  They are still there, they show up in my taskbar, but they
are too far to move.  How would I move the forms back to my screen from a
program I create?  I know it has to work with APIs to Windows, but I just
don't know the calls!  Thank-you for any help!

15-year-old VBer



Mon, 01 Jul 2002 03:00:00 GMT  
 Moving Windows
Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal _
lpClassName As String, ByVal lpWindowName As String)

Declare Function MoveWindow& Lib "user32" (ByVal hwnd As Long, ByVal x As
Long, _
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint
As _
Long)

Parameter Type/Description
hwnd LongHandle of the window to move.
x LongNew left position for the window.
y LongNew top position for the window.
nWidth LongNew width for the window.
nHeight LongNew height for the window.
bRepaint LongTRUE (nonzero) if window should be redrawn. FALSE (zero)
indicates that the application will explicitly redraw the window.

Dim NWi&, NHe&

hw& = FindWindow("", "Window Title")
dl& = MoveWindow(hw&, 250, 250, NWi, NHe, True)

Quote:

>So call me old, but I am having a problem.  My moniter is quite old and

only


Mon, 01 Jul 2002 03:00:00 GMT  
 Moving Windows
Thank-you for that quick reply, but it doesn't work.  I typed in the title
EXACTLY as I see it in the taskbar, but it won't budge.  I placed some
"DEBUG.PRINT"s in, and it returned 0 at the FindWindow  What is the empty
string for?

Quote:
> Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal _
> lpClassName As String, ByVal lpWindowName As String)

> Declare Function MoveWindow& Lib "user32" (ByVal hwnd As Long, ByVal x As
> Long, _
> ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
bRepaint
> As _
> Long)

> Parameter Type/Description
> hwnd Long-Handle of the window to move.
> x Long-New left position for the window.
> y Long-New top position for the window.
> nWidth Long-New width for the window.
> nHeight Long-New height for the window.
> bRepaint Long-TRUE (nonzero) if window should be redrawn. FALSE (zero)
> indicates that the application will explicitly redraw the window.

> Dim NWi&, NHe&

> hw& = FindWindow("", "Window Title")
> dl& = MoveWindow(hw&, 250, 250, NWi, NHe, True)


> >So call me old, but I am having a problem.  My moniter is quite old and
> only



Mon, 01 Jul 2002 03:00:00 GMT  
 Moving Windows
Use vbNullString for the classname, not "".

--

Randy Birch, MVP Visual Basic

http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/

| > hw& = FindWindow("", "Window Title")
| > dl& = MoveWindow(hw&, 250, 250, NWi, NHe, True)
| >



Mon, 01 Jul 2002 03:00:00 GMT  
 Moving Windows


Quote:
> So call me old, but I am having a problem.  My moniter is quite old
and only
> supports 640 X 480.  I have a program (made by another company) which
is
> suppose to help with clocks.  The problem is, the programmer has the
forms
> off my screen.  They are still there, they show up in my taskbar, but
they
> are too far to move.  How would I move the forms back to my screen
from a
> program I create?  I know it has to work with APIs to Windows, but I
just
> don't know the calls!  Thank-you for any help!

SetWindowPos will do it if you can get a handle to the window -- you
probably can do that by using FindWindow with the caption.

Another idea might be to Alt-Tab to make it the active app, then Alt-
Space to open the control menu, M for move and then use the left and/or
right arrows (hold them each down for a while) to move the window up to
the visible area.  Press Enter to drop the window in the new location.

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 02 Jul 2002 03:00:00 GMT  
 Moving Windows


Quote:
> Another idea might be to Alt-Tab to make it the active app, then Alt-
> Space to open the control menu, M for move and then use the left and/or
> right arrows (hold them each down for a while) to move the window up to
> the visible area.  Press Enter to drop the window in the new location.

Actually, here's a trick: after pressing M to put the window into move mode,
press any direction arrow once. Then move your mouse. The title bar will be
locked on the mouse and you can move it around. Click a button or hit Enter
to "drop" the window. Saves you from having to hold down an arrow key
forever.


Tue, 02 Jul 2002 03:00:00 GMT  
 Moving Windows
Thanks for the replies.  Now I have another question:  How do I keep the
size of the window when I move it?  It's not a resizable window, but when I
move it, I change the size.  Is there an API to catch the size of the
window?


Wed, 03 Jul 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Newbie: Moving windows

2. REALLY NEED HELP: Moving windows

3. Moving Windows around

4. moving windows while calculating

5. Assistance with activating, sizing and moving Windows in VB

6. Help in starting, sizing and moving Windows apps in VB 4.0

7. REALLY NEED HELP: Moving windows

8. Moving Windows

9. Moving Windows

10. Moving Windows around

11. REALLY NEED HELP: Moving windows

12. Moving windows without titlebar

 

 
Powered by phpBB® Forum Software