Jump to content

Create GUICtrlCreateLabel from *.ini


thorus
 Share

Recommended Posts

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 ? :o

hdd.ini

[HDD]
hdd=c:
hdd=d:
hdd=e:
hdd=g:

optic.ini

[DVD]
dvd=f:
dvd=h:

units.au3

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

played with it a little

#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)

NEWHeader1.png

Link to comment
Share on other sites

#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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...