Sign in to follow this  
Followers 0
James

Problem with Multi Creation

8 posts in this topic

Hey all,

I am re making my Disk Manager. I decided I would make it show all drives:

#include <GUIConstantsEx.au3>
#include <GUIStatusBar.au3>
#include <GUIListView.au3>
#include <Constants.au3>
#include <File.au3>

#NoTrayIcon

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

HotKeySet("^E", "_ExportData")

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Minimize")

; Retrieve all drive types
Global $_AllD = DriveGetDrive("ALL")
Dim $Labels[$_AllD[0] + 1]
Dim $Progress[$_AllD[0] + 1]
Local $Parts[2] = [175, 150]

#region GUI
; Create the GUI and the controls inside it
$GUI = GUICreate("Disk Manager - James Brooks", 520, 400 + $_AllD[0] * 2)

#region Menu
$M_File = GUICtrlCreateMenu("File")
$M_Export = GUICtrlCreateMenuItem("Export Data", $M_File)
$M_Exit = GUICtrlCreateMenuItem("Exit", $M_File)
$M_Options = GUICtrlCreateMenu("Options")
; $M_DDisplay = GUICtrlCreateMenuItem("Drives to display", $M_Options) ~ May remove this as all drives are displayed anyway
$M_Colours = GUICtrlCreateMenuItem("Colour Scheme", $M_Options)
$M_Help = GUICtrlCreateMenu("Help")
$M_About = GUICtrlCreateMenuItem("About", $M_Help)
$M_BugReport = GUICtrlCreateMenuItem("Report Bug", $M_Help)
$M_HelpTopic = GUICtrlCreateMenuItem("Help Me", $M_Help)
#region

$StatusBar = _GUICtrlStatusBar_Create($GUI)
_GUICtrlStatusBar_SetParts($StatusBar, $Parts)
_GUICtrlStatusBar_SetText($StatusBar, "Loading Drive Data...")

$DriveList = _GUICtrlListView_Create($GUI, "Drive|Label|Type|Status|File System|Serial Number|Free Space|Used Space|Total Space", 10, 10, 500, $_AllD[0] * 25)

GUICtrlCreateGroup("Information", 10, 140, 500, 210)
For $i = 1 To $_AllD[0]
    $Labels[$i] = GUICtrlCreateLabel(StringUpper($_AllD[$i]), 15, 160 * $i - 100)
    $Progress[$i] = GUICtrlCreateProgress(80, $i * 40, 121, 17)
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)
#region

_Drives()

While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            Exit
        Case $iMsg = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE)
            TraySetState(1)
    EndSelect
WEnd

Func _Drives()
    For $a = 1 To $_AllD[0]
        $Total = Round(DriveSpaceTotal($_AllD[$a]))
        $Free = Round(DriveSpaceFree($_AllD[$a]))
        $Used = Round($Total - $Free)
        $iItem = _GUICtrlListView_InsertItem($DriveList, "", -1, 1)
        _GUICtrlListView_SetItemText($DriveList, $iItem, _
                StringUpper($_AllD[$a]) & "|" & _
                DriveGetLabel($_AllD[$a]) & "|" & _
                DriveGetType($_AllD[$a]) & "|" & _
                DriveStatus($_AllD[$a]) & "|" & _
                DriveGetFileSystem($_AllD[$a]) & "|" & _
                DriveGetSerial($_AllD[$a]) & "|" & _
                $Free & "|" & _
                $Used & "|" & _
                $Total, -1)
    Next
    _GUICtrlStatusBar_SetText($StatusBar, "Drive Data was loaded!")
EndFunc   ;==>_Drives

Func _ExportData()
    ;
EndFunc   ;==>_ExportData

Func _CopyToClipBoard()
    ;
EndFunc   ;==>_CopyToClipBoard

Func Minimize()
    TraySetState(2)
    GUISetState(@SW_SHOW)
    TraySetToolTip("Disk Manager")
EndFunc   ;==>Minimize

However when I make the labels and progresses, they are split to far apart and when I add a - 100~ it moves them all.

Any fixes?

Thanks,

James

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There are a few others who are doing this/// I am sure you know that!

#include <GUIConstantsEx.au3>
#include <GUIStatusBar.au3>
#include <GUIListView.au3>
#include <Constants.au3>
#include <File.au3>

