<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 9pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Hi everyone:<BR><BR><BR>I had build a simple OSG program with visual studio2005.net and rendered the scene to a win32 window.<BR>I want to change the aspect ratio when the size of the win32 window was  resized, but it can't work correctly.<BR><BR>
 <BR>
Here is some code in my program and the whole project has been attached.<BR><BR>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<BR> {<BR>
    ....................<BR>
   case WM_CREATE:<BR>      gOSG = new COsg(hWnd);<BR>      gOSG->InitOSG(filename);<BR>      /* gThreadHandle = (HANDLE)_beginthread(&COsg::Render, 0, gOSG); */<BR>   break;<BR>    case WM_SIZE:<BR>   {<BR>    int cx = LOWORD(lParam);<BR>    int cy = HIWORD(lParam);<BR><BR>
    double asp = double(cx)/double(cy);<BR>    gOSG->getViewer()->getCamera()->setViewport(0,0,cx,cy);<BR>    gOSG->getViewer()->getCamera()->setProjectionMatrixAsPerspective(30.0f,asp,0.1f,10000.0f);<BR><BR>
    }<BR>    break;<BR>
   ........................<BR> }<BR><BR>
 <BR>
int APIENTRY WinMain(HINSTANCE hInstance,<BR>                     HINSTANCE hPrevInstance,<BR>                     LPTSTR    lpCmdLine,<BR>                     int       nCmdShow)<BR>
{<BR>
................<BR>
 while(!done)         // Loop That Runs While done=FALSE<BR> {<BR>       if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?<BR>       {<BR>            if (msg.message==WM_QUIT)    // Have We Received A Quit Message?<BR>            {<BR>               done=TRUE;       // If So done=TRUE<BR>            }<BR>            else         // If Not, Deal With Window Messages<BR>            {<BR>               TranslateMessage(&msg);    // Translate The Message<BR>               DispatchMessage(&msg);    // Dispatch The Message<BR>            }<BR>       }<BR>       else          // If There Are No Messages<BR>      {<BR>            gOSG->getViewer()->frame();<BR>       }<BR> }<BR>
........................<BR>
 <BR>
}<BR>
 <BR>
As is shown above, I didn't create a new thread for rendering and just made it in the main loop.<BR>
 <BR>
 <BR>
<BR> <BR><br /><hr />奥运圣火到哪里了?  <a href='http://msn.live.cn/ditu' target='_new'>点击查看!</a></body>
</html>