Solved

Changing Style of Common Control Toolbar

Posted on 1997-12-08
6
322 Views
Last Modified: 2008-03-10
I would like to change the style of the Common Control Toolbar to support the new Flatbar style...  I have implemented the following code in the Form Activate event but it does not appear to work...

Dim lStyle As Long
Const TBSTYLE_FLAT = &H800
lStyle = GetWindowLong(tbrStandard.hWnd, 0)
lStyle = lStyle Or TBSTYLE_FLAT
SetWindowLong tbrStandard.hWnd, 0, lStyle

This code was taken from the CWnd::ModifyStyle code in the MFC class libraries...

1) Does the Common Control Support this style
2) Is this code valid or do I need to do something else
0
Comment
Question by:cdm100497
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:kesonline
ID: 1444236
Have you def'd the getwindowlong and setwindowlong in your vb project?
0
 

Author Comment

by:cdm100497
ID: 1444237
I have...  All the code works (in that it runs/compiles without producing errors) however it does not appear to do anything.
0
 
LVL 2

Expert Comment

by:PedroMVGomes
ID: 1444238
i've a small revision to this code, in GetWindowLong and SetWindowLong where it is a 0 it should be -16. -16 is the index for the style. However this doesn't do a thing in VB. Does it really works in Visual C???
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:cdm100497
ID: 1444239
In Visual C I used the ModifyStyle command... This produced a Flat toolbar, however this was using the CToolbar functionality, which should be using the Common Control DLL but may not do I suppose...  I will look into it further and find out.
0
 
LVL 2

Accepted Solution

by:
PedroMVGomes earned 150 total points
ID: 1444240
use this code and you will be able to make a flat toolbar
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd as Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Global Const WM_USER = &H400

'Toolbar Messages
Global Const TBN_FIRST = &H700&
Global Const TB_SETSTYLE = WM_USER + 56
Global Const TB_GETSTYLE = WM_USER + 57

'Toolbar styles
Global Const TBSTYLE_FLAT = &H800

Sub SetToolbarFlat(tlbTemp As Toolbar)

Dim Style As Long, lngResult As Long, lngHWND As Long

   'Gets the *real* toolbar (it is inside this one)
   lngHWND = FindWindowEx(tlbTemp.hWnd, 0&, "ToolbarWindow32", vbNullString)
   'Gets old style
   Style = SendMessage(lngHWND, TB_GETSTYLE, 0&, 0&)
   'Adds new style
   Style = Style Or TBSTYLE_FLAT '
   'Modifies the style
   lngResult = SendMessage(lngHWND, TB_SETSTYLE, 0, Style)
   tlbTemp.Refresh

End Sub

'Now you can put call the function on a form load event for the 'form that contains the toolbar, as in:

Sub Form1_Load
SetToolbarFlat Toolbar1
End Sub

0
 

Author Comment

by:cdm100497
ID: 1444241
I added this code to the project... Whilst it works, there would appear to be some problems.

1) The control does not work correctly. i.e. the buttons to not highlight when you move over them.

2) On the MDI Form the code does not work. Any more suggestions.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now