CWnd & CStatic Based Windows, How to detect mouse leaving the win

Hello,

I am creating a new window class based on CWnd.  I am placing it on the View 
(CFormView).    How can I get the notification or any other indication that 
the cursor/mouse is not on this window?

I also tried the same to create a new window based on CStatic but I was not 
able to detect when the mouse leaves the window.

Regards,
Eitan
0
Eitan (21)
4/28/2005 6:34:03 AM
vc.mfc 33608 articles. 0 followers. Follow

12 Replies
999 Views

Similar Articles

[PageSpeed] 2

> I am creating a new window class based on CWnd.  I am placing it on the 
> View
> (CFormView).    How can I get the notification or any other indication 
> that
> the cursor/mouse is not on this window?
>
> I also tried the same to create a new window based on CStatic but I was 
> not
> able to detect when the mouse leaves the window.

The easiest should be handling WM_MOUSEMOVE - or what exactly is the 
problem?

-- 
Guido Stercken-Sorrenti
MVP - Visual Developer / Visual C++ 


0
mspbn (41)
4/28/2005 8:14:18 AM
or if you're not catering to W95-o-philes, you can use WM_MOUSELEAVE.

You'll need to find out about TRACKMOUSEEVENT.

HTH.

"Guido Stercken-Sorrenti [MVP VC++]" <mspbn@stercken-sorrenti.com> wrote in
message news:eiGOCp8SFHA.3464@tk2msftngp13.phx.gbl...
> > I am creating a new window class based on CWnd.  I am placing it on the
> > View
> > (CFormView).    How can I get the notification or any other indication
> > that
> > the cursor/mouse is not on this window?
> >
> > I also tried the same to create a new window based on CStatic but I was
> > not
> > able to detect when the mouse leaves the window.
>
> The easiest should be handling WM_MOUSEMOVE - or what exactly is the
> problem?
>
> --
> Guido Stercken-Sorrenti
> MVP - Visual Developer / Visual C++
>
>


0
KMA (44)
4/28/2005 9:43:40 AM
The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.  
However I would like to get some notification the moment the mouse LEAVE the 
window.  
Thanks, Eitan

"Guido Stercken-Sorrenti [MVP VC++]" wrote:

> > I am creating a new window class based on CWnd.  I am placing it on the 
> > View
> > (CFormView).    How can I get the notification or any other indication 
> > that
> > the cursor/mouse is not on this window?
> >
> > I also tried the same to create a new window based on CStatic but I was 
> > not
> > able to detect when the mouse leaves the window.
> 
> The easiest should be handling WM_MOUSEMOVE - or what exactly is the 
> problem?
> 
> -- 
> Guido Stercken-Sorrenti
> MVP - Visual Developer / Visual C++ 
> 
> 
> 
0
Eitan (21)
4/28/2005 6:08:02 PM
The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.  
However I would like to get some notification the moment the mouse LEAVE the 
window.  
Thanks, Eitan

"Guido Stercken-Sorrenti [MVP VC++]" wrote:

> > I am creating a new window class based on CWnd.  I am placing it on the 
> > View
> > (CFormView).    How can I get the notification or any other indication 
> > that
> > the cursor/mouse is not on this window?
> >
> > I also tried the same to create a new window based on CStatic but I was 
> > not
> > able to detect when the mouse leaves the window.
> 
> The easiest should be handling WM_MOUSEMOVE - or what exactly is the 
> problem?
> 
> -- 
> Guido Stercken-Sorrenti
> MVP - Visual Developer / Visual C++ 
> 
> 
> 
0
Eitan (21)
4/28/2005 6:08:02 PM
The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.  
However I would like to get some notification the moment the mouse LEAVE the 
window.  
Thanks, Eitan

"Guido Stercken-Sorrenti [MVP VC++]" wrote:

> > I am creating a new window class based on CWnd.  I am placing it on the 
> > View
> > (CFormView).    How can I get the notification or any other indication 
> > that
> > the cursor/mouse is not on this window?
> >
> > I also tried the same to create a new window based on CStatic but I was 
> > not
> > able to detect when the mouse leaves the window.
> 
> The easiest should be handling WM_MOUSEMOVE - or what exactly is the 
> problem?
> 
> -- 
> Guido Stercken-Sorrenti
> MVP - Visual Developer / Visual C++ 
> 
> 
> 
0
Eitan (21)
4/28/2005 6:08:05 PM
The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.  
However I would like to get some notification the moment the mouse LEAVE the 
window.  
Thanks, Eitan

