easy window position question.

junior_tim
junior_tim used Ask the Experts™
on
Hello,

I made a small app, it has only two forms, in the form setting windowstate = maximaized.

when I execute the app on my computer works great but on other computer the maximized state of the app doesnt cover all the screen, and part of the app gets out of the screen from the rigth side What is the problem?

thanks
   
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

Did you try setting the form to screen position?
 an example


procedure FormOnScreen(aform: TCustomForm);
var
  rect, scrRect: TRect;
begin
  scrRect.Left := 0;
  scrRect.top := 0;
  scrRect.Right := screen.width;
  scrRect.bottom := screen.height;
  if not intersectRect(rect, scrRect, aform.boundsRect) then
  begin
    aform.Left := 0;
    aform.top := 0;
  end;
end;
------------
T.

Author

Commented:
Did not work. that code didnt do anything.
Commented:
Try maximizing the forms at run-time and leave the windowstate default option to wsNormal.

Then, on the to-max-form, add this to the oncreate handler:

Form1.WindowState = msMaximized;
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Top Expert 2008

Commented:
hmmm I supose its on WinXP.
ziolko.

Commented:
I have used the following w/o problems under 9x, which covers the taskbar also. Under XP needed to use HWND_TOPMOST. So somethings have changed. As mentioned be another person I would set the top/left coords before maximizing the window.


  SetWindowPos(Handle,
               HWND_TOP,
               0, 0,
               GetSystemMetrics(SM_CXSCREEN),
               GetSystemMetrics(SM_CYSCREEN),
               SWP_SHOWWINDOW or SWP_NOACTIVATE) ;

  SetActiveWindow(Application.Handle);
  SetForegroundWindow(Handle) ;

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial