xeroTechnologiesLLC Posted February 4, 2012 Posted February 4, 2012 (edited) Greetings programmers, Back with another, probably dumb, question. I created a menu bar that lets users dynamically add and remove items - fun times (with more help than listable from one particular BA$$ on this forum - thank you again); and now that they can remove the items I need the bar to resize to fit shorter or longer against what items are left. IE: starts off with a dozen menu items user removes 5 restarts the program i need the bar to read the width of the left over menu items and make the gui that + about 5 to 10 pixels for safety. Thoughts? Ideas? I tried the getcntrlpos but it doesn't work for menu items. Any thoughts, ideas / directions? Thanks in advance. Edited April 7, 2012 by xeroTechnologiesLLC
Moderators Melba23 Posted February 4, 2012 Moderators Posted February 4, 2012 xeroTechnologiesLLC,I will take that as a compliment! The menu titles in a GUI are always in the same font, so I would suggest using my StringSize UDF to get the size of each top level menu title. They should all be in a single section of the ini, so a simple loop should be enough. Sum those values and add enough for the inter-title margins and you should get a sensible answer on which to base your new GUI size. Give it a go and see how you get on - you know where I am if you run into difficulties. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ProgAndy Posted February 4, 2012 Posted February 4, 2012 You should be able do something with _GUICtrlMenu_GetMenu and _GUICtrlMenu_GetItemRect *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
xeroTechnologiesLLC Posted February 4, 2012 Author Posted February 4, 2012 @Melba, The problem in this case is that the menu items that can be hidden are static, built into the form - not from the ini this time. @ProgAndy, Thanks, I am reading the intel on them now and will give it a whirl and reply back with results. I appreciate both of you taking the time to reply.
xeroTechnologiesLLC Posted February 4, 2012 Author Posted February 4, 2012 Great lead in information above came up with the working code below. Consider this one resolved. On to how to make the program 'refresh' the width automatically without requiring the program to restart every time.... #region --- resize toolbox --- ; resize the toolbox to the width of the left over buttons $hWnd = WinGetHandle("ToolBox") $hMain = _GUICtrlMenu_GetMenu($hWnd) ; counter variable $c = 0 $btnWidth1 = 0 do $c += 1 $mInfo = _GUICtrlMenu_GetMenuBarInfo($FRMtoolbox, $c, 1) $btnWidth1 += $minfo[2] - $minfo[0] until $minfo[2] = 0 ; added a few extra pixels for screen width safety $screenW = $btnWidth1 + 15 ; now resize the box based on the ini values plus the new width value winmove("ToolBox", "", $screenX, $screenY, $screenW) #endregion --- end resize toolbox --- As always, thanks very much!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now