"Guido Stercken-Sorrenti [MVP VC++]" wrote:

> > I am creating a new window class based on CWnd.  I am placing it on the 
> > View
> > (CFormView).    How can I get the notification or any other indication 
> > that
> > the cursor/mouse is not on this window?
> >
> > I also tried the same to create a new window based on CStatic but I was 
> > not
> > able to detect when the mouse leaves the window.
> 
> The easiest should be handling WM_MOUSEMOVE - or what exactly is the 
> problem?
> 
> -- 
> Guido Stercken-Sorrenti
> MVP - Visual Developer / Visual C++ 
> 
> 
> 
0
Eitan (21)
4/28/2005 6:08:06 PM
The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.  
However I would like to get some notification the moment the mouse LEAVE the 
window.  
Thanks, Eitan

> > I am creating a new window class based on CWnd.  I am placing it on the 
> > View
> > (CFormView).    How can I get the notification or any other indication 
> > that
> > the cursor/mouse is not on this window?
> >
> > I also tried the same to create a new window based on CStatic but I was 
> > not
> > able to detect when the mouse leaves the window.
> 
> The easiest should be handling WM_MOUSEMOVE - or what exactly is the 
> problem?
> 
> -- 
> Guido Stercken-Sorrenti
> MVP - Visual Developer / Visual C++ 
> 
> 
> 
0
Eitan (21)
4/28/2005 6:08:06 PM
> The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.
> However I would like to get some notification the moment the mouse LEAVE 
> the
> window.

In that case, use SetCapture() when the mouse enters the window, and test 
(with PtInRect) whether the mouse cursor is still inside your window. Don't 
forget to call ReleaseCapture() when the window boundaries are left.

-- 
Guido Stercken-Sorrenti
MVP - Visual Developer / Visual C++ 


0
mspbn (41)
4/28/2005 6:25:56 PM
The problem is that OnMouseMove, for this CWnd child window, do not get any 
OnMouseMove messages.  The parent View window gets the messages instead....  
Any idea why?
Thanks, Eitan

"Guido Stercken-Sorrenti [MVP VC++]" wrote:

> > The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.
> > However I would like to get some notification the moment the mouse LEAVE 
> > the
> > window.
> 
> In that case, use SetCapture() when the mouse enters the window, and test 
> (with PtInRect) whether the mouse cursor is still inside your window. Don't 
> forget to call ReleaseCapture() when the window boundaries are left.
> 
> -- 
> Guido Stercken-Sorrenti
> MVP - Visual Developer / Visual C++ 
> 
> 
> 
0
Eitan (21)
4/28/2005 7:20:06 PM
If you are using a CStatic as the base class make sure the control has the
SS_NOTIFY flag.

AliR.

"Eitan" <Eitan@discussions.microsoft.com> wrote in message
news:6E4AC49D-1886-473F-87DF-9E301B518E85@microsoft.com...
> The problem is that OnMouseMove, for this CWnd child window, do not get
any
> OnMouseMove messages.  The parent View window gets the messages
instead....
> Any idea why?
> Thanks, Eitan
>
> "Guido Stercken-Sorrenti [MVP VC++]" wrote:
>
> > > The WM_MOUSEMOVE is good as long as the mouse is in the window
boundries.
> > > However I would like to get some notification the moment the mouse
LEAVE
> > > the
> > > window.
> >
> > In that case, use SetCapture() when the mouse enters the window, and
test
> > (with PtInRect) whether the mouse cursor is still inside your window.
Don't
> > forget to call ReleaseCapture() when the window boundaries are left.
> >
> > -- 
> > Guido Stercken-Sorrenti
> > MVP - Visual Developer / Visual C++
> >
> >
> >


0
AliR1 (391)
4/28/2005 8:11:52 PM
Thanks, I forgot the SS_NOTIFY, and it solved the problem.
Eitan

"AliR" wrote:

> If you are using a CStatic as the base class make sure the control has the
> SS_NOTIFY flag.
> 
> AliR.
> 
> "Eitan" <Eitan@discussions.microsoft.com> wrote in message
> news:6E4AC49D-1886-473F-87DF-9E301B518E85@microsoft.com...
> > The problem is that OnMouseMove, for this CWnd child window, do not get
> any
> > OnMouseMove messages.  The parent View window gets the messages
> instead....
> > Any idea why?
> > Thanks, Eitan
> >
> > "Guido Stercken-Sorrenti [MVP VC++]" wrote:
> >
> > > > The WM_MOUSEMOVE is good as long as the mouse is in the window
> boundries.
> > > > However I would like to get some notification the moment the mouse
> LEAVE
> > > > the
> > > > window.
> > >
> > > In that case, use SetCapture() when the mouse enters the window, and
> test
> > > (with PtInRect) whether the mouse cursor is still inside your window.
> Don't
> > > forget to call ReleaseCapture() when the window boundaries are left.
> > >
> > > -- 
> > > Guido Stercken-Sorrenti
> > > MVP - Visual Developer / Visual C++
> > >
> > >
> > >
> 
> 
> 
0
Eitan (21)
4/28/2005 10:20:01 PM
See TrackMouseEvent

