+ Reply to Thread
Results 1 to 5 of 5

Trying to understand PopUp Menus!

  1. #1
    Registered User
    Join Date
    04-02-2012
    Location
    Guatemala, Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    31

    Trying to understand PopUp Menus!

    Hi All!

    I'm an amateur programmer and just recently came across a piece of code to build popup menus with the right-click of the mouse. It works!, I think I can adapt it and use it to enhance my own code however, since I don't fully understand how it works, I'd feel like the Apes in Planet of the apes when they pulled a car with horses not knowing any better . What I understand is this:

    1) A bunch of functions (I think, pre-built for usage on almost any programming language) are used to build the menu, destroy it when no longer needed, etc.
    2) There are other ways to build the PopUp menus, I think, but I'm not sure if they would be quiet as effective or at least as easy and flexible to use.
    3) What really confuses me the most is the usage of things like: * <-----------------------

    Please Login or Register  to view this content.
    MF_SEPARATOR = &H800& <---------- What is this? some sort of hexadecimal notation? what is it used for? is there any advantage for using this?

    for any help or guidance Thanks a lot !



















    Const MF_SEPARATOR = &H800&, then later a parameter in other words, why the need of constants instead of just
    Last edited by Leith Ross; 09-07-2012 at 08:42 PM. Reason: Set Type Size To Normal

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Trying to understand PopUp Menus!

    Quote Originally Posted by Guido Meng View Post
    Const MF_SEPARATOR = &H800&, then later a parameter in other words, why the need of constants instead of just
    Instead of just what?

    The &H prefix denotes a hexadecimal number. The & suffix is a type declaration character - http://support.microsoft.com/kb/191713 - and & denotes a Long constant, overriding the default Integer type for constants.

    Hexadecimal notation makes it easier to see which bits of a flag or bitmask are set. For the AppendMenu function used in your code - http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx - the uFlags parameter is a 32-bit (4 byte) number and the values represent different bits, in sequence &H1, &H2, &H4, &H8, &H10, &H20, &H40, &H80, &H100, &H200, &H400, &H800, etc.

    Constants make the code easier to read and understand. You can use the raw numbers (hex or decimal) instead of the constant names if you like, but then you might be wondering what &H800 (or 2048 decimal) means.
    Post responsibly. Search for excelforum.com

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Trying to understand PopUp Menus!

    Hello Guido Meng,

    Here are some examples as to way naming a constant helps you understand the what is happening in the function. This is especially true with low level code like the API. Each of the constants has the same value but each has a different purpose depending on the function it is used in.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    04-02-2012
    Location
    Guatemala, Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Trying to understand PopUp Menus!

    Thanks a lot for your comments Chippy!

    I now realize that there're a LOT of things for me to learn yet when it comes to programming. I think I'll start with the links you sent me.

  5. #5
    Registered User
    Join Date
    04-02-2012
    Location
    Guatemala, Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Trying to understand PopUp Menus!

    Hi Leith Ross,

    Thanks for the info.! I think I'll need to buy me some books on the whole programming subject hehehehe. I like it but back Highschool I just learned programming at a procedural level so, I guess I've a lot of updating to do.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1