[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

NM_RCLICK Windows message - HELP.....

Posted on 1999-01-07
6
Medium Priority
?
401 Views
Last Modified: 2013-12-03
Hi,

I have a tree control and I need to let the client know when the user right clicks the mouse. I have handled the Windows Message NM_RCLICK. However I have a slight problem... When the user right clicks, the node does not stay selected... it reselects the node that was selected previously. What is causing this... How do I get it to actually select a node when the right mouse button is clicked...

please help me...

TIA

Emma
0
Comment
Question by:middlel
[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
  • 3
  • 2
6 Comments
 

Expert Comment

by:T38Jet
ID: 1418285
have you tried the myControl.SetFocus inside the MouseDown event?
0
 

Author Comment

by:middlel
ID: 1418286
Is that a VB method??? The C++ ones are asking you to pass in a handle to the window that will receive the focus... I just want a tree node to get selected.  What do you think?

regards

Emma

0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 240 total points
ID: 1418287
I've had this problem and it seems to be part of the standard tree control behaviour

I can't give you a very good explanation of why....there seems to be some wierd logic in the tree control...that there is more than one why of selecting an item....the whole behaviour depends on what happens before...

IIRC this is what happens :

If you right-click on an item that's not already selected, the selection appears to jump to a new item...however afterwards it jumps back.  The fact is the new item was never truly selected, I think if you use GetNextItem (MFC) or TVM_GETNEXTITEM (SDK) to find the selection, you will find the control thinks the old item is still selected.

So assuming you want the selection to stay on the new item, you need to explicitly set it...here's how

In response to NM_RCLICK
(a) Use GetMessagePos to get the cursor position when this message occured
(b) Use HitTest (MFC) or TVM_HITTESTINFO (SDK) to test which item in the tree this position corresponds to.
(c) Assuming you want the selection to stay on the new item after the option is completed, explicitly set the new selection to the item found by (b) [to my feeble mind this makes more sense than having the selection jump back to some other item].
(d) The item to perform whatever right click on is the item you got from (b)




0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:middlel
ID: 1418288
Thanks for the response... It was very useful... Can you take a look at the method... OnRClick();

It compiles, but nothing is found when it does a TreeView_HitTest();
Have I done something wrong when get the coordinates or is it a different problem completely...? If it is then I'll close the question and give the points to you...

Thanks

Emma

0
 

Author Comment

by:middlel
ID: 1418289
Adjusted points to 80
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1418290
Sorry I missed your follow up till now (too late ?)

GetMessagePos is in screen coordinates

HitTest is I think in window coordinates

Stick in the debugger or write to a log file.  If the coordinate systems are different use ScreenToClient to convert the mesage position to a client coords for the tree control
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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