Solved

CToolBarCtrl GPF during Create

Posted on 1997-04-30
3
389 Views
Last Modified: 2013-11-20
I'm trying to create a tool bar control in a dialog (something like the small toolbar in the standard Open/Save dialog). However, when the program is first run it GPF's when creating the toolbar control. After the program has been run once, subsequent executions of the program work fine. This only seems to happen under Windows 95. NT doesn't "seem" to have a problem creating the control.

Here's a snippet of code  - just the creation part that actually GPF's.

    CToolBarCtrl    MyToolBar;

    if( ! MyToolBar.Create( WS_CHILD | WS_VISIBLE | CCS_TOP | CCS_NOPARENTALIGN |
                                CCS_NODIVIDER | TBSTYLE_TOOLTIPS,
                                CRect(10,10,100,40), this, 50384 ) )
    {
        TRACE( "Failed to create toolbar\n" );
        return;
    }

Am I completely missing something? I've tried putting both a call to InitCommonControls and AfxOleInit with no effect.
0
Comment
Question by:Melange
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
mbhakta earned 100 total points
Comment Utility
The following code is from one of my old projects. It works well under 95 and NT.

CRect rtToolBar(0,0,0,0);
m_wndStyleBar.Create(WS_BORDER | WS_VISIBLE | WS_CHILD |
      TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS,
      rtToolBar,this, IDR_TOOLSTYLE);
      m_wndStyleBar.AutoSize();

GetDlgItem( IDC_TOOLBAR)->GetWindowRect( &rtToolBar);
ScreenToClient( &rtToolBar);

m_wndStyleBar.SetWindowPos( &CWnd::wndTop ,
                        rtToolBar.left, rtToolBar.top,
                        -1, -1, SWP_NOSIZE | SWP_SHOWWINDOW);

m_wndStyleBar.CheckButton( m_nToolsStyle + BUTTON_INCR );
m_wndStyleBar.SetSelectedID(m_nToolsStyle + BUTTON_INCR);


m_wndStyleBar is a mem. variable.


Also , the toolbar is drawn on top of a frame on the dialog.
Type : Frame . Color : Black Id : IDC_TOOLBAR.


0
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
If you still have problems send me your e-mail address and I will send you the source code.
0
 
LVL 3

Author Comment

by:Melange
Comment Utility
Thanks for your answer. I've now figure out EXACTLY what portion of the Create call was crashing. I believe this is a bug in Windows 95. Note: Windows NT performs flawlessly. When the CCS_NOPARENTALIGN flag is set AND the starting rectangle is NOT all zeroes, then the Create does a firey crash and burn. It works otherwise. Anybody know why???
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 76
move a line in eclipse 3 60
pre4 challenge 19 87
Annoying "thing" blocks my view 4 49
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

9 Experts available now in Live!

Get 1:1 Help Now