Solved

Changing Style of Common Control Toolbar

Posted on 1997-12-08
6
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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