Solved

Coolbar

Posted on 1998-07-02
6
255 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 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

18 Experts available now in Live!

Get 1:1 Help Now