[RESOLVED] Checkbox on a Toolbar
Hi, recently I created a small application and I put a Checkbox on the Toolbar to shut down the computer after the application is finished.
Everything looks fine on my computer (XP) and heard nothing from the people who tested the application.
http://img355.imageshack.us/img355/4070/78478056vu2.png
A few days ago I submitted the application to softpedia.com and they ceated their own screenshots, but the Checkbox is positioned over the last button on the Toolbar.
http://img385.imageshack.us/img385/6359/65204134mo8.png
Does anybody know how to fix this?
The Align property is set to 1 - vbAlignTop
I would like to keep it that way, because if I set it to 0 - vbAlignNone, the toolbar gets an ugly border.
Re: Checkbox on a Toolbar
Here is how I do it:
- add standard checkbox to your form
- assign "placeholder" key to one of your toolbar buttons
- use code similar to this:
Code:
Option Explicit
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Form_Load()
With Toolbar1
.Buttons("placeholder").Style = tbrPlaceholder
.Buttons("placeholder").Width = Check1.Width + 120
Set Check1.Container = Toolbar1
'SetParent Check1.hWnd, Toolbar1.hWnd
Check1.Move .Buttons("placeholder").Left + 120, (.Height - Check1.Height) / 2
Check1.ZOrder
End With
End Sub
NOTE: you can use Container or SetParent - I gave you both options but it's your choice.
Re: Checkbox on a Toolbar
Another way would be to use an image of a checkbox checked and unchecked and toggle the image upon button click.
Re: Checkbox on a Toolbar
Thank you very much, RhinoBull :bigyello:
I'm using Container and it works perfectly.
Re: [RESOLVED] Checkbox on a Toolbar