Hi;

I have this portion of the code that in principle must be in WM_SIZE msg .
but if i do that nothing happens and i get
the black screen of mem device context.so instead thinking
may be the rendering part is not getting the size info, i put
it in WM_TIMER and it works fine. why?

Code:

      case WM_SIZE:

 
	   
		
          
         width = cxclient = LOWORD (lParam) ;
         height = cyclient = HIWORD (lParam) ;

       

	
	
		  
          
		 return 0;


	  case WM_TIMER:
		  switch (wParam) 
    { 
        case ID_TIMER1:

//this is the part that is supposed to be in WM_SIZE but its here.

//-----------------------------------------//initializing size for opengl


	   glViewport(0, 0, width, height);              
	   glMatrixMode(GL_PROJECTION);              
	   glLoadIdentity();
	   gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 1.0f, 1000.0f);
	   glMatrixMode(GL_MODELVIEW);
       glLoadIdentity();
glEnable(GL_POINT_SMOOTH);

//-----------------------------------------end of the code, in question
       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	   glLoadIdentity();
	   angle = angle + 1.0f;

	if(angle >= 360.0f)
       angle = 0.0f;
	   glTranslatef(0.0f, 0.0f, -10.0f);

       glColor3f(1.0f, 0.0f, 1.0f);
	   glPolygonMode(GL_FRONT, GL_FILL);
       glPolygonMode(GL_FRONT, GL_LINE);         //filling mode

	
       glBegin(GL_TRIANGLES);

	   glVertex3f(0.0f, 0.0f, 0.0f);
	
       glVertex3f(1.0f, -1.0f, 0.0f);
	   glVertex3f(-1.0f, -1.0f, 0.0f);
	

	   glEnd();
       glColor3f(1.0f, 0.0f, 0.0f);
	   glRotatef(angle, 0.0f, 1.0f, 0.0f);
	
	
	   glBegin(GL_QUADS);

	   glVertex3f(1.0f, 0.0f, 0.0f);
	   glVertex3f(1.0f, 0.2f, 0.0f);
    
       glVertex3f(-1.0f, 0.2f, 0.0f);
	   glVertex3f(-1.0f, 0.0f, 0.0f);
	
	   glEnd();



	    SwapBuffers(g_HDC);
      
 
             return 0; 
 
        case ID_TIMER: 
            
          bdraw = !bdraw;
		  InvalidateRect(hwnd, NULL, FALSE);
            return 0; 

		  }
			  

		
			
		  return 0;
/////
/////

 case WM_COMMAND:

//////
//////


       case 67:
		      InvalidateRect(hwnd, NULL, TRUE);
              hdc = GetDC(hwnd);
		      g_HDC = hdc;

		       SetupPixelFormat(hdc);

		      hRC = wglCreateContext(hdc);
		      wglMakeCurrent(hdc ,hRC);
if(glIsEnabled(GL_POINT_SMOOTH))

       	      MessageBox(hwnd, TEXT(" AntiAliasing Enabled"), TEXT("Antialising"), 0);     
	
         

        ReleaseDC(hwnd, hdc);
		SetTimer(hwnd, ID_TIMER1, 20, NULL);	 
 
	   break;
       return 0;

         case 68:
			 KillTimer(hwnd, ID_TIMER1);
			 hdc = GetDC(hwnd);
	         wglMakeCurrent(hdc, NULL);
		     wglDeleteContext(hRC);
		if   (hdc)
			 ReleaseDC(hwnd, hdc);
		     InvalidateRect(hwnd, NULL, TRUE);
		     UpdateWindow(hwnd);
        break;
        return 0;


		 case 71:
             ShowWindow(hwndlist, TRUE);
			 MoveWindow(hwndlist, cxchard, cychard * 20,cxchard * 13 + GetSystemMetrics (SM_CXVSCROLL),
             cychard * 10, TRUE);
			 SetFocus(hwndlist);                
			 return 0;

////////
///////

case WM_DESTROY:
		 hdc = GetDC(hwnd);
		 DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
         SetBkMode(hdc, OPAQUE);
        
         ReleaseDC(hwnd, hdc);
		 
		if(hRC)
		wglDeleteContext(hRC);
	 if(pbuffer)
		 free(pbuffer);
	     if(ID_TIMER)
	     KillTimer(hwnd, ID_TIMER);
         if(ID_TIMER1)
	     KillTimer(hwnd, ID_TIMER1);

		 DeleteObject(hbrush);
		if(lpszSystemInfo)
		free(lpszSystemInfo);
		 DeleteObject(hmenu1);
		 FontDeinitialize();
		 DeleteObject(hb);
		 ChangeClipboardChain(hwnd, hnextclipowner);
		

		
	

       

         PostQuitMessage (0) ;
          return 0 ;
if u need more code, i will print.

cheers!