// JP opened flex table

Click to See Complete Forum and Search --> : right click select - popup for treeview


sublime99
March 4th, 2008, 12:39 PM
I have a right click popup menu for a treeview. I would like to enable a right click select and popup simultaneously (like in explorer). At the moment the user must select the item in the treeview with the left mouse and then right rlick. i have having difficulty determining the right combinations. Also i have not been able to capture WM_RBUTTONDOWN

thanks


here is the callback code:

//=============================================================================
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){

switch (uMsg) {
case WM_COMMAND:
return OnCommand(hwnd, uMsg, wParam, lParam);

case WM_CREATE:
{
return OnCreate(hwnd,reinterpret_cast<CREATESTRUCT*>(lParam));
}
case WM_DESTROY:
{
OnDestroy(hwnd);
return 0;
}
case WM_SIZE:
{
OnSize(hwnd,LOWORD(lParam),HIWORD(lParam),static_cast<UINT>(wParam));
return 0;
}



case WM_NOTIFY:
{
case IDC_TREE1:
{

if(((LPNMHDR)lParam)->code == NM_RCLICK) {
return 0;
}

// some tests
// selection has changed : set global variable to keep track
//...
} // if
return 0;
} // IDC_TREE1
return 0;
} // WM_NOTIFY

case WM_CONTEXTMENU:
{
OnContextMenu(hwnd);
return 0;
}

case WM_DROPFILES:
{
//...
return 0;
}

default:
//let system deal with msg
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
}

heteroy
March 12th, 2008, 05:15 PM
You might be able to use the TVM_HITTEST (http://msdn2.microsoft.com/en-us/library/bb773732(VS.85).aspx) in your NM_RCLICK handler to get the item the mouse is over and then set its selected state manually.

Igor Vartanov
March 12th, 2008, 06:14 PM
Also i have not been able to capture WM_RBUTTONDOWN
case WM_NOTIFY:
{
case IDC_TREE1:
{

if(((LPNMHDR)lParam)->code == NM_RCLICK) {
return 0;
}
Sure you have not. You've made it totally impossible. :D

heteroy
March 13th, 2008, 09:32 AM
According to MSDN (http://msdn2.microsoft.com/en-us/library/ms911841.aspx), the return code for NM_RCLICK is irrelevant.

I'm guessing that sublime99 is referring to the WM_RBUTTONDOWN in the treeview itself. In that case, you would have to subclass the treeview to be able to handle the message.

Hopefully my previous post would make it unnecessary to do the subclassing.

Igor Vartanov
March 13th, 2008, 02:01 PM
According to MSDN, the return code for NM_RCLICK is irrelevant.Well, did I say something about return code? The intention was to point out that NM_RCLICK handler does absolutely nothing.

//JP added flex table