FrancescoDiMuro Posted June 22, 2018 Posted June 22, 2018 (edited) Good evening everyone First, I want to apologize with you for the title not very clear, but I thought a little bit on which title to set at the thread, and this is the one that came in mind. Now, let me explain what I'm trying to understand. I am making an application ( with n clients ), with an SQLite Database, which has a Main form, and n sub-forms... Since these sub-forms are called several times, because they are used to add or update records to the Database, I put the code that generates the GUI of these sub-forms in Functions. There are two sub-forms which are "treated" as two main forms, since even them have n sub-forms, which perform various tasks. Where am I stucked? For the Main form I created a Status Bar, in order to display messages ( add/delete/update/search results ), and it works perfectly with all the forms which don't have other sub-forms. For the two forms, which indeed have n sub-forms, I created two separated Status Bars, which are (re)created everytime I call the function that then displays the form. Practically, I can't set icons to these two Status Bars, and I don't know why. I'm really sorry that I don't feel clear enough, so, here you are an example of what I am saying. I recreated exactly what my script does: expandcollapse popup#include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $frmSubForm, _ $txtSubFormField, _ $sbSubFormStatusBar, _ $objSB_IconError = _WinAPI_LoadShell32Icon(109), _ $objSB_IconInformation = _WinAPI_LoadShell32Icon(277) #Region ### START Koda GUI section ### Form= $frmMainForm = GUICreate("Main Form", 300, 300, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") $sbMainStatusBar = _GUICtrlStatusBar_Create($frmMainForm) $btnCreateSubForm = GUICtrlCreateButton("Create Sub Form", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "GenerateSubForm") GUICtrlSetFont(-1, 10, 400, 0, "Arial") _GUICtrlStatusBar_SetSimple($sbMainStatusBar) _GUICtrlStatusBar_SetText($sbMainStatusBar, "") GUISetState(@SW_SHOW, $frmMainForm) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func ExitApplication() Exit EndFunc Func GenerateSubForm() #Region ### START Koda GUI section ### Form= $frmSubForm = GUICreate("Sub-Form", 300, 300, -1, -1, -1, -1, $frmMainForm) GUISetOnEvent($GUI_EVENT_CLOSE, "DeleteSubForm") $txtSubFormField = GUICtrlCreateInput("", 0, 0, 100, 20) $btnCheckSubFormField = GUICtrlCreateButton("Check Field", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "CheckSubFormField") GUICtrlSetFont(-1, 10, 400, 0, "Arial") $sbSubFormStatusBar = _GUICtrlStatusBar_Create($frmSubForm) _GUICtrlStatusBar_SetSimple($sbSubFormStatusBar) _GUICtrlStatusBar_SetText($sbSubFormStatusBar, "") GUISetState(@SW_SHOW, $frmSubForm) GUISetState(@SW_DISABLE, $frmMainForm) #EndRegion ### END Koda GUI section ### EndFunc Func DeleteSubForm() ; Declared Globally => $frmSubForm GUIDelete($frmSubForm) GUISetState(@SW_ENABLE, $frmMainForm) EndFunc Func WriteToStatusBar($sbStatusBar, $objSB_Icon, $strText) _GUICtrlStatusBar_SetIcon($sbStatusBar, 0, $objSB_Icon) _GUICtrlStatusBar_SetText($sbStatusBar, $strText) ConsoleWrite("Icon Handle: " & $objSB_Icon & @CRLF) EndFunc Func CheckSubFormField() ; Declared Globally => $txtSubFormField If GUICtrlRead($txtSubFormField) = "" Then ; Declared Globally => $sbStatusBar WriteToStatusBar($sbSubFormStatusBar, $objSB_IconError, "Field NOK.") Else WriteToStatusBar($sbSubFormStatusBar, $objSB_IconInformation, "Field OK.") EndIf EndFunc The text is set, but icon is not. Could someone please tell me why? Thanks everyone in advance Best Regards. Edited June 26, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
AutoBert Posted June 22, 2018 Posted June 22, 2018 Have a look at example 2 in https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlStatusBar_Create.htm That's a very easy way to set icons in a statusbar.
FrancescoDiMuro Posted June 23, 2018 Author Posted June 23, 2018 4 hours ago, AutoBert said: That's a very easy way to set icons in a statusbar. @AutoBert I already managed to set icons in my Status Bar, but, in this particular situation, I can't do it, and I don't know why... If you try to run the code in the first post, what result do you get? Thanks. Best Regards. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
AutoBert Posted June 23, 2018 Posted June 23, 2018 (edited) 20 hours ago, FrancescoDiMuro said: If you try to run the code in the first post, what result do you get? I don't run as i know there is a easier way to do this. set a icon in a statusbar. Edited June 23, 2018 by AutoBert
FrancescoDiMuro Posted June 23, 2018 Author Posted June 23, 2018 @AutoBert, sorry, but I am not following you... Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
InnI Posted June 23, 2018 Posted June 23, 2018 @FrancescoDiMuro ;~ _GUICtrlStatusBar_SetSimple($sbSubFormStatusBar)
FrancescoDiMuro Posted June 25, 2018 Author Posted June 25, 2018 @InnI Thanks for your help! I didn't pay attention to that! And sorry @AutoBert Have a good day Best Regards. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
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