Solved

Why does my application assert on File->New ?

Posted on 2004-04-18
9
304 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
[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
  • 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
MongoDB Through a MySQL Lens

This article looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.

 
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

MongoDB Through a MySQL Lens

This article looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.

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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

623 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