I have read some posts here on StackOverflow, but none has worked for me. Here is the code I am using to display the window of the standard Calculator on my form:
procedure TForm1.Button1Click(Sender: TObject);
var
Tmp: Cardinal;
R: TRect;
begin
CalcWindow := FindWindow(nil, 'Calculator');
if (CalcWindow <> 0) then
begin
GetWindowThreadProcessID(CalcWindow, CalcProcessID);
Tmp := GetWindowLong(CalcWindow, GWL_STYLE);
Tmp := (Tmp and not WS_POPUP) or WS_CHILD;
SetWindowLong(CalcWindow, GWL_STYLE, Tmp);
GetWindowRect(CalcWindow, R);
SetForegroundWindow(CalcWindow);
Windows.SetParent(CalcWindow, Panel1.Handle);
SetWindowPos(CalcWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_FRAMECHANGED);
AttachThreadInput(GetCurrentThreadID(), CalcWindow, True);
end;
end;
It does display the window on my form, but the glass border is lost and sometimes (especially when I move my form), it is hard to restore the focus to the embedded window (I need to click several times).
What may be causing this? Also, do you see any potential issues I may get into with using this method?
Thank you for your time.
See Question&Answers more detail:os