|
-
July 21st, 2011, 07:55 PM
#1
OnClick for list control doesn't work first time
When I click within a list control, suppose there is an event OnClick fired. In my program, I catch OnClick event by processing the message NM_Click, i.e. ,
Code:
ON_NOTIFY_REFLECT_EX(NM_CLICK, OnClick)
However, whenever I click within the list control first time, this event won't be fired. This event is always fired when I click within the list control second time! Any guru here can explain why? Thanks for your inputs.
-
July 21st, 2011, 10:29 PM
#2
Re: OnClick for list control doesn't work first time
Does it work if you set focus to the list control first?
In other words, tab to set focus on the list control, and then click on a list item. Does it work then?
At any rate, what are you trying to do? Are you trying to determine a change in selected list items?
-
July 24th, 2011, 11:26 AM
#3
Re: OnClick for list control doesn't work first time
First of all correction:
You are not catching any event. You are handling WM_NOTIFY message that in this case notifies about mouse click on the control, by setting a notification code to NM_CLICK. No events of any kind are being used here.
You have to realize that Windows OS is not event driven, it is message driven system.
Unfortunately, somebody from MS, decided to use this word in the menu for inserting message handlers and this is unfortunate, since it confuses programmers who just recently started programming for Windows.
C# and other .NET languages, internally use so called events but they are language specific implementation and have nothing to do Windows event, used for example for thread synchronization.
C# events are generated (fired) by the framework from Windows message handler anyway.
Now, to add to Arjay’s response:
You can have scenario, when mouse capture is taken by another control, and first click is used to release capture therefore list control (or any other control) would react only to the second click.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|