Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maxamize a program from a Delphi 7.0 program .

Status
Not open for further replies.

WayneStev

Programmer
Jan 3, 2006
21
0
0
US
I NEED TO MAXAMIZE A PROGRAM FROM A RUNING DELPHI 7.0 PROGRAM. Can any one offer me any suggestions or help.
 
Use the [tt]WindowState[/tt] property:
Code:
  Form1.WindowState := wsMaximized; // type TWindowState = (wsNormal, wsMinimized, wsMaximized)

Check out the help on [tt]WindowState[/tt], [tt]Application.Minimize[/tt] and [tt]Application.Restore[/tt] - it's all there.

Cheers,
Chris [pc2]
 
For some resion no one seems to understand the quistion. So I will try to make real simple. Because I don't know what else to do. OK I have two different seperat programs runing in computer memory at the same time. Now I NEED TO RUN OR Maxamize ONE OF THE PROGRAMS BY CALLING FROM THE OTHER. SIMPLE IDEA but I don't know how to make this happen CAN ANY ONE MAKE A SUGGESTION.

Maxemize one seperate running program in commom memory from an other running program.
WayneStev

 
WayneSteve: Firstly please do not use capitals in your posts, this is considered to be equivalent to shouting, and some members will red flag you immediately.

I don't know how to maximise a running program, you will need to get the windows handle I expect. I am sure this question has been asked before, a search of the forum should get you the answer.

This code will call and run another program in whatever window you choose.


From the fmxutil library
Code:
function ExecuteFile(const FileName, Params, DefaultDir: string;
  ShowCmd: Integer): THandle;
var
  zFileName, zParams, zDir: array[0..79] of Char;
begin
  Result := ShellExecute(Application.MainForm.Handle, nil,
    StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
    StrPCopy(zDir, DefaultDir), ShowCmd);
end;

The showCmd parameter can be SW_MAXIMIZE so the called program will run in a maximised window.



Steve: Delphi a feersum engin indeed.
 
Hi!

first you should make access to that application that you want to miximize or something else....

to do this you should get the handle of that application's window....

to get the handle you can use several functions, but I think the easier one is FindWindowByTitle =>

{***************************************}
function FindWindowByTitle(WindowTitle: string): Hwnd;
var
NextHandle: Hwnd;
NextTitle: array[0..260] of char;
begin
// Get the first window
NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
while NextHandle > 0 do
begin
// retrieve its text
GetWindowText(NextHandle, NextTitle, 255);
if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
begin
Result := NextHandle;
Exit;
end
else
// Get the next window
NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
end;
Result := 0;
end;
{***************************************}

Now we got the handle so we can send a command to that window via it's handle by this function =>

sendmessage(handle,wm_syscommand,sc_maximize,0);
{***************************************}

Example =>

var
h:thandle;
begin

h := findwindowbytitle('Notepad');
if h<>0 then
sendmessage(h,wm_syscommand,sc_maximize,0)
else
showmessage('Window not found');

end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top