Sign in to follow this  
Followers 0
MrFlibble

CheckBox Partially Displayed

9 posts in this topic

I have a script that reads a list of up to 40 computer numbers and displays them on the gui with corresponding checkboxes. The checkboxes are spaced 25 pixels apart going down the screen in line with the computer numbers. The labels are fine, but the checkboxes when it reaches about 15 down are only partially showing.

Im assuming that the previous checkbox is partially covering the next checkbox, if you click on one of the checkboxes it shows in full and the top of the checkbox is quite a distance away from the bottom of the previous checkbox. Increasing the spacing isnt really much of an option, anybody have any ideas on either what Im doing wrong or a workaround for this?

I know I havent explained very clearly so Ive included some code to show what I mean.

#include <GUIConstants.au3>
$gui = GUICreate("TEST",400,900)
$button = GUICtrlCreateButton("Submit Username",120,7)
$EditBoxUSer = GUICtrlCreateInput("Enter Username",10,10,100,20)
GUISetState(@SW_SHOW)
$string = "pc1,pc2,pc3,pc4,pc5,pc6,pc7,pc8,pc9,pc10,pc11,pc12,pc13,pc14,pc15,pc16,pc12,pc13,pc14,pc15,pc16,

pc17,pc18,pc19,pc20,pc21,pc22,pc23,pc24,pc25"
$aAllPc = StringSplit($string,",")
Createcheckbox($aAllPc)
;;;;;;;;;;;;;;;;;;MAIN GUI LOOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    
    While 1
$msg = GUIGetMsg(1)
if $msg[0] = $GUI_EVENT_CLOSE Then
    Exit
EndIf
    Wend
    
Func Createcheckbox($aAllPc)
    $int = $aAllPc[0] + 1
    Dim $pclabel[$int] , $chk[$int]
    $add = 50
    $add1 = 50
        
    For $i = 1 to UBound($aAllPc) - 1
    $pclabel[$i] = GUICtrlCreateLabel($aAllPc[$i],5, $add1)
    $chk[$i] = GUICtrlCreateCheckbox("",100, $add)
    $add = $add + 25
    $add1 = $add1 + 26
    Next

EndFunc

Share this post


Link to post
Share on other sites



You need the width and height values for your checkboxes. You can see the effect of this by adding a background color to the checkbox.

#include <GUIConstants.au3>
$gui = GUICreate("TEST",400,900)
$button = GUICtrlCreateButton("Submit Username",120,7)
$EditBoxUSer = GUICtrlCreateInput("Enter Username",10,10,100,20)
GUISetState(@SW_SHOW)
$string = "pc1,pc2,pc3,pc4,pc5,pc6,pc7,pc8,pc9,pc10,pc11,pc12,pc13,pc14,pc15,pc16,pc12,pc13,pc14,pc15,pc16,pc17,pc18,pc19,pc20,pc21,pc22,pc23,pc24,pc25"
$aAllPc = StringSplit($string,",")
Createcheckbox($aAllPc)
;;;;;;;;;;;;;;;;;;MAIN GUI LOOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    
    While 1
$msg = GUIGetMsg(1)
if $msg[0] = $GUI_EVENT_CLOSE Then
    Exit
EndIf
    Wend
    
Func Createcheckbox($aAllPc)
    $int = $aAllPc[0] + 1
    Dim $pclabel[$int] , $chk[$int]
    $add = 50
    $add1 = 50
        
    For $i = 1 to UBound($aAllPc) - 1
    $pclabel[$i] = GUICtrlCreateLabel($aAllPc[$i],5, $add1)
    $chk[$i] = GUICtrlCreateCheckbox("",100, $add, 20, 20)
    GuiCtrlSetBkColor(-1, 0xffffff)
    $add = $add + 25
    $add1 = $add1 + 26
    Next

EndFunc

Share this post


Link to post
Share on other sites

You need the width and height values for your checkboxes. You can see the effect of this by adding a background color to the checkbox.

#include <GUIConstants.au3>
$gui = GUICreate("TEST",400,900)
$button = GUICtrlCreateButton("Submit Username",120,7)
$EditBoxUSer = GUICtrlCreateInput("Enter Username",10,10,100,20)
GUISetState(@SW_SHOW)
$string = "pc1,pc2,pc3,pc4,pc5,pc6,pc7,pc8,pc9,pc10,pc11,pc12,pc13,pc14,pc15,pc16,pc12,pc13,pc14,pc15,pc16,pc17,pc18,pc19,pc20,pc21,pc22,pc23,pc24,pc25"
$aAllPc = StringSplit($string,",")
Createcheckbox($aAllPc)
;;;;;;;;;;;;;;;;;;MAIN GUI LOOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    
    While 1
