Guten morgen,
ich habe ein Problem wo ich noch nicht so richtig mit umzugehen weiß.
Ich erstelle ein Bild als Static-Control, weise dem ein OnClick (SS_NOTIFY) zu, aber dann funktioniert mein MouseOver-Event nicht mehr.
Schalte ich OnClick aus, funktioniert MouseOver wieder.
Ich hätte gerne beides auf einmal, was mache ich falsch?
Hier relevante Code teile:
Delphi-Quellcode:
// variablen:
const
IDC_BMP = 1000;
var
hWndBmp: HWND;
//hier im Message handler WndProc...
WM_CREATE:
begin
hWndBmp := CreateWindowEx(
0,
'STATIC', 'VOID',
WS_VISIBLE or WS_CHILD
SS_NOTIFY or SS_BITMAP,
10, 5, 32, 32,
hWnd, IDC_BMP, hInstance, nil);
end;
WM_COMMAND:
begin
if HiWord(wParam) = STN_CLICKED then
case LoWord(wParam) of
IDC_BMP:
begin
// mach was
end;
end;
end;
WM_MOUSEMOVE:
begin
// get current coordinates
pt.x := Word(lParam);
pt.y := Word(lParam shr 16);
// switch cursor back to normal if outside of image
if ((ChildWindowFromPoint(hWnd, pt) <> hWndBmp)
and (GetCursor <> Cardinal(IDC_ARROW))) then
SetCursor(LoadCursor(0, IDC_ARROW));
// switch cursor if over image
if ((ChildWindowFromPoint(hWnd, pt) = hWndBmp)
and (GetCursor <> Cardinal(IDC_HAND))) then
SetCursor(LoadCursor(0, IDC_HAND));
end;
WM_LBUTTONDOWN:
begin
(*
dirty workaround wenn SS_NOTIFY nicht gesetzt wurde.
hier code von mouseover reinkopieren
hier code von onclick reinkopieren
*)
end;