"Eitan" <Eitan@discussions.microsoft.com> wrote in message 
news:A64427E5-5180-4C6D-BFA0-58A0462974B6@microsoft.com...
> The WM_MOUSEMOVE is good as long as the mouse is in the window boundries.
> However I would like to get some notification the moment the mouse LEAVE 
> the
> window.
> Thanks, Eitan
>
> "Guido Stercken-Sorrenti [MVP VC++]" wrote:
>
>> > I am creating a new window class based on CWnd.  I am placing it on the
>> > View
>> > (CFormView).    How can I get the notification or any other indication
>> > that
>> > the cursor/mouse is not on this window?
>> >
>> > I also tried the same to create a new window based on CStatic but I was
>> > not
>> > able to detect when the mouse leaves the window.
>>
>> The easiest should be handling WM_MOUSEMOVE - or what exactly is the
>> problem?
>>
>> -- 
>> Guido Stercken-Sorrenti
>> MVP - Visual Developer / Visual C++
>>
>>
>> 


0
alegr (1131)
4/29/2005 3:01:07 AM
Reply:

Similar Artilces:

Bring an app window to the front
In my app, I have the HWND of another application (that is not written by us). From my app I want to bring this other app to the front but NOT in front of any system model dialogs that may be knocking about i.e. if this other app's window is obscured by other applications I want to bring it to be made visible., Is this impossible ? My window must always be in front of this other app, thats why I made my app system modal. If I SetWindowPos( hwndOtherApp, MyWindow, ..... ) then this initially achieves my goal, but now the other app automatically becomes system modal and so can app...

Excel 2003 Viewer: No more "Browse in same window" IE functionality?
With Excel viewer '97, by going into the file associations in explorer, you could modify the '.xls' entry and choose 'browse in same window'. In IE, this would then launch the excel attachment in the same window. After installing the recently released Excel Viewer 2003, the 'browse in same window' checkbox is greyed out. Is this a feature that was dropped in the new release? If so, is there any registry hack I can use to re-enable it? I'd really like to have the old functionality in the new version...without it, I can't push out the new version. Any hel...

Receiving UDP streaming through Windows Media Player
Hi All, I am using Windows Media Player Version 11.0.5721.5268 and VLC version 1.0.3 I am trying to stream video over UDP between two media players, the transmitter is VLC and the receiver is Windows Media Player. To roll out networking problem I have installed VLC and Windows Media Player on the same IP host and I use 127.0.0.1 or the IP address assigned to the computer from my DHCP server. Please send free to send your reply as well to ramig-at-comsysmobile-dot-com I manage to do so when the receiver is VLC as well -- so there is no networking or firewall issue. My...

Window placement problem: SW_HIDE, GetWindowPlacement, SetWindowPlacement etc.
Hi, In my OnInitDialog method I have some controls decide whether it's appropriate for them to be visible. If they decide against being visible, they'll call SetWindowPlacement for hiding and do some rearranging of other controls. To do all of this in a neatly manner, a control in progress of hiding wants to know the "hidden" state of other controls in the same dialog. One would expect GetWindowPlacement to be a nice source of this information. But the GetWindowPlacement / SetWindowPlacement combo seems very unreliable to me. I've narrowed it down to this: WI...

Homepage Quick Links for Fixed Assetss Windows
Similar to other GP windows, the fixed assets windows should be allowed to be added to a user's homepage as a Quick Link. -- Haiden Turner Winged Disc Technologies, LLC Dallas, Texas ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Business...

ie 8 in windows XP crash
ie 8 loads PDF file then crashes, reloads file then crashes..... IE 8 is upto date Adobe reader 9.3 is up to date Any suggestions. "Tmeister" wrote: > ie 8 loads PDF file then crashes, reloads file then crashes..... > > IE 8 is upto date > Adobe reader 9.3 is up to date > > Any suggestions. Get rid of Adobe reader & get Foxit--faster, much smaller & less complicated. Been using it for 2 years with no problems, even when message is "must have Adobe...." TIC "Tmeister" wrote: > ie 8 loads PDF file...

