Solved

Changing Style of Common Control Toolbar

Posted on 1997-12-08
6
319 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
Comment Utility
Have you def'd the getwindowlong and setwindowlong in your vb project?
0
 

Author Comment

by:cdm100497
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:cdm100497
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

743 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

12 Experts available now in Live!

Get 1:1 Help Now