Solved

Coolbar

Posted on 1998-07-02
6
258 Views
Last Modified: 2010-05-03
I would just like to ask if the coolbar could be implemented in an MDI form.  Whenever I use the coolbar in an
MDI form, it returns an invalid page fault error.  I believe the error's in

Public Sub SubClass(hwnd As Long)
    NextProcs = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)  
    'suspected error to be in third parameter
End Sub

the call to the function WindowProc.  Is it possible to fix this problem?
0
Comment
Question by:wsanchez
[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
  • 3
6 Comments
 
LVL 6

Accepted Solution

by:
anthonyc earned 70 total points
ID: 1464788
Where is WindowProc located?  It MUST be in a BAS file.

also, Coolbar..d o you mean like outlook, or just a flat toolbar?  If you mean a flat toolbar, I can do that without subclassing.

Anthony
0
 

Author Comment

by:wsanchez
ID: 1464789
Coolbar as in flat toolbars.  Actually I have downloaded it from the net.  It consists of the CRebar(Rebar.cls) class module and the RebarSubClass(Rebarsubclass.bas) module.
Public Sub SubClass(hwnd As Long) is located in the MDI form while WindowProc is located in the Rebarsubclass.bas module.

Could you show me how to implement it in an MDI form if possible?
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1464790
Seems like a lot of work.  I have a wrapper function that if you pass it the comctl32 toolbar, SP3, it will make it flat with a flag.  Here it is:

Private Const WM_USER = &H400
Private Const TB_SETSTYLE = WM_USER + 56
Private Const TB_GETSTYLE = WM_USER + 57
Private Const TBSTYLE_FLAT = &H800

Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Sub SetToolbarStyle(tbr As Object, bFlat As Boolean)
    Dim lStyle   As Long
    Dim lToolbar As Long
    Dim lRes     As Long
   
    If UCase$(TypeName(tbr)) = "TOOLBAR" Then
        'Make it flat

        'get the handle of the toolbar
        lToolbar = FindWindowEx(tbr.hwnd, 0&, "ToolbarWindow32", vbNullString)

        'retrieve the toolbar styles
        lStyle = SendMessageLong(lToolbar, TB_GETSTYLE, 0&, 0&)

        'Set the new lStyle flag
        If bFlat Then
            lStyle = lStyle Or TBSTYLE_FLAT
        Else
            lStyle = lStyle Xor TBSTYLE_FLAT
        End If

        'apply the new lStyle to the toolbar
        lRes = SendMessageLong(lToolbar, TB_SETSTYLE, 0, lStyle)
        tbr.Refresh
    End If
End Sub

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:wsanchez
ID: 1464791
anthonyc, I still have to try this out but I would like to make it clear that the Coolbar works with a non-MDI form.  Also, how do I call the procedure you gave and where do I put it (just to be sure).
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1464792
Wsanchez,

My function will work with any form that has a toolbar with it.  You can place the function in a BAS file, and then  just call it.  It doesn't have to be in a BAS file, but if it is, then everyone can use it.

One thing about MDI Forms, the HWND of the MDIFORM is NOT the HWND of the client area where the toolbar resides. MDI Forms consist of a few windows.
0
 

Author Comment

by:wsanchez
ID: 1464793
anthonyc.  Thanks for the code.  It works and it's much shorter.  Do you have any code that makes the toolbar movable.  Anyway, here are the points for the flat toolbar.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

730 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