Solved

Why does my application assert on File->New ?

Posted on 2004-04-18
9
294 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 91
repeatEnd java challenge 42 84
sum28 challenge 31 112
Sed question 2 85
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

773 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