Solved

help with WM_MOUSEHOVER use

Posted on 2007-03-30
12
1,394 Views
Last Modified: 2012-06-21
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
Comment
Question by:patera2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 18822365
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
 

Author Comment

by:patera2
ID: 18822402
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
 
LVL 21

Expert Comment

by:ziolko
ID: 18822416
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
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!

 

Author Comment

by:patera2
ID: 18822463
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
 
LVL 21

Expert Comment

by:ziolko
ID: 18822471
ok, show some code how you create those static windows

ziolko.
0
 

Author Comment

by:patera2
ID: 18822494
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
 
LVL 21

Expert Comment

by:ziolko
ID: 18822781
do you catch any messages in WndProc?
how you set WndProc for newly created windows?

ziolko.
0
 

Author Comment

by:patera2
ID: 18822892
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
 
LVL 10

Accepted Solution

by:
dinilud earned 250 total points
ID: 18828586
0
 

Expert Comment

by:dciambrone
ID: 18994382
0
 

Author Comment

by:patera2
ID: 21134263
sorry, had forgotten to close the question.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show Listview image from database (String field) 5 152
oracle global variables 4 80
How to debug For loops? 3 63
Delphi Yen format 3 62
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question