?
Solved

Changing Style of Common Control Toolbar

Posted on 1997-12-08
6
Medium Priority
?
328 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 450 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 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