Hi Timo!
Is there a way to use PNG files as button images? GDI+?
Regards
Meelis
PNG as button image
Re: PNG as button image
Hi,
Yes, this can be done, if you find a way to load the PNG into an image list. Loading a PNG into an image list should be possible. I'll try to create a sample project.
Regards
TiKu
Yes, this can be done, if you find a way to load the PNG into an image list. Loading a PNG into an image list should be possible. I'll try to create a sample project.
Regards
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: PNG as button image
See the attached file. The sample uses GDI+ to load a PNG file into an image list and use the icons for the tool bar buttons.
Regards
TiKu
Regards
TiKu
- Attachments
-
- PNG Icons.zip
- (32.53 KiB) Downloaded 780 times
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: PNG as button image
Hi
Thank you, PNG-s are working fine now.
Question about aligning ReBar. When I set ReBar's alignment to left/right, then no buttons are visible.
What is causing this?
Regards
Meelis
Thank you, PNG-s are working fine now.
Question about aligning ReBar. When I set ReBar's alignment to left/right, then no buttons are visible.
What is causing this?
Regards
Meelis
Re: PNG as button image
OK this was the "Orientation" problem...Mex wrote:Hi
Thank you, PNG-s are working fine now.
Question about aligning ReBar. When I set ReBar's alignment to left/right, then no buttons are visible.
What is causing this?
Regards
Meelis
But how to change rebar/toolbar alignment at runtime? Setting Align at runtime is not working as expected. Align is only working when I use toolbar without rebar.
And couple "bugs" or something..
1) When I set ButtonStyle to flat and toolbar is aligned Top, everything looks ok. Now when I set align to Right, button visual look is changed to 3D, but property is still "flat".
2) Change rebar align to top at design time and try to change "Apperance". ReBar starts to flicker and VB6 IDE hangs.
- Attachments
-
- toolbar.png
- (19.6 KiB) Not downloaded yet
Re: PNG as button image
Hi,
Changing the rebar's orientation at runtime will recreate the control window. Recreation includes destroying the window. Destroying a window also destroys its child windows - the tool bar.
So it might work to detach the tool bar from the rebar while changing the rebar's orientation. This can be done by setting the band's hContainedWindow property to 0 (and afterwards to the tool bar's window handle to re-attach).
Regarding the 2 bugs: I've fixed no. 2. No. 1 seems to be caused by the internal behavior of the native tool bar control and I have not yet found a work-around.
Regards
TiKu
Changing the rebar's orientation at runtime will recreate the control window. Recreation includes destroying the window. Destroying a window also destroys its child windows - the tool bar.
So it might work to detach the tool bar from the rebar while changing the rebar's orientation. This can be done by setting the band's hContainedWindow property to 0 (and afterwards to the tool bar's window handle to re-attach).
Regarding the 2 bugs: I've fixed no. 2. No. 1 seems to be caused by the internal behavior of the native tool bar control and I have not yet found a work-around.
Regards
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: PNG as button image
OK, got it working now.
I found, that correct order is very important, how to change alignment. For example, if you change ReBar's properties first and then ToolBar properties, Buttons.Add method will fail.
And if you change ReBar's "Orientation" first and then "Align", ReBar starts flicker and applications hangs.
Method that's working now as excpected.
I found, that correct order is very important, how to change alignment. For example, if you change ReBar's properties first and then ToolBar properties, Buttons.Add method will fail.
And if you change ReBar's "Orientation" first and then "Align", ReBar starts flicker and applications hangs.
Method that's working now as excpected.
Code: Select all
Private Sub CreateToolbar(Optional ByVal Alignment As Integer = vbAlignTop)
Dim il As Long, dom As New DOMDocument
If MyGDIHelper Is Nothing Then
Set MyGDIHelper = New clsGDIHelper
End If
theToolBar.Buttons.RemoveAll
theRebar.Bands.RemoveAll
Select Case Alignment
Case vbAlignTop
With theToolBar
.Orientation = oHorizontal
End With
With theRebar
.Align = Alignment
.Orientation = oHorizontal
End With
Case vbAlignRight
With theToolBar
.Orientation = oVertical
End With
With theRebar
.Align = Alignment
.Orientation = oVertical
End With
End Select
theRebar.Bands.Add(, theToolBar.hwnd, , SizingGripVisibility:=sgvAlways, MinimumWidth:=38, MinimumHeight:=38).UseChevron = True
Dim node As IXMLDOMNode, n As Integer
dom.Load app.path & "\Templates\toolbars.xml"
If MyGDIHelper.CreateImageListForToolbar("mainmdi") Then
theToolBar.hImageList(ilNormalButtons) = MyGDIHelper.ImageList
For Each node In dom.selectSingleNode("//toolbar[@id='mainmdi']").childNodes
With theToolBar
.Buttons.Add n + 1, , n
End With
n = n + 1
Next
End If
End Sub