Solved

help with WM_MOUSEHOVER use

Posted on 2007-03-30
12
1,362 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
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple image collision 13 75
SUM 2 INTEGER ARRAYS INTO 1 10 100
CheckListBox usage 3 59
Firemonkey DbLookupComboBox equivalent ? 2 47
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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