Jump to content

[Resolved] Possible to add guictrlmenu from form 2 to form 1?


Recommended Posts

Is it possible to use form 2 to call a function to create menu items onto form 1?

I apologize for probably a simple question, but I'm not finding clear syntax on how to accomplish it.

In .net i guess it would just be ... like create frm1.menu.value = whatever, etc.

I'm not sure how to implement that into autoIT syntax - if I even can.

Thanks in advance.

Edited by xeroTechnologiesLLC
Link to comment
Share on other sites

  • Moderators

xeroTechnologiesLLC,

I thought we already did that in one of your other threads? :)

As long as you use GUISwitch to set the correct GUI in which to create the controls you can use the standard AutoIt GUICtrlCreate* functions from anywhere in your script. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

LOL silly Melba...you know I can't read and have the memory of a brick...

:)

So I tried the following to basically clear the ini section of the list of items we hid, destroy the menu bar (since other items were destroyed it's easier to clear it all then rebuild it) and then run a function to rebuild the menu items.

Unfortunately it doesn't destroy all the items, it leaves a few behind. What am I missing? ;)

Case $ShowAll
     ; clear the information in the .ini file
     IniWriteSection("config.ini", "MenuHideShow", "")

     ; recreate the menu bar in the $FRMtoolbox window
     GUISwitch($FRMtoolbox)
     GUISetState()
     _GUICtrlMenu_DestroyMenu($FRMtoolbox)
     backupMenu()
     _GUICtrlMenu_DrawMenuBar($FRMtoolbox)

     ; resize the menu bar to fit for the recreated items
     #region --- resize toolbox ---
     ; resize the toolbox to the width of the left over buttons
     $hWnd = WinGetHandle("ToolBox")
     $hMain = _GUICtrlMenu_GetMenu($hWnd)
     $c = 0
     $btnWidth1 = 0
     Do
      $c += 1
      $mInfo = _GUICtrlMenu_GetMenuBarInfo($FRMtoolbox, $c, 1)
      $btnWidth1 += $mInfo[2] - $mInfo[0]
     Until $mInfo[2] = 0
     $screenW = $btnWidth1 + 15
     WinMove("ToolBox", "", $screenX, $screenY, $screenW)
     #endregion --- resize toolbox ---

Thanks in advance...and again - sorry for all the dumb questions. >< ;)

Link to comment
Share on other sites

  • Moderators

xeroTechnologiesLLC,

No idea from just that snippet. ;)

Are all the menu items created by the same _GUICtrlMenu_CreateMenu call? If not then _GUICtrlMenu_DestroyMenu will not delete them. :)

Perhaps if you post the whole script.... ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

xeroTechnologiesLLC,

Ah, the crystal ball is working well tonight! :)

Yes, you will need to loop through the returned ControlIDs as I did in the very early scripts I posted in your other thread. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I'll definitely need to make note of the difference for the future.

I can see how the _guictrlmenu_createMenu option in conjunction with the .ini file would have made this add/remove process infinitely smoother than the methodology I have it now.

The lessons will be shared with the rest of the team as well since we are all picking up autoIT and learning it about the same time.

I have one more hurdle of a persistent menu item that retains even after i use the guictrldelete for it's menu ID, but I think I can get around that.

For this topic - [RESOLVED] !

LOL

Melba - I owe you drinkage or something.

Thank you again!

;) ;) :)

edit - spelling fail corrected

Edited by xeroTechnologiesLLC
Link to comment
Share on other sites

  • Moderators

xeroTechnologiesLLC,

I owe you drinkage or something

Thank you for the thought. Perhaps a donation to the site to help Jon with the server costs instead? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

consider it done when i get home.

(keyloggers at work ftl)

I have some more coding to do on this last item of the project then it's complete.

I'll be cleaning up the code, removing some work proprietary stuff and then probably (if it's ok to the forum rules) just give the code away when it's complete and stable.

Mainly in a thank you for the help - here's what I completed.

Second as a - don't do this...it was inefficient, but worked like sludge on slope. LOL

Link to comment
Share on other sites

  • Moderators

xeroTechnologiesLLC,

You are very kind - thank you. :)

Feel free to post your final code here - either as a working example or as a "warning to others" showing both approaches. After all, that is why the forum exists - to let others learn. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

And with all your knowledge and help, my first major AutoIT project is complete and now our team has a floating menu that:

relaunches in the same location it closes (also allowing for floating freely)

gives the user the ability to permanently hide/show menu items

hide individual menus

gives the user the choice to show the program in just the system tray or on the start bar

create their own menu and sub menus with items

....and other stuff i can't even think of.... LOL

I am a happy noob-grammer! hahah

Thank you very much Melba. Infinite appreciation in your assistance and instructions.

:);) ;)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...