?
Solved

CToolBarCtrl GPF during Create

Posted on 1997-04-30
3
Medium Priority
?
415 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
[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
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
mbhakta earned 200 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

762 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