Solved

CToolBarCtrl GPF during Create

Posted on 1997-04-30
3
401 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 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