Solved

Why does my application assert on File->New ?

Posted on 2004-04-18
9
295 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 
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

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 130
Adapt this command to show who installed 29 111
haveThree challenge 22 121
How to convert MFC::CString to UTF8 wchar_t* 10 275
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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

792 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