Вниз
Скачать: CL | DM;

Position message box   Найти похожие ветки 

← →
Jon ©   (2008-08-12 13:20) [0]

How can ShowMsg be centered on parent form instead of sreen?


← →
azsd ©   (2008-08-12 23:58) [1]

you can use SetWindowHookEx to get rid of popuped MessageBox, or you can using an NewThreadEx() to create a thread, then get the message box by findwindow and move it. but I suggest to new a form with same layout like Messagebox then ShowModal() it.


← →
Jon ©   (2008-08-13 01:58) [2]

Thanks for mentioning hooks!
This is my solution:


program Test;

uses
 Windows, Messages, KOL;

var
 Hook: HHOOK;

function HookProc(Code,wParam,lParam: Integer): Lresult; stdCall;
var
 Wnd: Hwnd;
 Rect: TRect;
 MB_Width, MB_Height: Integer;
begin
 if Code < 0 then
   CallNextHookEx(Hook,Code,wParam,lParam);
 if Code = HCBT_ACTIVATE then
 begin
   Wnd := wParam;
   GetWindowRect(Wnd,Rect);
   MB_Width := Rect.Right - Rect.Left;
   MB_Height := Rect.Bottom - Rect.Top;
   MoveWindow(Wnd,Applet.Left + ((Applet.Width - MB_Width) div 2),Applet.Top + ((Applet.Height - MB_Height) div 2),MB_Width,MB_Height,True);
   UnhookWindowsHookEx(Hook);
 end;
 Result := CallNextHookEx(Hook,Code,wParam,lParam);
end;

procedure MouseDown(Dummy: Pointer; Sender: PControl; var Mouse: TMouseEventData);
begin
 if Mouse.Button <> mbLeft then Exit;
 Hook := SetWindowsHookEx(WH_CBT,HookProc,0,GetCurrentThreadId);
 ShowMsg(">> Click! <<",MB_OK or MB_APPLMODAL or MB_SETFOREGROUND);
//  UnhookWindowsHookEx(Hook);
end;

begin
 Applet := NewForm(nil,"Test").SetSize(640,480);
 Applet.OnMouseDown := TOnMouse(MakeMethod(nil,@MouseDown));
 Run(Applet);
end.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.064 c
15-1267787785
boriskb
2010-03-05 14:16
2010.08.27
Налог на болванки


15-1268650699
Омлет
2010-03-15 13:58
2010.08.27
Проверка на выпуклость четырехугольника


3-1239785375
ocean
2009-04-15 12:49
2010.08.27
Как лучше искать по текстовому полю?


15-1264580056
12
2010-01-27 11:14
2010.08.27
А кто-то во что-то играет?Интересуют неглупые стрелялки от 1 лица


2-1268463477
Тофер
2010-03-13 09:57
2010.08.27
Как узнать анкор на странице в TWebBrowser




   Наверх