Get number of MDIChild forms
Use MDIChildCount property of Form. This property contains number of open MDI child forms.
with Form1 do Caption:='Count of MDIChild forms is '+ IntToStr(MDIChildCount);
Use MDIChildCount property of Form. This property contains number of open MDI child forms.
with Form1 do Caption:='Count of MDIChild forms is '+ IntToStr(MDIChildCount);
This example shows a creation of Message Dialog relative to center of Form1.
procedure TForm1.Button1Click(Sender: TObject); var MyForm: TForm; begin MyForm:=CreateMessageDialog('This is example', mtInformation, [mbOk]); with MyForm do begin Height:=130; Width:=150; Left:=Trunc((Form1.Width-Width)/2)+Form1.Left; Top:=Trunc((Form1.Height-Height)/2)+Form1.Top;; ShowModal; end; end;
You can use onMouseMove event for your form. This event has coordinates of mouse position.
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Label1.Caption:=IntToStr(X); Label2.Caption:=IntToStr(Y); end;
You must intercept WM_MOVE message. Implementation of this idea is so:
type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; private procedure MyMessage(var Msg: TWMMove); message WM_MOVE; { Private declarations } public { Public declarations } end; ... procedure TForm1.MyMessage(var Msg: TWMMove); begin if Msg.Result=0 then begin Label1.Caption:='x - '+IntToStr(Msg.XPos); Label2.Caption:='y - '+IntToStr(Msg.YPos); end; end;
Try to use SetWindowPos WinAPI function to make a Delphi-form to stay on top: And for lose stay on top, you should change HWND_BOTTOM to HWND_TOPMOST in this function.
SetWindowPos( Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);