#NoTrayIcon

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

HotKeySet("^E", "_ExportData")

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Minimize")

; Retrieve all drive types
Global $_AllD = DriveGetDrive("ALL")
Dim $Labels[$_AllD[0] + 1]
Dim $Progress[$_AllD[0] + 1]
Local $Parts[2] = [175, 150]

#region GUI
; Create the GUI and the controls inside it
$GUI = GUICreate("Disk Manager - James Brooks", 520, 400 + $_AllD[0] * 2)

#region Menu
$M_File = GUICtrlCreateMenu("File")
$M_Export = GUICtrlCreateMenuItem("Export Data", $M_File)
$M_Exit = GUICtrlCreateMenuItem("Exit", $M_File)
$M_Options = GUICtrlCreateMenu("Options")
; $M_DDisplay = GUICtrlCreateMenuItem("Drives to display", $M_Options) ~ May remove this as all drives are displayed anyway
$M_Colours = GUICtrlCreateMenuItem("Colour Scheme", $M_Options)
$M_Help = GUICtrlCreateMenu("Help")
$M_About = GUICtrlCreateMenuItem("About", $M_Help)
$M_BugReport = GUICtrlCreateMenuItem("Report Bug", $M_Help)
$M_HelpTopic = GUICtrlCreateMenuItem("Help Me", $M_Help)
#region

$StatusBar = _GUICtrlStatusBar_Create($GUI)
_GUICtrlStatusBar_SetParts($StatusBar, $Parts)
_GUICtrlStatusBar_SetText($StatusBar, "Loading Drive Data...")

$DriveList = _GUICtrlListView_Create($GUI, "Drive|Label|Type|Status|File System|Serial Number|Free Space|Used Space|Total Space", 10, 10, 500, $_AllD[0] * 25)

GUICtrlCreateGroup("Information", 10, 140, 500, 210)
For $i = 1 To $_AllD[0]
    $Labels[$i] = GUICtrlCreateLabel(StringUpper($_AllD[$i]), 15, 160 * $i - 100)
    $Progress[$i] = GUICtrlCreateProgress(80, ($i * 30) + 140, 121, 17)
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)
#region

_Drives()

While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            Exit
        Case $iMsg = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE)
            TraySetState(1)
    EndSelect
WEnd

Func _Drives()
    For $a = 1 To $_AllD[0]
        $Total = Round(DriveSpaceTotal($_AllD[$a]))
        $Free = Round(DriveSpaceFree($_AllD[$a]))
        $Used = Round($Total - $Free)
        $iItem = _GUICtrlListView_InsertItem($DriveList, "", -1, 1)
        _GUICtrlListView_SetItemText($DriveList, $iItem, _
                StringUpper($_AllD[$a]) & "|" & _
                DriveGetLabel($_AllD[$a]) & "|" & _
                DriveGetType($_AllD[$a]) & "|" & _
                DriveStatus($_AllD[$a]) & "|" & _
                DriveGetFileSystem($_AllD[$a]) & "|" & _
                DriveGetSerial($_AllD[$a]) & "|" & _
                $Free & "|" & _
                $Used & "|" & _
                $Total, -1)
        GUICtrlSetData($Progress[$a], $Used/1000); not precise
    Next
    _GUICtrlStatusBar_SetText($StatusBar, "Drive Data was loaded!")
EndFunc   ;==>_Drives

Func _ExportData()
    ;
EndFunc   ;==>_ExportData

Func _CopyToClipBoard()
    ;
EndFunc   ;==>_CopyToClipBoard

Func Minimize()
    TraySetState(2)
    GUISetState(@SW_SHOW)
    TraySetToolTip("Disk Manager")
EndFunc   ;==>Minimize

Not intended to be precise, just give direction

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Hey all,

I am re making my Disk Manager. I decided I would make it show all drives:

#include <GUIConstantsEx.au3>
#include <GUIStatusBar.au3>
#include <GUIListView.au3>
#include <Constants.au3>
#include <File.au3>

#NoTrayIcon

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

HotKeySet("^E", "_ExportData")

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Minimize")