$msg = GUIGetMsg(1)
if $msg[0] = $GUI_EVENT_CLOSE Then
    Exit
EndIf
    Wend
    
Func Createcheckbox($aAllPc)
    $int = $aAllPc[0] + 1
    Dim $pclabel[$int] , $chk[$int]
    $add = 50
    $add1 = 50
        
    For $i = 1 to UBound($aAllPc) - 1
    $pclabel[$i] = GUICtrlCreateLabel($aAllPc[$i],5, $add1)
    $chk[$i] = GUICtrlCreateCheckbox("",100, $add, 20, 20)
    GuiCtrlSetBkColor(-1, 0xffffff)
    $add = $add + 25
    $add1 = $add1 + 26
    Next

EndFunc
Thanks very much :-)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I have a script that reads a list of up to 40 computer numbers and displays them on the gui with corresponding checkboxes. The checkboxes are spaced 25 pixels apart going down the screen in line with the computer numbers. The labels are fine, but the checkboxes when it reaches about 15 down are only partially showing.

I’m assuming that the previous checkbox is partially covering the next checkbox, if you click on one of the checkboxes it shows in full and the top of the checkbox is quite a distance away from the bottom of the previous checkbox. Increasing the spacing isn’t really much of an option, anybody have any ideas on either what I’m doing wrong or a workaround for this?

I know I haven’t explained very clearly so I’ve included some code to show what I mean.

#include <GUIConstants.au3>
$gui = GUICreate("TEST",400,900)
$button = GUICtrlCreateButton("Submit Username",120,7)
$EditBoxUSer = GUICtrlCreateInput("Enter Username",10,10,100,20)
GUISetState(@SW_SHOW)
$string = "pc1,pc2,pc3,pc4,pc5,pc6,pc7,pc8,pc9,pc10,pc11,pc12,pc13,pc14,pc15,pc16,pc12,pc13,pc14,pc15,pc16,

pc17,pc18,pc19,pc20,pc21,pc22,pc23,pc24,pc25"
$aAllPc = StringSplit($string,",")
Createcheckbox($aAllPc)
;;;;;;;;;;;;;;;;;;MAIN GUI LOOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    
    While 1
$msg = GUIGetMsg(1)
if $msg[0] = $GUI_EVENT_CLOSE Then
    Exit
EndIf
    Wend
    
Func Createcheckbox($aAllPc)
    $int = $aAllPc[0] + 1
    Dim $pclabel[$int] , $chk[$int]
    $add = 50
    $add1 = 50
        
    For $i = 1 to UBound($aAllPc) - 1
    $pclabel[$i] = GUICtrlCreateLabel($aAllPc[$i],5, $add1)
    $chk[$i] = GUICtrlCreateCheckbox("",100, $add)
    $add = $add + 25
    $add1 = $add1 + 26
    Next

EndFunc

It looks like it's just a matter of irregular spacing overlaps. Give this variation on your For... Next in the Createcheckbox() function a try - came up clean on a test run:

For $i = 1 To UBound($aAllPc) - 1
   $pclabel[$i] = GUICtrlCreateLabel($aAllPc[$i], 5, $add1,Default,20)
   $chk[$i] = GUICtrlCreateCheckbox("", 100, $add,Default,20)
   $add = $add + 25
   $add1 = $add1 + 25
Next

Edit: spacing

Edit2: apparently I'm a slow typer - weaponx pointed it out for ya already :)

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You should alway check your GUI using the AutoIt Window Info tool:

Start button > All Programs > AutoIt v3 > AutoIt Window Info

With the tool open, you make your script's GUI active and hover your mouse over the checkboxes to find where they overlap each other, which they do!

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

You should alway check your GUI using the AutoIt Window Info tool:

Start button > All Programs > AutoIt v3 > AutoIt Window Info

With the tool open, you make your script's GUI active and hover your mouse over the checkboxes to find where they overlap each other, which they do!

Good advice, its obviously something I've never done before. Anyone know why the size of the checkbox gets so much bigger as the list goes down? the Autoit Window Info tool really does highlight this.

Share this post


Link to post
Share on other sites

Good advice, its obviously something I've never done before. Anyone know why the size of the checkbox gets so much bigger as the list goes down? the Autoit Window Info tool really does highlight this.

It pulls the height value out of its ass by default. Better just to specify.

Share this post


Link to post
Share on other sites

It pulls the height value out of its ass by default. Better just to specify.

Lol, fair enough. Thanks all for help and advice.

Share this post


Link to post
Share on other sites

After some investigation, the height of each checkbox was always (ControlID + 8) pixels for me...sounds like some kind of conspiracy.

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