Hallo allemaal,
In onderstaand code fragment wordt NotePad.Exe op Form1 gezet met behulp van Button4. Werkt prima. Ook het sluiten met Button3 werkt goed.
Nu wil ik m.b.v van een Button een karakter in NotePad plaatsen en ook de scrollbar met een button uitvoeren. Hoe doe je dat?
Code:
unit unit3;
{$mode objfpc}{$H+}
interface
uses Windows, ShellApi, Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, Buttons;
type
...
...
Var
Form1: TForm1;
WPM: WINDOWPLACEMENT;
A: HWND;
implementation
{$R *.lfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
SendMessage(A,WM_DESTROY,0,0); // Sluit NotePad.exe
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
ShellExecute(Application.Handle, 'Open', 'NotePad.exe', nil, nil, SW_NORMAL);
Sleep(100);
A := FindWindow(nil, PChar('Naamloos - Kladblok'));
memo1.lines.Add(IntToStr(Application.Handle)+' '+inttostr(A));
if A <> 0 then
begin
SetForegroundWindow(a);
Windows.SetParent(a, Form1.Handle);
SetWindowLong(A, GWL_STYLE, GetWindowLong(A, GWL_STYLE) and not WS_CAPTION);
WPM.Length := SizeOf(WPM);
GetWindowPlacement(A, @WPM);
WPM.rcNormalPosition := Classes.Rect(0, 130, Form1.Width, Form1.Height);
SetWindowPlacement(A, @WPM);
end;
end;
Bookmarks