; Retrieve all drive types
Global $_AllD = DriveGetDrive("ALL")
Dim $Labels[$_AllD[0] + 1]
Dim $Progress[$_AllD[0] + 1]
Local $Parts[2] = [175, 150]

#region GUI
; Create the GUI and the controls inside it
$GUI = GUICreate("Disk Manager - James Brooks", 520, 400 + $_AllD[0] * 2)

#region Menu
$M_File = GUICtrlCreateMenu("File")
$M_Export = GUICtrlCreateMenuItem("Export Data", $M_File)
$M_Exit = GUICtrlCreateMenuItem("Exit", $M_File)
$M_Options = GUICtrlCreateMenu("Options")
; $M_DDisplay = GUICtrlCreateMenuItem("Drives to display", $M_Options) ~ May remove this as all drives are displayed anyway
$M_Colours = GUICtrlCreateMenuItem("Colour Scheme", $M_Options)
$M_Help = GUICtrlCreateMenu("Help")
$M_About = GUICtrlCreateMenuItem("About", $M_Help)
$M_BugReport = GUICtrlCreateMenuItem("Report Bug", $M_Help)
$M_HelpTopic = GUICtrlCreateMenuItem("Help Me", $M_Help)
#region

$StatusBar = _GUICtrlStatusBar_Create($GUI)
_GUICtrlStatusBar_SetParts($StatusBar, $Parts)
_GUICtrlStatusBar_SetText($StatusBar, "Loading Drive Data...")

$DriveList = _GUICtrlListView_Create($GUI, "Drive|Label|Type|Status|File System|Serial Number|Free Space|Used Space|Total Space", 10, 10, 500, $_AllD[0] * 25)

GUICtrlCreateGroup("Information", 10, 140, 500, 210)
For $i = 1 To $_AllD[0]
    $Labels[$i] = GUICtrlCreateLabel(StringUpper($_AllD[$i]), 15, 160 * $i - 100)
    $Progress[$i] = GUICtrlCreateProgress(80, $i * 40, 121, 17)
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)
#region

_Drives()

While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            Exit
        Case $iMsg = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE)
            TraySetState(1)
    EndSelect
WEnd

Func _Drives()
    For $a = 1 To $_AllD[0]
        $Total = Round(DriveSpaceTotal($_AllD[$a]))
        $Free = Round(DriveSpaceFree($_AllD[$a]))
        $Used = Round($Total - $Free)
        $iItem = _GUICtrlListView_InsertItem($DriveList, "", -1, 1)
        _GUICtrlListView_SetItemText($DriveList, $iItem, _
                StringUpper($_AllD[$a]) & "|" & _
                DriveGetLabel($_AllD[$a]) & "|" & _
                DriveGetType($_AllD[$a]) & "|" & _
                DriveStatus($_AllD[$a]) & "|" & _
                DriveGetFileSystem($_AllD[$a]) & "|" & _
                DriveGetSerial($_AllD[$a]) & "|" & _
                $Free & "|" & _
                $Used & "|" & _
                $Total, -1)
    Next
    _GUICtrlStatusBar_SetText($StatusBar, "Drive Data was loaded!")
EndFunc   ;==>_Drives

Func _ExportData()
    ;
EndFunc   ;==>_ExportData

Func _CopyToClipBoard()
    ;
EndFunc   ;==>_CopyToClipBoard

Func Minimize()
    TraySetState(2)
    GUISetState(@SW_SHOW)
    TraySetToolTip("Disk Manager")
EndFunc   ;==>Minimize

However when I make the labels and progresses, they are split to far apart and when I add a - 100~ it moves them all.

Any fixes?

Thanks,

James

I think it's not a good idea to make the height of yur list view depend on the number of drives found. Best to keep a constant height and let the vertical scroll bar take care of any drives out of sight. Otherwise you have to set the size of your gui as well and the position of all the buttons etc.

If the top of the ListView is $LVTop and the height is $LVHt then in your loop for the progresses you can say

$Progress[$i] = GUICtrlCreateProgress(80, $LVtop + $LVHt + 10 + $i * $VPitch, 121, 17)

where $VPitch is the vertical spacing wanted.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Val, I have already seen it. Very good job he did aswell!

....

Others doing what? This program?

Now I'm confussed.... :)

not really!

8)


NEWHeader1.png

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
Sign in to follow this  
Followers 0