Solved

CToolBarCtrl GPF during Create

Posted on 1997-04-30
3
394 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
ID: 1301252
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
ID: 1301253
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
ID: 1301254
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

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 124
maxBlock challenge 30 112
My project did see openJDK that I installed. What could be the problem 7 123
Problem to open Excel file 15 97
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

13 Experts available now in Live!

Get 1:1 Help Now