Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1526
  • Last Modified:

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?
0
patera2
Asked:
patera2
1 Solution
 
ziolkoCommented:
when you create window with CreateWindowEx you have to pass pointer to WndProc and that's where you handle messages for this window

ziolko.
0
 
patera2Author Commented:
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.
0
 
ziolkoCommented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
patera2Author Commented:
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.
0
 
ziolkoCommented:
ok, show some code how you create those static windows

ziolko.
0
 
patera2Author Commented:
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;
0
 
ziolkoCommented:
do you catch any messages in WndProc?
how you set WndProc for newly created windows?

ziolko.
0
 
patera2Author Commented:
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
0
 
patera2Author Commented:
sorry, had forgotten to close the question.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now