thorus Posted February 27, 2006 Share Posted February 27, 2006 (edited) I work at an aplication to have something like computer information .I've declared disks (CD & DVD , fixed , ...) into a ini file and for now i'm burning my brain for a solution to create in a GUI text labels with computer information . Some computers may have just 2 partitions , some computers may have more.So i have to find a way to create dynamic labels for this.Any help ? hdd.ini[HDD] hdd=c: hdd=d: hdd=e: hdd=g:optic.ini[DVD] dvd=f: dvd=h:units.au3expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> #include <file.au3> If FileExists("hdd.ini") Then FileDelete ("hdd.ini") $file = FileOpen("hdd.ini", 1) FileWriteLine($file , "[HDD]"); try to emulate IniWrite like EndIf If FileExists("optic.ini") Then FileDelete ("optic.ini") $file = FileOpen("optic.ini", 1) FileWriteLine($file , "[DVD]"); try to emulate IniWrite like EndIf $Form1 = GUICreate("AForm1", 592, 365, 190, 134) $Group1 = GUICtrlCreateGroup("Unitati optice :", 8, 16, 561, 89, $WS_BORDER) GUICtrlCreateGroup("", -99, -99, 1, 1) If NOT @error Then $cddvd = DriveGetDrive("CDROM") $textoptic = ("dvd=") $file = FileOpen("optic.ini", 1) For $i = 1 to $cddvd[0] FileWriteLine($file, $textoptic & $cddvd[$i] & @CRLF) Next EndIf If NOT @error Then $hdd = DriveGetDrive( "FIXED" ) $texthdd = ("hdd=") $file = FileOpen("hdd.ini", 1) For $o = 1 to $hdd[0] FileWriteLine($file, $texthdd & $hdd[$o] & @CRLF) Next EndIf $opticok = IniRead("optic.ini", "optice", "dvd", "NotFound") $var = IniReadSection("optic.ini", "DVD") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0][0] MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1]) Next EndIf GUISetState(@SW_SHOW) GUICtrlCreateLabel("DVD sursa : " & $opticok, 200, 110) ;; must auto create GUICtrlCreateLabel for every partition found While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit Edited February 28, 2006 by thorus Link to comment Share on other sites More sharing options...
Valuater Posted February 27, 2006 Share Posted February 27, 2006 readi ini.. if the info is found then create the gui accordingly $info = iniread guicreate() if $info > "" then guicreate label() 8) Link to comment Share on other sites More sharing options...
greenmachine Posted February 27, 2006 Share Posted February 27, 2006 Or you could use different controls, such as listview (good for large lists because it's scrollable) or combo boxes (select 1 of many items..). You could also make a tab control with tab items for each partition. Link to comment Share on other sites More sharing options...
thorus Posted February 27, 2006 Author Share Posted February 27, 2006 Thanks a lot. I will try soon. I'm @work right now Link to comment Share on other sites More sharing options...
thorus Posted February 28, 2006 Author Share Posted February 28, 2006 I got this error : "Error occured, probably no INI file." The message box purpose is to verify ini read. I am so stupid or what ? Link to comment Share on other sites More sharing options...
Valuater Posted February 28, 2006 Share Posted February 28, 2006 played with it a little expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> #include <file.au3> dim $top = 40, $label[10] $file = @ScriptDir & "\hdd.ini" $file2 = @ScriptDir & "\optic.ini" If FileExists($file) Then FileDelete ($file) If FileExists($file2) Then FileDelete ($file2) FileWriteLine($file , "[HDD]"); try to emulate IniWrite like FileWriteLine($file2 , "[DVD]"); try to emulate IniWrite like $Form1 = GUICreate("AForm1", 592, 365, 190, 134) $Group1 = GUICtrlCreateGroup("Unitati optice :", 8, 16, 561, 100);, $WS_BORDER) ;GUICtrlCreateGroup("", -99, -99, 1, 1) If NOT @error Then $cddvd = DriveGetDrive("CDROM") $textoptic = "dvd" For $i = 1 to $cddvd[0] IniWrite($file2, "DVD", $textoptic & $i, $cddvd[$i]) Next EndIf If NOT @error Then $hdd = DriveGetDrive( "FIXED" ) $texthdd = "hdd" For $o = 1 to $hdd[0] IniWrite($file, "DVD", $texthdd & $o, $hdd[$o]) Next EndIf $opticok = IniRead("optic.ini", "optice", "dvd", "NotFound") $var = IniReadSection($file2, "DVD") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0][0] ;MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1]) $Label[$i] = GUICtrlCreateLabel("Key: " & $var[$i][0] & " Value: " & $var[$i][1], 50, $Top, 180, 20) $top = $top + 20 Next EndIf ;; must auto create GUICtrlCreateLabel for every partition found GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit 8) Link to comment Share on other sites More sharing options...
thorus Posted February 28, 2006 Author Share Posted February 28, 2006 THANK YOU !!!! Interesting method! I did not think about this way.Thanks again. Link to comment Share on other sites More sharing options...
Valuater Posted February 28, 2006 Share Posted February 28, 2006 Welcome!! and you can set the size of the group by creating it after the labels and utilize the $Top variable for the hieght 8) Link to comment Share on other sites More sharing options...
thorus Posted March 1, 2006 Author Share Posted March 1, 2006 Thanks, I'v seen $Top variable and i use it well. With the same method i integrate functions for find free space left on every partition and partition type. Link to comment Share on other sites More sharing options...
thorus Posted March 2, 2006 Author Share Posted March 2, 2006 expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> #include <file.au3> dim $top = 40, $label[10] $file = @ScriptDir & "\hdd.ini" $file2 = @ScriptDir & "\optic.ini" If FileExists($file) Then FileDelete ($file) If FileExists($file2) Then FileDelete ($file2) FileWriteLine($file , "[HDD]");emulate INI write FileWriteLine($file2 , "[DVD]");emulate INI write $Form1 = GUICreate("UNITATI", 592, 365, 190, 134) $Group1 = GUICtrlCreateGroup("Medii depistate :", 8, 16, 561, 150, $WS_BORDER) If NOT @error Then $cddvd = DriveGetDrive("CDROM") $textoptic = "dvd" For $i = 1 to $cddvd[0] IniWrite($file2, "DVD", $textoptic & $i, $cddvd[$i]) Next EndIf If NOT @error Then $hdd = DriveGetDrive( "FIXED" ) $texthdd = "hdd" For $o = 1 to $hdd[0] IniWrite($file, "HDD", $texthdd & $o, $hdd[$o]) Next EndIf $opticok = IniRead("optic.ini", "optice", "dvd", "NotFound") $var = IniReadSection($file2, "DVD") If @error Then MsgBox(4096, "", "EROARE, fisierul ini nu poate fi interpretat!") Else For $i = 1 To $var[0][0] $Label[$i] = GUICtrlCreateLabel("cd/dvd " & " " & $var[$i][1], 20, $Top, 180, 20) $top = $top + 20 Next EndIf $partok = IniRead("hdd.ini", "partitii", "hdd", "NotFound") $var = IniReadSection($file, "HDD") If @error Then MsgBox(4096, "", "EROARE, fisierul ini nu poate fi interpretat!") Else For $o = 1 To $var[0][0] $Label[$o] = GUICtrlCreateLabel("hdd " & $var[$o][1]& " " & Round(DriveSpaceFree($var[$o][1]), -1)& " MB; partitie : " & DriveGetFileSystem ($var[$o][1]), 20, $Top, 180, 20) $top = $top + 20 Next EndIf GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit 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