now providing new position of child relative to parent in the position
authorDiederick Niehorster <dcnieho@gmail.com>
Fri, 23 Nov 2012 08:21:24 +0000 (08:21 +0000)
committerDiederick Niehorster <dcnieho@gmail.com>
Fri, 23 Nov 2012 08:21:24 +0000 (08:21 +0000)
callback
also need to set position func for the child window in the resizer demo

git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1480 7f0cb862-5218-0410-a997-914c9d46530a

progs/demos/Resizer/Resizer.cpp
src/mswin/fg_main_mswin.c

index c2ca76d..3caf38e 100644 (file)
@@ -12,7 +12,8 @@ GLboolean bChildPosDone = GL_FALSE, bChildSizeDone = GL_FALSE;
 \r
 void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY );\r
 void Redisplay();\r
-void Reshape(int x, int y);\r
+void Reshape(int width, int height);\r
+void Position(int x, int y);\r
 \r
 \r
 \r
@@ -117,6 +118,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
             glutKeyboardFunc( SampleKeyboard );\r
             glutDisplayFunc( Redisplay );\r
             glutReshapeFunc( Reshape );\r
+            glutPositionFunc( Position );\r
         }\r
         else\r
         {\r
index 981acad..3ecde1f 100644 (file)
@@ -432,6 +432,18 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
             SFG_Window* saved_window = fgStructure.CurrentWindow;
             RECT windowRect;
             GetWindowRect( window->Window.Handle, &windowRect );
+            
+            if (window->Parent)
+            {
+                /* For child window, we should return relative to upper-left
+                * of parent's client area.
+                */
+                POINT topleft = {windowRect.left,windowRect.top};
+
+                ScreenToClient(window->Parent->Window.Handle,&topleft);
+                windowRect.left = topleft.x;
+                windowRect.top  = topleft.y;
+            }
 
             INVOKE_WCB( *window, Position, ( windowRect.left, windowRect.top ) );
             fgSetWindow(saved_window);