charon Posted March 29, 2014 Share Posted March 29, 2014 I have a tab in my GUI that will list issues found such as low disk space, etc and will only display the control if there is an issue. So I start out setting up the controls as hidden and only show the controls that have an issue. This part works but displays the label controls in the wrong location. I want the controls to display at the top of the tab instead of white space and then it displays it half way down the window. I thought I could use a variable for the location but not sure how to go about it using hidden controls. Here is a test example: expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Built-In Tab Example", 500, 500) $hTab = GUICtrlCreateTab(10, 10, 480, 480) ; Create tabitems Global $Tab_Warn = GUICtrlCreateTabItem("Warn") ;WarningsCheck() $loc = 40 ;VM $VM = _IsVirtualMachine() ;If $VM = 1 Then $Virtual_Label = GUICtrlCreateLabel("Warning: Virtual Machine Found ", 10, $loc) GUICtrlSetBkColor(-1, 0xff0000) ; Red GUICtrlSetTip(-1, "Things are not what they seem") $loc = $loc + 20 ;freespace Local $iFreeSpace = DriveSpaceFree(@HomeDrive & "\") $freeSpace = Floor($iFreeSpace /1024) $freeSpace_label = GUICtrlCreateLabel("Free Space is low: " & $freeSpace & " GB", 10, $loc) GUICtrlSetBkColor($freeSpace_label, 0xff0000) GUICtrlSetState($freeSpace_label, $GUI_HIDE) $loc = $loc + 20 ;Flash $Flash_label = GUICtrlCreateLabel("Flash needs updated", 10, $loc) GUICtrlSetBkColor($Flash_label, 0xff0000) GUICtrlSetState($Flash_label, $GUI_HIDE) $loc = $loc + 20 Local $Java_Label = GUICtrlCreateLabel("Java is out of date: ", 10, $loc) GUICtrlSetBkColor($Java_Label, 0xff0000) GUICtrlSetState($Java_Label, $GUI_HIDE) $loc = $loc + 20 Local $Button_Refresh = GUICtrlCreateButton("Refresh", 220, 35, 60) GUICtrlSetTip(-1, "Lists Issues found on this PC") GUICtrlCreateTabItem("") ; end tabitem definition GUISetState() While 1 Switch GUIGetMsg() Case $msg = $Button_Refresh $VM = _IsVirtualMachine() If $VM = 1 Then ;MsgBox(64, "_IsVirtualMachine()", _IsVirtualMachine()) GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Virtual_Label, $GUI_SHOW) ;MsgBox(64, "Warning", "Warning: Virtual Machine Found") Else GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Virtual_Label, $GUI_HIDE) ;GUICtrlDelete($Virtual_Label) EndIf ;freespace If $freeSpace < 90 Then GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($freeSpace_label, $GUI_SHOW) Else GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($freeSpace_label, $GUI_HIDE) ;GUICtrlDelete($freeSpace_label) EndIf ;flash $FPXVer = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayerActiveX", "Version") if $FPXVer < 12 Then ;will work for now. change this later GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Flash_label, $GUI_SHOW) Else GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Flash_label, $GUI_HIDE) EndIf ;java check Local $JavaCheckResults = CheckJavaVer() If $JavaCheckResults = 1 Then GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Java_Label, $GUI_SHOW) Else GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Java_Label, $GUI_HIDE) EndIf ;etc.................. Link to comment Share on other sites More sharing options...
BrewManNH Posted March 29, 2014 Share Posted March 29, 2014 You should explain what it is you want a bit better, because I'm not sure what it is you need. Also, you should post a functioning script that demonstrates that problem rather than a part of it that isn't helping define the issue. Also, your switch case statements are written wrong, When using Switch/Case/EndSwitch the case statements are written like this. $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ; code here Case $button ; code here EndSwitch ; or this way Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; code here Case $button ; code here EndSwitch If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
charon Posted March 29, 2014 Author Share Posted March 29, 2014 You should explain what it is you want a bit better, because I'm not sure what it is you need. Also, you should post a functioning script that demonstrates that problem rather than a part of it that isn't helping define the issue. Also, your switch case statements are written wrong, When using Switch/Case/EndSwitch the case statements are written like this. $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ; code here Case $button ; code here EndSwitch ; or this way Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; code here Case $button ; code here EndSwitch I will try to explain better: I fixed the switch statement and provided a working example along with screenshots: My issue is the location of the labels. I want the label to be at the top with no whitespace between like this image: So lets say I fix the free space issue on the PC and I press refresh to see the status. I get whitespace between Flash and Memory due to the location of the label expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Built-In Tab Example", 225, 200) $hTab = GUICtrlCreateTab(10, 10, 280, 280) ; Create tabitems Global $Tab_Warn = GUICtrlCreateTabItem("Warn") ;WarningsCheck() $loc = 40 $Mem = MemGetStats() $MemAvail = Floor($Mem[1] /1024) $MEM_Label = GUICtrlCreateLabel("Memory Low: " & $MemAvail, 10, $loc) GUICtrlSetBkColor(-1, 0xff0000) ; Red GUICtrlSetState($MEM_Label, $GUI_HIDE) $loc = $loc + 20 ;freespace Local $iFreeSpace = DriveSpaceFree(@HomeDrive & "\") ; Find the free disk space of the home drive, generally this is the C:\ drive. $freeSpace = Floor($iFreeSpace /1024) $freeSpace_label = GUICtrlCreateLabel("Free Space is low: " & $freeSpace & " GB", 10, $loc) GUICtrlSetBkColor($freeSpace_label, 0xff0000) GUICtrlSetState($freeSpace_label, $GUI_HIDE) $loc = $loc + 20 ;Flash $Flash_label = GUICtrlCreateLabel("Flash needs updated", 10, $loc) GUICtrlSetBkColor($Flash_label, 0xff0000) GUICtrlSetState($Flash_label, $GUI_HIDE) $loc = $loc + 20 ;test() Local $Button_Refresh = GUICtrlCreateButton("Refresh", 140, 35, 60) GUICtrlSetTip(-1, "Lists Issues found on this PC") Global $Tab_test = GUICtrlCreateTabItem("test") ;~ For $i = 0 To 2 ;~ GUICtrlCreateTabItem("Tab " & $i) ;~ GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) ;~ Next ; Close Tab definiton GUICtrlCreateTabItem("") ;end tabs GUISetState() While 1 Switch GUIGetMsg() Case $Button_Refresh $Mem = MemGetStats() $MemAvail = Floor($Mem[1] /1024) If $MemAvail < 5024 Then GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($MEM_Label, $GUI_SHOW) Else GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($MEM_Label, $GUI_HIDE) EndIf ;freespace If $freeSpace < 10 Then GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($freeSpace_label, $GUI_SHOW) Else GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($freeSpace_label, $GUI_HIDE) ;GUICtrlDelete($freeSpace_label) EndIf ;flash $FPXVer = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayerActiveX", "Version") if $FPXVer < 12 Then GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Flash_label, $GUI_SHOW) Else GUISwitch($hGUI, $Tab_Warn) GUICtrlSetState($Flash_label, $GUI_HIDE) EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
BrewManNH Posted March 29, 2014 Share Posted March 29, 2014 Why not make one large label that holds the text you want to display? Figure out how many lines you are going to need in this label before creating it, and then make it just big enough to hold the information you want in it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 29, 2014 Moderators Share Posted March 29, 2014 charon,My StringSize UDF (look in my sig for the link) is just the thing for determining how big that label would have to be. 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 Link to comment Share on other sites More sharing options...
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