Jump to content

Using a functions from multiple tab screen


GNGNUT
 Share

Recommended Posts

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 

 

 

 

 

 

 

 

Link to comment
Share on other sites

  • Moderators

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

WEnd

If 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

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

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 by GNGNUT
Link to comment
Share on other sites

  • Moderators

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

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

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

×
×
  • Create New...