2009/12/16 "Arí Ricardo Ody" <[email protected]>:
> I have no idea how I can capture the mentioned message. Could you send an
> example, please?
I have attached a few functions, but it's not complete example. I
don't have access to windows right now.
Call SetMyWndProc() with a handle of your main form to hook into
message queue and add code to handle WM_DEVICECHANGE in MyWndProc().
--
cobines
var
OldWProc: WNDPROC;
function MyWndProc(hWnd: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM):
LRESULT; stdcall;
begin
case uiMsg of
WM_DEVICECHANGE:
if (wParam = DBT_DEVICEARRIVAL) or (wParam = DBT_DEVICEREMOVECOMPLETE)
then
begin
// Device added or removed detected.
// Add handling code here.
Exit(TRUE);
end;
end;
Result := CallWindowProc(OldWProc, hWnd, uiMsg, wParam, lParam);
end;
procedure SetMyWndProc(Handle : THandle);
begin
OldWProc := WNDPROC(SetWindowLong(Handle, GWL_WNDPROC, LONG_PTR(@MyWndProc)));
end;
// Somewhere in OnCreate of your main form.
procedure TMainForm.FormCreate(Sender: TObject);
begin
SetMyWndProc(Handle);
end;
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus