Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with OnPaint() 1

Status
Not open for further replies.

ebuBekir

Technical User
Sep 6, 2001
22
DE
Hello everybody!
Do you know why this does not work? My problem is, that I cannot see any output on my window.
x is a public member variable of the class CMyMainWindow.
void CMyMainWindow::OnPaint()
{
CPaintDC dc(this);
RECT rect;
GetClientRect(&rect);
char text[128];
text[0] = 0;

if( -1 < x
&& x < SIZE
)
sprintf( text,&quot;Results for x = %d&quot;, x );

if ( text[0] != 0 )
dc.TextOut( 600, 40, text );
}


void CMyMainWindow::OnRun()
{
MfContour2D* pContour = 0;


while( x >= (-1)
&& x < SIZE
)
{
x = ( x < 255 ) ? ( x + 1 ) : x;
sphere.LayerExtraction( x, 'x' );
pContour = sphere.ShapeSearch( gs_off,gs_d,gs_max, x );

if ( pContour != 0 )
{
InvalidateRect( NULL );
// If I call OnPaint as below, it works, with some changing in the definition of OnPaint of course.
//OnPaint( pContour );
}
}
}
Thanks, for your help! :cool:
 
Look at what you are doing:

text[0] = 0;

if( -1 < x
&& x < SIZE
)
sprintf( text,&quot;Results for x = %d&quot;, x );

if ( text[0] != 0 )
dc.TextOut( 600, 40, text );

Go with the debug. Maybe your code does not enter a an if{}.
Does your code ever enters the OnRun. Put a breakpoint also there.

HTH,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
I have set breakpoints into both functions. I think, MFC should call OnPaint itself, if it finds the line InvalidateRect( NULL );
But it does not. I cannot understand why this does not happen.

I think I need a lot of time for leraning MFC and C++.:cool:
 
I think your InvalidateRect(NULL) should work. It looks OK too me.Anyway if you really want to see what is happening in debug mode 'step in' in the line where InvalidateRect is.
Maybe there is some setting you have to make.

HTH,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Well, I had to decide, to check that problem later on. Although not very well, I will keep the code as it is.
Thanks alot.
 
Also try to see if it works:
::SendMessage(this->m_hWnd,WM_PAINT,0,0);

If this, won't work there is a problem in rec ceiving windows messages.

HTH, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top