Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Why does my application assert on File->New ?

Posted on 2004-04-18
9
Medium Priority
?
307 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

705 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