GNGNUT Posted August 10, 2015 Posted August 10, 2015 Hi, guys I'm in need of a little advice , help with my coding, I currently have 10 tab Gui pages 1-9 all have the same screen layout, on these screens i have a button that needs to access a function to do some workings out, but I don't want to have to copy this out 9 times all with different variable names is there a way to use a function that can be accessed by multiple screens ?working outs is done within the script but the output from this goes to tab one if button on tab one is used and so on for the 9 screens, sorry if this has been answered before or if im not looking at the correct sections of the help file, if your able to help or even point me to the correct section that tells me how to share a function accorss that would be great
Moderators Melba23 Posted August 10, 2015 Moderators Posted August 10, 2015 GNGNUT,If you are using MessageLoop mode then you can easily set several button ControlIDs to fire the same function - something like this:While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cBut_Tab0, $cBut_Tab1, $cBut_Tab2, $cBut_Tab3, $cBut_Tab4, $cBut_Tab5 _Common _Function() EndSwitch WEndIf you are using OnEvent mode, then just link all the buttons to the same function:$cBut_Tab0 = GUICtrlCreateButton(....) GUICtrlSetOnEvent($cBut_Tab0, "_Common_Function") $cBut_Tab1 = GUICtrlCreateButton(....) GUICtrlSetOnEvent($cBut_Tab1, "_Common_Function")All clear?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
GNGNUT Posted August 10, 2015 Author Posted August 10, 2015 (edited) Using the (message loop)and It makes sense,But one Stupid question,if I press button one and goto said function to get my result -how can I store / set this on the Tab window from which I entered the function,mybe I'm trying to over complicate my thinking, or I'm just old and stupid .. Edited August 10, 2015 by GNGNUT
Moderators Melba23 Posted August 10, 2015 Moderators Posted August 10, 2015 GNGNUT,When you press a key and enter the function, use GUICtrlRead on the Tab control - that will return the tab index and allow you to determine which one is active.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
GNGNUT Posted August 12, 2015 Author Posted August 12, 2015 Thank you for your help Melba23makes lots of sense, I think I was over thinking about it
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