Link to home
Start Free TrialLog in
Avatar of patera2
patera2

asked on

help with WM_MOUSEHOVER use

I have two static windows that are created with the API call createwindowex and each contain a bitmap of a button - but what i would like to do is get notified when the user hovers over each of the static windows so i can then change the bitmap to show a depressed bitmap button.

I found the WM_MOUSEHOVER message that i guess is where i need to do the work but i am unable to get any information on using it with delphi in an API created program.

Can anyone help?
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

when you create window with CreateWindowEx you have to pass pointer to WndProc and that's where you handle messages for this window

ziolko.
Avatar of patera2
patera2

ASKER

hanling the messages via the WndProc is no problem - it is getting a message when the mouse is hovering over the button so i can swap out the bitmaps is the problem. checking for the WM_MOUSEHOVER messages doesn't work.
what you mean by: checking for the WM_MOUSEHOVER messages doesn't work.
you dont recive this message or message is recived by window not button?

note that if button is bitmap it will not recive any messages, you can handle
mouse messages in window and then calculate mouse position to determine
if it's on button, make sure you want WM_MOUSEHOVER not WM_MOUSEMOVE

ziolko.
Avatar of patera2

ASKER

I don't get anything when i check for the WM_MOUSEHOVER, WM_MOUSEMOVE or WM_MOUSELEAVE message in the WndProc - although maybe i am doing something wrong.

what i have is two static windows each has a bitmap, when the user moves mouse over any of the static windows i want to swap the bitmap out to show a change then go back to original button bitmap when user moves mouse off the static window.

i have trie checking the iparm for the name of the static window under the different mouse messages but get nothing when i move over each window.
ok, show some code how you create those static windows

ziolko.
Avatar of patera2

ASKER

hbtn1 := CreateWindowEx (0, Pchar('Static'), '', WS_TABSTOP or WS_VISIBLE or
                               WS_CHILD or SS_BITMAP, 10,
                               10, 40, 25, hWindow, 0, hClass.hInstance, nil);

      If hbtn1 <> 0 then
       begin
            hBitmap1:= LoadImage(hClass.hInstance, 'image1', IMAGE_BITMAP, 25, 40, 0);
            SendMessage(hbtn1, STM_SETIMAGE, IMAGE_BITMAP, hBitmap1);

       end;

hbtn2 := CreateWindowEx (0, Pchar('Static'), '', WS_TABSTOP or WS_VISIBLE or
                               WS_CHILD or SS_BITMAP, 10,
                               70, 40, 25, hWindow, 0, hClass.hInstance, nil);


      If hbtn2 <> 0 then
       begin
            hBitmap2:= LoadImage(hClass.hInstance, 'image1', IMAGE_BITMAP, 25, 40, 0);
            SendMessage(hbtn2, STM_SETIMAGE, IMAGE_BITMAP, hBitmap2);

       end;
do you catch any messages in WndProc?
how you set WndProc for newly created windows?

ziolko.
Avatar of patera2

ASKER

yes, i catch WM_SYSCOMMAND, WM_PAINT, etc in the winproc of the main window (hwindow)  - when i create a window for an actual  button i check the WM_SYSCOMMAND for it in the IParm and that all works perfectly - it is the static window i cannot get.

i tried looking for the WM_MOUSEHOVER in the wndproc of the main window and then check the Iparam for the static window (hbtn1 for example) but it doesn;t seem to do anything
ASKER CERTIFIED SOLUTION
Avatar of dinilud
dinilud
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of patera2

ASKER

sorry, had forgotten to close the question.