Controlling EXE files

I've make a program like Windows Explorer which execute EXEs.
The question is, can I arrange all executed EXEs to TILE/CASCADE like
in MDI?

Need a help for this,

Daniel
LVL 7
daniel_cAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:

Hi

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,ShellApi;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
 
implementation

{$R *.DFM}
function CreateProcessSimple(sExecutableFilePath : string ): string;
  var
   pi: TProcessInformation;
   si: TStartupInfo;
   wnd : hwnd;
   i : integer;
  begin
   FillMemory( @si, sizeof( si ), 0 );
   si.cb := sizeof( si );
    CreateProcess(Nil, PChar( sExecutableFilePath ),
                  Nil, Nil, False, NORMAL_PRIORITY_CLASS,
                  Nil, Nil, si, pi );

      WaitForSingleObject(pi.hProcess,1000);
   wnd:= FindWindow(nil, PChar('Untitled - Notepad'));
   setwindowpos(wnd,HWND_TOPMOST,0,0,0,0,SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE);
   CloseHandle( pi.hProcess );
   CloseHandle( pi.hThread );
  end;

procedure TForm1.Button1Click(Sender: TObject);
begin
CreateProcessSimple('notepad.exe');
end;


procedure TForm1.Button2Click(Sender: TObject);
var h: THandle;
begin
  h:= FindWindow(nil, PChar('Untitled - Notepad'));
  SendMessage(h, WM_CLOSE, 0, 0);
end;


end.

use in the HWND_TOPMOST,0,0,0,0
the 0,0,0,0 equals :
    int X,      // horizontal position
    int Y,      // vertical position
    int cx,      // width
    int cy,      // height
   


also look at movewindow() api:
from win32.hlp:

The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.

BOOL MoveWindow(

    HWND hWnd,      // handle of window
    int X,      // horizontal position
    int Y,      // vertical position
    int nWidth,      // width
    int nHeight,      // height
    BOOL bRepaint       // repaint flag
   );      
 

Parameters

hWnd

Identifies the window.

X

Specifies the new position of the left side of the window.

Y

Specifies the new position of the top of the window.

nWidth

Specifies the new width of the window.

nHeight

Specifies the new height of the window.

bRepaint

Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives a WM_PAINT message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of moving a child window. If this parameter is FALSE, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.


hope taht helps some#
Regards Barry
0
 
men xinCEOCommented:
following
0
 
daniel_cAuthor Commented:
Thanks Barry...
I'll try it first!
0
 
rwilson032697Commented:
Listening!
0
 
daniel_cAuthor Commented:
Thanks Barry!
0
All Courses

From novice to tech pro — start learning today.