Jump to content
FrancescoDiMuro

[Solved] Can't set icon to a Status Bar

Recommended Posts

FrancescoDiMuro
Posted (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 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:

#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 by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro
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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
AutoBert
Posted (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 by AutoBert

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@AutoBert, sorry, but I am not following you...

 


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
InnI

@FrancescoDiMuro

;~         _GUICtrlStatusBar_SetSimple($sbSubFormStatusBar)

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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

  • Similar Content

    • dimm
      By dimm
      Is it possible to compile script without any icon resources included?
      When I make exe it uses default system icon of current OS even if I compile as console application.
      On other versions of Windows it looks a little strange

       
      Update:
      It seems that the only way is remove icons from exe after compilation using resource editors like ResHacker.

       
      another bad solution:
      Using corrupted 35 bytes icon file. Windows can't load it and shows default system icon.
      #pragma compile(Icon, broken.ico) broken.ico
    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


×