?
Solved

SetWindowPos alternative ?

Posted on 2007-07-23
21
Medium Priority
?
880 Views
Last Modified: 2009-12-16
Hi,

Sometimes SetWindowPos doesn't work. It doesn't move the program at all. Why? And is there an alternative to move it anyway?

Thank you.
0
Comment
Question by:TonyJix
  • 11
  • 5
  • 3
  • +2
21 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 19549751
what kind of window is it? Is it one of yourself of from another app?
0
 

Author Comment

by:TonyJix
ID: 19549790
Another app.
0
 

Author Comment

by:TonyJix
ID: 19549793
I know the Handle, and then I do:

SetWindowPos(Wnd, 0, 100, 100, 0, 0, 0);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 19

Expert Comment

by:MerijnB
ID: 19549804
it's quite possible the window itself doesn't allow it to be resized.
Did you try this same code on another window (from another app)?
0
 

Author Comment

by:TonyJix
ID: 19549806
^ This is doing fine with many Apps... just this one App won't move... So i figured maybe theres an alternative.
0
 

Author Comment

by:TonyJix
ID: 19551856
Anyone an alternative to SetWindowPos?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19553631
like MerijnB posted some apps don't allow to resize (see Constraints property of form in delphi)

ziolko.
0
 

Author Comment

by:TonyJix
ID: 19553923
I don't want to resize, I want to move the App.
Should be possible, since my mouse is able to move the app too.
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 19553951
there is MoveWindow() but I doub't if that will work.

Are you sure that the coordinates you give to SetWindowPos() result in the same size as the window already has?
0
 

Author Comment

by:TonyJix
ID: 19554029
Yes, I set the NOSIZE flag.
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19554157
try like this



  WinRect: TRect;
begin

  GetWindowRect(wnd, WinRect);
  MoveWindow(wnd, 100, 100, WinRect.Right-WinRect.Left, WinRect.Bottom-WinRect.Top, True);
end
0
 

Author Comment

by:TonyJix
ID: 19554855
Not moving the winwdow...
0
 

Author Comment

by:TonyJix
ID: 19554873
Maybe it's possible to move the mouse to the title bar of the window, let it hold the left mouse button, and then move the mouse to a position... Possible ?
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19554910
How you get the window handle?
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19554917
Is that window handle is correct?
0
 

Author Comment

by:TonyJix
ID: 19554938
Yes, it is...

I even did GetWindowText to verify.

Besides, the code I use works with Notepad and many other Apps.. just not this one.
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19555049
from where you get that application
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19555186
Using Microsoft's Spy++ check the message flow while using mouse and using Code.
0
 

Author Comment

by:TonyJix
ID: 19555213
The problem is not Delphi... it is Windows Vista setting...

On my laptop (Vista), the code won't move the window, but on this computer (Also Vista), it will move the App... weird... used to work on both.
0
 

Author Comment

by:TonyJix
ID: 19558447
Is it possible to move window with a SendMessage command?
0
 
LVL 6

Accepted Solution

by:
Hardi earned 2000 total points
ID: 19573157
http://delphi.about.com/od/vclusing/a/mouseadvanced.htm
See Simulations
You can simulate mouse button down, then mouse move, then mouse button up

About Mouse_Event on MSDN:
http://msdn2.microsoft.com/en-us/library/ms646260.aspx
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question