having a long menu not taking all the screen height
-
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
-
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
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
-
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
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!