Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-02

Re: How to resize window under win32? (Jeff Pohlmeyer)

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernhard Steffen
Show quoted text 7 lines
> I'm launching another program from Freepascal program through > "exec" I need code that can set the position and size of the > started program. I haven't used Windows in a while, but I think you need CreateProcess() instead of WinExec() [...]

If you have access to the source code of the launched program, you can use the SetWindowPos function to set the window position and size from within that program.

Bernhard

Reply by email

Matt D. Emson

I sent more or less this info yesterday, but it bounced (my ISP doesn't like redirecting email from my work IP address!!!).... I think the CreateProcess idea is better than this one, but just in case...

Assuming you have a window with the caption 'Untitled - Notepad' (running notepad.exe will get you this)

Function  ResizeWindow(const Caption: pchar; const AWidth, Aheight:
integer): boolean; var
  h: Thandle;
  r: Trect;
  Width, Height, Left, Top: integer;
begin
  Result := False;
  h := FindWindow( nil, Caption );
  if (h  0) and GetWindowRect(h, r) then begin
    Width := (r.right - r.left);
    Height := (r.Bottom - r.top);
    Left := r.Left;
    Top := r.Top;
    if (Awidth = Width) and (Aheight = height) then exit; //don't bother
if the size is same
    Windows.MoveWindow(h, Top, Left, Width, Height, true); //DOH!! Silly
api name M$ 2 API's would have been
//easier... If you want to move the window you
//must track it's size too!!!!
    Result := True; //<--- only return true is we do a resize.... You
could put this above the line
			  //		"if (Awidth..." if you want to
know that you 'found the window' but
			  //        didn't necessarily move it.
  end;
end;

Therefore:

  Resizewindow('Untitled - Notepad', 10, 10);
Show quoted text 33 lines
-----Original Message----- From: On Behalf Of Bernhard Steffen Sent: 28 February 2003 12:07 To: Subject: [fpc-pascal]Re: How to resize window under win32? (Jeff Pohlmeyer) > > I'm launching another program from Freepascal program through "exec" > > I need code that can set the position and size of the started > > program. > > I haven't used Windows in a while, but I think you need > CreateProcess() instead of WinExec() > [...] If you have access to the source code of the launched program, you can use the SetWindowPos function to set the window position and size from within that program. Bernhard -- http://www.bernhard-steffen.de/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/f> pc-pascal

Reply by email