adjusable columns in original dynamics windows
adjusable columns in original dynamics windows, that you can sort on and size properly. Is there a way to post a screenshot to show you what i'm on about ?? ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGr...

Outlook Task Window Flickering Rapidly
I am running Outlook 2007, but the same issue happened in Outlook 2003. When I go to the Task window and click the field labeled "Click Here to Add a New Task", the entire window begins to flicker rapidly as soon as I start typing. It still allows me to enter the task without any issue, but it is very annoying. The only way to make it stop is to select another open window and then go back to the Outlook window. Any ideas? I cannot find anything on this. Thanks. ...

Win7 backup error: Windows Backup skipped I:\ because it cannot be found on drive I:\
After expanding my O/S disk and thus deleting "Disk I" my windows 7 backup completes successfully but gives me the above error for the previously deleted Disk. More of an annoyance. I DID have a disk I on the first Backup file I did before the expansion and I have NOT tried to restore any files, etc yet. I am looking for a registry or ? change that can fix this and not necessarily a 'work-around.' My Computer, Device Manager, Win 7 Backup devices, etc do NOT show any "Disk I." available on the computer. All help is appreciated. Backup error: Window...

windows 7 search not working
Hi, I have a brand new laptop running Windows 7 Home Premium x64. Windows Search does not work - there is no drive activity and I get no results. I've seen the KB article 977380 about Win7 search not working and I have tried the hotfix, but with no luck. Search still does not work. The indexing service is running, AFAICT, and the drive properties are set to allow indexing. Anyone know the answer to this? (please don't say Google Search 8-) George On Thu, 19 Aug 2010 03:33:47 -0400, George Neuner <gneuner2@comcast.net> wrote: I was advised by email to tr...

import Windows Mail files to Outlook 2007
I just upgraded from Vista to Win 7, and since Win 7 doesn't support Mail, I need to import my old mail files to Outlook. Sounds simple enough, but I have a couple issues -- I have several user accounts on the computer, and for 2 of the accounts I had Windows Mail configured to point to the same folder locations (under the "Public" folders) so that we could share e-mail. So, the active mail account was not under either of our own user accounts; and we shared access. Now, when I try to import the files into Outlook (and I can't export from Mail, since it...

Duplicate Detection Count
Is there a way to add a count onto the duplicate detection job results grid to show how many duplicates were found in each job? ...

