Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2010.08.27;
Скачать: 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 вся ветка

Текущий архив: 2010.08.27;
Скачать: CL | DM;

Наверх




Память: 0.45 MB
Время: 0.065 c
15-1264368629
Юрий
2010-01-25 00:30
2010.08.27
С днем рождения ! 25 января 2010 понедельник


15-1274352889
crazy~driver
2010-05-20 14:54
2010.08.27
Распечатать с dbgrid


2-1275034068
Сергей
2010-05-28 12:07
2010.08.27
Фокус на файл


6-1223985468
flags8192
2008-10-14 15:57
2010.08.27
HTTP и Cookies


11-1212343554
Сашик
2008-06-01 22:05
2010.08.27
OleVariant и OleObject в KOL Delphi 4





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский