I read a few posts here on StackOverflow, but no one worked for me. Here is the code that I use to display the standard calculator window in 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 displays a window in my form, but the glass border is lost and sometimes (especially when I move my form), it is difficult to restore focus to the built-in window (I need to click several times).
What could be the reason for this? Also, do you see any potential problems that I may encounter when using this method?
Thank you for your time.
source share