Solved

Why does my application assert on File->New ?

Posted on 2004-04-18
9
291 Views
Last Modified: 2013-11-20
Please have a look at my project here:

http://mr_wad_99.europe.webmatrixhosting.net/Gui4UnexTEST.zip

I asked other questions regarding eliminating flicker in my child windows, but the answers also introduced this asserting when the user creates a new document.  

The (skinned down for this question) app displays web pages in tabs.  On startup it displays Yahoo! just for demonstration of the flickering.  The code asserts in Wincore.cpp at the line

ASSERT(wndcls.style == nClassStyle);

I have deduced that the problem is down to the line

SetClassLong(m_hWnd, GCL_STYLE, GetClassLong(m_hWnd, GCL_STYLE) & ~(CS_HREDRAW | CS_VREDRAW));

that is contained within CChildFrame::OnCreate

Without this, no assertion but flicker.  With it, assertion but no flicker.  

I have no idea why this is, maybe you will ?

I know it is only a debug assertion error, and it does not happen in the release build, but I still think it should be sorted out !

TIA !
0
Comment
Question by:mrwad99
  • 5
  • 4
9 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10852913
Cannot reproduce this assertion - maybe installing the latest Visual Studio Service Pack and latest Microsoft SDK can help.
I just guess - try to add this line to CChildFrame::PreCreateWindow

cs.style &= (~(CS_HREDRAW | CS_VREDRAW));

Maybe in this case wndcls.style will be equal to nClassStyle, and MFC will be happy.
0
 
LVL 19

Author Comment

by:mrwad99
ID: 10852916
Did you uncomment the line

SetClassLong(m_hWnd, GCL_STYLE, GetClassLong(m_hWnd, GCL_STYLE) & ~(CS_HREDRAW | CS_VREDRAW));

?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10852923
Yes, I uncommented it in CChildFrame::OnCreate, and this removes flickering. But there is no assertion.
0
 
LVL 19

Author Comment

by:mrwad99
ID: 10852954
OK that is crazy.  I am using VC++6.0 with SP5, and when I have taken the debug version of the app elsewhere on machines that do not have this installed I still get the assertion:

http://mr_wad_99.europe.webmatrixhosting.net/Evidence.jpg

What version of VS are you running ?

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 19

Author Comment

by:mrwad99
ID: 10852960
Sorry, and adding

cs.style &= (~(CS_HREDRAW | CS_VREDRAW));

does not help.

(Updated zip file to give assertion immediately)
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10853016
VC 6.0 with SP5. Well, wait for somebody who can reproduce this problem.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10853036
OK, I reproduced this. You didn't write that assertion appears after File - New command. I will try to do something.
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 10853319
It was really interesting. To solve the problem, open Resource View and remove the IDR_GUI4UNTYPE icon from it (don't ask me why, just read MFC source code in the function which call asserting function...). Program works without assertion now.

However, after removing the icon we get wrong icon in the child frame. To restore it, add the same icon to the resources, but give other ID to it (for example, IDI_ICON1). Add new line to CChildFrame::OnCreate:

    SetClassLong(m_hWnd, GCL_STYLE, GetClassLong(m_hWnd, GCL_STYLE) & ~(CS_HREDRAW | CS_VREDRAW));

    SetIcon(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON1)), FALSE);   // add this line
0
 
LVL 19

Author Comment

by:mrwad99
ID: 10853337
Marvelous.  Thanks a load for that.  

You learn something new every day eh ?

:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 87
how to monitor remote shell execution on linux 9 93
sumDigits challenge 9 98
Not needed 13 58
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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 …
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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