March 29, 2024, 03:47:51 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Context menu on a treeview control

Started by Andy, September 13, 2017, 12:23:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

September 13, 2017, 12:23:30 AM Last Edit: September 13, 2017, 12:37:07 AM by Andy
I have my main screen with a treeview control, and I've sub classed the control so I can get a context menu on a right click.

$define SUBCLASS2_ID 54322 ' any number

sub KeyContextMenu(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam,UINT_PTR uIdSubclass,DWORD_PTR dwRefData)
Select uMsg
case WM_RBUTTONDOWN
POINT cursor
GetCursorPos(cursor)
ScreenToClient(win.hwnd, cursor)
CONTEXTMENU win,cursor.x, cursor.y
MENUITEM "Add key",0,106
MENUITEM "Copy key",0,107
MENUITEM "Rename key",0,108
MENUITEM "Delete key",0,109
ENDMENU
Case WM_DESTROY
RemoveWindowSubclass(hWnd,&KeyContextMenu,SUBCLASS2_ID)
EndSelect
Return DefSubclassProc(hWnd,uMsg,wParam,lParam)
EndSub


Now when I select an option such as "Add", my program opens the AddKey screen - but as soon as I click on the Add screen I loose focus (of the Add screen and it becomes unresponsive).

The only way I can get my program to respond is to click on the main screen again.

The same happens if I choose any of the above options, and I know it's not the Add, Copy, Rename or delete functions as there are also buttons a user can press and these are working correctly.

Any ideas please?
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

If nobody gives you a solution, email me your code so I can compile it and I'll look at it. I can't work out in my shop until the 27th at the earliest.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Larry that's a nice offer considering what you've just gone through - I will bare that in mind - thanks.

In the mean time I've changed the line:

case WM_RBUTTONDOWN

to

case WM_RBUTTONUP

This stops my secondary screens from freezing BUT - you have to effectively do a double click on the right mouse button - so not there yet.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

The problem was a missing RETURN command!
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library