CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 1999
    Posts
    505

    [RESOLVED] Run Time Assertion

    Hi,
    Following function is causing run-time assertion. I am using VC6.0 professional version. My OS is Win7.0. I am calling the function from OnDraw. OnDraw does not contain any other code other than the function call code:
    Code:
    void CMoireUseCirclesView::UseCircle(CDC* pDC){
    	int x1, y1, x2, y2;
    	x1=20;
    	y1=100;
    	x2=200;
    	y2=280;
    	int color1=0;
    	int color2=0;
    	int color3=0;
    	CPen newPen(PS_SOLID, 5, RGB(0,0,0));
    	CPen* pOldPen=NULL;
    	//pOldPen=pDC->SelectObject(&penBlack);
        //pDC->SelectObject(pOldPen);
    
    	
    	for(int i=0; i<50; ++i){
    		pDC->Ellipse(x1+i, y1, x2+i, y2);
    		newPen.CreatePen(PS_SOLID,5, RGB(color1,color2,color3+i));
    		pDC->SelectObject(&newPen);
    	}
    	pDC->SelectObject(pOldPen);
    }
    The assertion is occurring at:
    Code:
    newPen.CreatePen(PS_SOLID,5, RGB(color1,color2,color3+i));
    The error message is:
    Debug Assertion Failed
    Prog:....
    File:wingdi.cpp
    Line:1120
    Debug is giving following values
    Loaded 'ntdll.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\kernel32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\KernelBase.dll', no matching symbolic information found.
    Loaded symbols for 'C:\Windows\SysWOW64\MFC42D.DLL'
    Loaded symbols for 'C:\Windows\SysWOW64\MSVCRTD.DLL'
    Loaded 'C:\Windows\SysWOW64\gdi32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\user32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\advapi32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\msvcrt.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\sechost.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\sspicli.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\cryptbase.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\lpk.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\usp10.dll', no matching symbolic information found.
    Loaded symbols for 'C:\Windows\SysWOW64\MFCO42D.DLL'
    Loaded 'C:\Windows\SysWOW64\imm32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\msctf.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\uxtheme.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\dwmapi.dll', no matching symbolic information found.
    Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5\comctl32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\ole32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\clbcatq.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\oleaut32.dll', no matching symbolic information found.
    Loaded 'C:\Program Files\WIDCOMM\Bluetooth Software\syswow64\BtMmHook.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\shell32.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\shlwapi.dll', no matching symbolic information found.
    Loaded 'C:\Windows\SysWOW64\psapi.dll', no matching symbolic information found.
    Detected memory leaks!
    Dumping objects ->
    strcore.cpp(118) : {125} normal block at 0x00422C10, 18 bytes long.
    Data: < Read> 01 00 00 00 05 00 00 00 05 00 00 00 52 65 61 64
    strcore.cpp(118) : {108} normal block at 0x00422120, 21 bytes long.
    Data: < Unti> 01 00 00 00 08 00 00 00 08 00 00 00 55 6E 74 69
    array_p.cpp(110) : {106} normal block at 0x00422170, 20 bytes long.
    Data: < -B > 00 00 00 00 D0 2D 42 00 00 00 00 00 CD CD CD CD
    array_p.cpp(71) : {105} normal block at 0x004221B0, 4 bytes long.
    Data: < > 00 00 00 00
    winfrm2.cpp(66) : {104} client block at 0x004221E0, subtype 0, 168 bytes long.
    a CDockBar object at $004221E0, 168 bytes long
    array_p.cpp(71) : {103} normal block at 0x004222C0, 4 bytes long.
    Data: < > 00 00 00 00
    winfrm2.cpp(66) : {102} client block at 0x004222F0, subtype 0, 168 bytes long.
    a CDockBar object at $004222F0, 168 bytes long
    array_p.cpp(71) : {101} normal block at 0x00422660, 4 bytes long.
    Data: < > 00 00 00 00
    winfrm2.cpp(66) : {100} client block at 0x004223D0, subtype 0, 168 bytes long.
    a CDockBar object at $004223D0, 168 bytes long
    winfrm2.cpp(66) : {98} client block at 0x004224B0, subtype 0, 168 bytes long.
    a CDockBar object at $004224B0, 168 bytes long
    bardock.cpp(735) : {97} normal block at 0x00422690, 176 bytes long.
    Data: < K_ > 84 01 4B 5F CD CD CD CD CD CD CD CD CD CD CD CD
    strcore.cpp(118) : {96} normal block at 0x00422590, 17 bytes long.
    Data: < SCRL> 01 00 00 00 04 00 00 00 04 00 00 00 53 43 52 4C
    strcore.cpp(118) : {95} normal block at 0x004225D0, 16 bytes long.
    Data: < NUM > 01 00 00 00 03 00 00 00 03 00 00 00 4E 55 4D 00
    strcore.cpp(118) : {94} normal block at 0x00422610, 16 bytes long.
    Data: < CAP > 01 00 00 00 03 00 00 00 03 00 00 00 43 41 50 00
    {90} normal block at 0x004227E0, 80 bytes long.
    Data: < U > 00 00 00 00 55 01 00 00 00 01 00 08 00 00 00 00
    plex.cpp(31) : {87} normal block at 0x00422860, 124 bytes long.
    Data: < p(B -B > 00 00 00 00 70 28 42 00 00 00 00 00 D0 2D 42 00
    plex.cpp(31) : {86} normal block at 0x00422910, 124 bytes long.
    Data: < )B > 00 00 00 00 00 00 00 00 00 00 00 00 C0 29 42 00
    D:\Zulfi\VC6\CGAM LAB\MoireUseCircles\MoireUseCirclesView.cpp(19) : {85} client block at 0x004229C0, subtype 0, 68 bytes long.
    a CMoireUseCirclesView object at $004229C0, 68 bytes long
    strcore.cpp(118) : {81} normal block at 0x00422BC0, 28 bytes long.
    Data: < Moir> 01 00 00 00 0F 00 00 00 0F 00 00 00 4D 6F 69 72
    D:\Zulfi\VC6\CGAM LAB\MoireUseCircles\MainFrm.cpp(18) : {79} client block at 0x00422C90, subtype 0, 480 bytes long.
    a CMainFrame object at $00422C90, 480 bytes long
    D:\Zulfi\VC6\CGAM LAB\MoireUseCircles\MoireUseCirclesDoc.cpp(18) : {78} client block at 0x00422EA0, subtype 0, 84 bytes long.
    a CMoireUseCirclesDoc object at $00422EA0, 84 bytes long
    plex.cpp(31) : {77} normal block at 0x00422F20, 124 bytes long.
    Data: < B > 00 00 00 00 00 00 00 00 00 00 00 00 B0 10 42 00
    {76} client block at 0x00422FD0, subtype 0, 32 bytes long.
    a CDocManager object at $00422FD0, 32 bytes long
    strcore.cpp(118) : {75} normal block at 0x00421030, 79 bytes long.
    Data: < B B Moir> 01 00 00 00 42 00 00 00 42 00 00 00 4D 6F 69 72
    D:\Zulfi\VC6\CGAM LAB\MoireUseCircles\MoireUseCircles.cpp(76) : {74} client block at 0x004210B0, subtype 0, 108 bytes long.
    a CSingleDocTemplate object at $004210B0, 108 bytes long
    strcore.cpp(118) : {72} normal block at 0x00421150, 19 bytes long.
    Data: < File> 01 00 00 00 06 00 00 00 06 00 00 00 46 69 6C 65
    strcore.cpp(118) : {71} normal block at 0x00421190, 29 bytes long.
    Data: < Rece> 01 00 00 00 10 00 00 00 10 00 00 00 52 65 63 65
    {70} normal block at 0x004211E0, 20 bytes long.
    Data: < L_ L_ L_> 04 00 00 00 14 CB 4C 5F 14 CB 4C 5F 14 CB 4C 5F
    {69} normal block at 0x00421220, 32 bytes long.
    Data: << K_ B B > 3C 8D 4B 5F 04 00 00 00 E4 11 42 00 9C 11 42 00
    Object dump complete.
    The thread 0xF60 has exited with code 3 (0x3).
    The program 'D:\Zulfi\VC6\CGAM LAB\MoireUseCircles\Debug\MoireUseCircles.exe' has exited with code 3 (0x3).

    Somebody plz help me.

    Zulfi.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Run Time Assertion

    The crucial part you left out is what the ASSERT actually says is wrong.

    You never delete the pen which is probably what the problem is. You're creating the same pen more than once.
    Last edited by GCDEF; February 2nd, 2014 at 09:16 AM.

  3. #3
    Join Date
    Jun 1999
    Posts
    505

    Re: Run Time Assertion

    Hi,
    Thanks. I am able to solve this problem by deleting object.

    Code:
    void CMoireUseCirclesView::UseCircle(CDC* pDC){
    	int x1, i,y1, x2, y2;
    	x1=20;
    	y1=100;
    	x2=200;
    	y2=280;
    	int color1=0;
    	int color2=0;
    	int color3=0;
    	CPen newPen1(PS_SOLID, 5, RGB(0,0,0));
    	CPen newPen;
    	CPen* pOldPen=NULL;
    	//pOldPen=pDC->SelectObject(&penBlack);
        //pDC->SelectObject(pOldPen);
    
    	i=0;
    	for( i=0; i<50; ++i){
    		pDC->Ellipse(x1+i, y1, x2+i, y2);
    		newPen.CreatePen(PS_SOLID,5, RGB(color1,color2,color3+i));
    		pDC->SelectObject(&newPen);
    		//newPen.CreatePen(PS_SOLID,5, RGB(color1,color2,color3+i));
    		//pDC->SelectObject(&newPen);
    		
    
    	pDC->SelectObject(pOldPen);
    	newPen.DeleteObject();
    	}
    }

  4. #4
    Join Date
    Jan 2012
    Location
    India
    Posts
    193

    Re: [RESOLVED] Run Time Assertion

    Hi ,

    I have not tried ur code .. but why you are creating and deleting Pen in loop .. I think you can select pen .. draw whatever you wish and then select oldpen and delete current pen if required.

  5. #5
    Join Date
    Jun 1999
    Posts
    505

    Re: [RESOLVED] Run Time Assertion

    Hi,
    Thanks. Actually i dont know how to chnage the color of pen without creating an object.

    Zulfi.

  6. #6
    Join Date
    Jan 2012
    Location
    India
    Posts
    193

    Re: [RESOLVED] Run Time Assertion

    Hi ..

    I use the following code

    Code:
    CPen* oldPen = pDC->GetCurrentPen();
    
    
    CPen *myDrawPen;
    
    myDrawPen = new CPen(PS_SOLID, 1, RGB(230, 230, 230));
    
    pDC->selectObject(myDrawPen);
    
    
    /* Draw all graphics */
    
    delete myDrawPen;
    
    /* or  */
    
    CPen myDrawPen(PS_SOLID, 1, RGB(230, 230, 230));
    		
    pDC->SelectObject(signalPen);
    
    /* draw all graphics */
    
    pDC->SelectObject(oldPen);

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: [RESOLVED] Run Time Assertion

    Quote Originally Posted by Zulfi Khan2 View Post
    Hi,
    Thanks. Actually i dont know how to chnage the color of pen without creating an object.

    Zulfi.
    The code you have that works is fine. I think new_2012 probably missed that you're changing the color each time through the loop.

  8. #8
    Join Date
    Jan 2012
    Location
    India
    Posts
    193

    Re: [RESOLVED] Run Time Assertion

    Thank u GCDEF sir .. I got my mistake .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured