[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CToolBarCtrl GPF during Create

Posted on 1997-04-30
3
Medium Priority
?
420 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 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

Technology Partners: 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Integration Management Part 2
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

810 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