Mouse action not detect @ all.
Hi I created a class as follows and try to inherit from CWnd: class CGLWinTarget : public CWnd { public: CGLWinTarget(CWnd *pParent=NULL); // standard constructor ~CGLWinTarget(); void CreateNewWin(); ..... public: virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); DECLARE_MESSAGE_MAP() afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT...

renaming windows 2003 domain
Hi all, I have successfully rename my windows 2003 domain using rendom and gpfixup. There is only 1 dc in my environment. But my clients login still reflect the old domain during login. I have followed the requirement of restarting my domain clients for more than 2 times but to no avail. Pls advise. Thks in advance. Hello inenewbl, Do you mean the NetBIOS domain name after choosing ctrl+alt+del in the logon to window? Did you follow all steps as listed under "Domain Rename Processes and Interactions": http://technet.microsoft.com/en-us/library/cc738208(WS.10).as...

Prove these security patch for MS Windows
--mvddfydp Content-Type: multipart/related; boundary="obmcttblilzyttwnw"; type="multipart/alternative" --obmcttblilzyttwnw Content-Type: multipart/alternative; boundary="frrpwnqkbjtaepg" --frrpwnqkbjtaepg Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS User this is the latest version of security update, the "September 2003, Cumulative Patch" update which eliminates all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express. Install now to maintain the security of your computer from th...

Transparent CStatic
I have derived a CStatic control in order to add transparency and font control. In a first step I have override OnPaint Method to make the control transparent : void CStaticTest::OnPaint() { CPaintDC dc(this); // device context for painting // Where to draw text CRect client_rect; GetClientRect(client_rect); // Get the caption CString szText; GetWindowText(szText); // Get the font CFont *pFont, *pOldFont; pFont = GetFont(); pOldFont = dc.SelectObject(pFont); // Map "Static Styles" to "Text Styles" #define MAP_STYLE(src, dest) if(dwStyle & (src)) dwText...

Windows 2003 server Standard Edition 180 day Trial software link
Hi Guys. Can anyone provide me with a link to be able to download a 180 day trial version of windows 2003 server (not R2) standard edition. I want to build a test lab for testing out domain migration to windows 2008 server and exchange 2010. Am planning on doing this soon on our 2003 domain. Ive tried searching the microsoft site for it without much success. thanks Hello Jason, Since Server 2008 is released the trial versions are not longer available. Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties, and confers ...

outlook v6 with windows XP
Hi, I have a problem with starting/running outlook; it takes very long to start and to display its contents - cpu utilization is up to 100%. It seems that this problem occured after runnig regclean but it still remains when I restored the registry keys from backup. The keys that were deleted did not seem to be related to outlook. Removing and adding outlook from 'Add/remove programs' did not solve anything either. Is there a way to completely reinstall outlook? Thanks a lot in advance, K. Karl <nospam@for.me> wrote: > I have a problem with starting/running outlook; it ...

Can not leave the Edit box empty when associate it with a float variable
I am using an Edit control in Dialog to input float data, I associated a float variable with the Edit control. When I try to change the input, I use backspace to delete all the digits, but the program was terminated with an error at this time. I have to be carefull for not deleting all the digits in Edit box(one digit have to be there). But you can not always avoid that. Does anybody know how to avoid this problem? Thanks in advance! >I am using an Edit control in Dialog to input float data, I associated a >float variable with the Edit control. When I try to change the input, I...

OWA: Combining form-based & basic HTTP auth
Hello, Is it possible to enable both form-based and HTTP authentication at the same time for an OWA server in Exchange 2003? I've been trying to do this for the last day or so and have not been having much luck. I would like to have both because each method has its advantages. Form-based auth allows session timeouts and compression (why is compression tied to the form method by the way?). HTTP auth prevents unauthenticated users from knowing that you have an OWA server there as they hit the HTTP auth before they can learn anything except you are running IIS. I can use either in...

What are the entry points for Console applications and Windows based application.
Hi, Recently in one of the discussions, a question was asked to tell the entry points for Console application and Windows based application if application is developed with MFC support. And what difference it makes if UNICODE is defined ? Regards, Jigar Mehta WinMain or wWinMain for windows applications main or wmain for console applications I think MFC also has some defines for the unicode versions _tmain and _tWinMain. But they simply point to wmain and wWinMain AliR. "Jigar Mehta" <jigar.programmer@gmail.com> wrote in message news:1149092528.804246.299380@y43g2000cw...

How Custom draw a List control handles the mouse over (NM_HOVER) message ?
Hi All, How a Custom draw List control handles the mouse over (NM_HOVER) message ? I have written the custom draw control (View = Report ). I am able to draw the control but I am not able to get the Mouse over message (NM_HOVER) Please can you tell me How should a custom control handles a Mouse over message ? Thanks Anup On Jul 5, 4:51 am, Matrixinline <anup.kata...@gmail.com> wrote: > Hi All, > > How a Custom draw List control handles the mouse over (NM_HOVER) > message ? > > I have written the custom draw control (View = Report ). I am able to > draw the c...

Computer freezes while using mouse to select group of data in Exce
Regularly, when mousing to select a group of data in a column , using Excel, the computer completely freezes up, and I have to hard reset to recover. This happened with 98 and XP office versions on my computer. Thanks for your time, Mike Shook I have no idea... But David McRitchie has a bunch of notes that deal with the misbehavior of mice and excel. http://www.mvps.org/dmcritchie/excel/ghosting.txt What kind of mouse do you use? USB/PS2 Logitech/MS Intellipoint/etc Make sure you have the current drivers and post back with more details it that doesn't help. (Maybe someone wil...

Microsoft Word has stopped working, Windows 7
I had a issue on word 2007 on Windows 7, when open either document .docx the application warning message : "Microsoft Word has stopped working". I cleaned the register, reinstall office and NOT fix Please, anyone have a solution. See http://word.mvps.org/FAQs/AppErrors/ProblemsStartingWord.htm and http://support.microsoft.com/kb/921541. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Diego wrote: > I had a issue on word 2007 on Windows 7,...

Setting up Windows Mail using my Yahoo ID but receiving error mess
I have tried to set up my email account on Windows Mail but when I tried to send a test email the error below keeps popping up. Could somebody tell me how to fix it? Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Subject 'Hi Mojo ', Account: 'pop.mail.yahoo.com.au', Server: 'smtp.mail.yahoo.com.au', Protocol: SMTP, Port: 465, Secure(SSL): No, Socket Error: 10053, Error Number: 0x800CCC0F Thankyou "richnic" <richnic@discussions.m...