Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. having a long menu not taking all the screen height

having a long menu not taking all the screen height

Scheduled Pinned Locked Moved C#
cssannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    joebarthib
    wrote on last edited by
    #1

    Hi, I display a lot of images in a context menu, using OwnerDraw=true and overring OnMeasureItem/OnDrawItem. The automatically displayed arrows are great, but the menu takes all the screen height! My boss want the menu to be shorter... I tried to display only a few images, and added my own arrow items at the beginning and the end of them, but I can't make the menu scroll when I click/select the arrows! - when clicking the arrows, the menu automatically closes - when selecting them, I dynamically modify the images items, but I can't make the menu update! I tried everything: Refresh/Update/Invalidate of the parent control, PerformSelect on all the images items, calling SendMessage with WM_PAINT, WM_PRINT, WM_PRINT_CLIENT with the menu handle, and the parent control handle, I've even tried to set to false then back to true all the images items OwnerDraw, they update more or less, but the false ownerdraw menu (brief) displaying is awful! I didn't manage to find an answer to my problems on the web, so if someone have a clue it would be great to tell me! Either about how making my long menu not taking all the screen height, or forcing the menu to update when I dynamically modify it! Thanks a lot Thibaud

    D 1 Reply Last reply
    0
    • J joebarthib

      Hi, I display a lot of images in a context menu, using OwnerDraw=true and overring OnMeasureItem/OnDrawItem. The automatically displayed arrows are great, but the menu takes all the screen height! My boss want the menu to be shorter... I tried to display only a few images, and added my own arrow items at the beginning and the end of them, but I can't make the menu scroll when I click/select the arrows! - when clicking the arrows, the menu automatically closes - when selecting them, I dynamically modify the images items, but I can't make the menu update! I tried everything: Refresh/Update/Invalidate of the parent control, PerformSelect on all the images items, calling SendMessage with WM_PAINT, WM_PRINT, WM_PRINT_CLIENT with the menu handle, and the parent control handle, I've even tried to set to false then back to true all the images items OwnerDraw, they update more or less, but the false ownerdraw menu (brief) displaying is awful! I didn't manage to find an answer to my problems on the web, so if someone have a clue it would be great to tell me! Either about how making my long menu not taking all the screen height, or forcing the menu to update when I dynamically modify it! Thanks a lot Thibaud

      D Offline
      D Offline
      dnewmon
      wrote on last edited by
      #2

      Allow the menu to close as normal when the arrows are selected, update the items, and make it appear in the same location again. If you added the context menu to the control using the "ContextMenu" Property create a delegate for the MouseDown event and note the location of the mouse when the right mouse button is clicked. Update the menu items, then call: myCtrl.ContextMenu.Show(myCtrl, savedX, savedY); David

      J 1 Reply Last reply
      0
      • D dnewmon

        Allow the menu to close as normal when the arrows are selected, update the items, and make it appear in the same location again. If you added the context menu to the control using the "ContextMenu" Property create a delegate for the MouseDown event and note the location of the mouse when the right mouse button is clicked. Update the menu items, then call: myCtrl.ContextMenu.Show(myCtrl, savedX, savedY); David

        J Offline
        J Offline
        joebarthib
        wrote on last edited by
        #3

        Hi, thanks for your answer. That's a goog idea yes, I will try it. But I'm afraid the menu closing then re-opening will be unaesthetic. Otherwise, I have found another solution on a French forum: http://www.csharpfr.com/code.aspx?ID=34929 This solution consists in using the SetMenuInfo API to set the maximum menu height. But you also need to create a new contextmenu class, as SetMenuInfo needs a handle, and the only valid handle can be obtained by calling CreateMenuhandle, which is a ContextMenu protected method!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups