Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

CListCtrl with CMenu C++ example anyone?

  • 06-11-2008 10:12pm
    #1
    Closed Accounts Posts: 5


    I'm writing a small app for myself which has a control list, i'd like to add a context menu when i right-click on a row in the list, then allow editing that row.

    has anyone here got source code in C/C++ that shows how to do this?

    i've already searched online and did find lots of discussion/code snippets, but nothing complete which can be compiled and seen in action.

    ideally, i'd like to processrun code when the app receives the WM_CONTEXTMENU message

    TIA


Comments

  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    redkr0w wrote: »
    I'm writing a small app for myself which has a control list, i'd like to add a context menu when i right-click on a row in the list, then allow editing that row.

    has anyone here got source code in C/C++ that shows how to do this?

    i've already searched online and did find lots of discussion/code snippets, but nothing complete which can be compiled and seen in action.

    ideally, i'd like to processrun code when the app receives the WM_CONTEXTMENU message

    TIA

    Yea done it a few weeks ago... the right click menu gets generated dynamically... you need to select the CListControl and "add an event handler" for the right click.

    Check that your even handler is firing every time you right click. In the event handler you can then dynamically generate your menu...

    You should be able to find some code to generate the menu dynamically, and trap the output from it... if your stuck let me know and i'll try dig out what i used...


  • Closed Accounts Posts: 5 redkr0w


    Thanks DD

    But what if the user is left handed? i haven't checked whether left-click would work, but WM_CONTEXTMENU should work for both, i guess?

    i'll have another go at it..were you using MFC code?


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    redkr0w wrote: »
    Thanks DD

    But what if the user is left handed? i haven't checked whether left-click would work, but WM_CONTEXTMENU should work for both, i guess?

    i'll have another go at it..were you using MFC code?

    If they are left handed they can flip the buttons on the mouse in control panel...

    yes i wrote it in MFC...

    Check out the second post here, this is what i did:-
    http://www.codeguru.com/forum/archive/index.php/t-122595.html


  • Registered Users, Registered Users 2 Posts: 981 ✭✭✭fasty


    If we're talking about MFC, it's much better to add the menu to your app as a resource, override OnContextMenu and have it load the menu from the resource.

    Give each menu item a command id then add ON_COMMAND handlers to the mesage map for those actions.


Advertisement