CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2019
    Posts
    11

    UINT_PTR numbers among a program's identifiers..

    Hello,

    I have a simple question regarding the UINT_PTR passed as parameter to a InsertMenu function as in

    Code:
    HMENU hM1;
    hM1 = GetMenu(hWnd);
    
    HMENU hM2;
    
    hM2 = CreateMenu();
    InsertMenu(hM1, 0, MF_POPUP | MF_BYPOSITION, UINT_PTR(hM2), TEXT("Item 1"));
    
    hM2 = CreateMenu();
    InsertMenu(hM1, 1, MF_POPUP | MF_BYPOSITION, UINT_PTR(hM2), TEXT("Item 2"));
    The question is if there is any guarantee that the UINT_PTR(hM2) will be unique among the menu's all identifiers, and also among programs's all identifiers..Suppose that the program also has a button identifier

    #define ID_BUTTON1 15

    Is there any guarantee that some UINT_PTR(hM2) will not be 15 ?


    Best,
    D Narcis
    Last edited by 2kaud; December 4th, 2019 at 09:27 AM. Reason: Added code tags

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: UINT_PTR numbers among a program's identifiers..

    A menu handle (e.g. hM1) is different from a menu ID constant, but there is no guarantee that the values could be the same.

  3. #3
    Join Date
    Sep 2019
    Posts
    11

    Re: UINT_PTR numbers among a program's identifiers..

    Ok, so it should be avoided even for popup menu items, because it might interfere with other identifiers when processing the WM_COMMAND message..

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: UINT_PTR numbers among a program's identifiers..

    Quote Originally Posted by dnarcistrinca View Post
    Ok, so it should be avoided even for popup menu items, because it might interfere with other identifiers when processing the WM_COMMAND message..
    There is a range of user IDs that you should use. I'm on a phone now so I can't look this up for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured