Solved

Changing Style of Common Control Toolbar

Posted on 1997-12-08
6
324 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

810 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