February 8, 2018 at 12:15 AM #1 Hallo,How to get the position of a child window in its parent window coordinates?best regardsMAx
February 8, 2018 at 2:02 PM #2 Hi,To get the position of a window relative to its parent simply subtract the screen position of the parent from the screen position of the child window.Try this: C #include "DIALOG.h" /********************************************************************* * * Static code * ********************************************************************** */ /********************************************************************* * * _cbWinParent */ static void _cbWinParent(WM_MESSAGE * pMsg) { WM_HWIN hChild; GUI_RECT Rect; int xPos; int yPos; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_RED); GUI_Clear(); hChild = WM_GetFirstChild(pMsg->hWin); xPos = WM_GetWindowOrgX(hChild) - WM_GetWindowOrgX(pMsg->hWin); yPos = WM_GetWindowOrgY(hChild) - WM_GetWindowOrgY(pMsg->hWin); break; default: WM_DefaultProc(pMsg); break; } } /********************************************************************* * * _cbBk */ static void _cbWinChild(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_GREEN); GUI_Clear(); break; default: WM_DefaultProc(pMsg); break; } } /********************************************************************* * * Public code * ********************************************************************** */ /********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hWinParent; WM_HWIN hWinChild; GUI_Init(); hWinParent = WM_CreateWindowAsChild(10, 10, 150, 150, WM_HBKWIN, WM_CF_SHOW, _cbWinParent, 0); hWinChild = WM_CreateWindowAsChild(10, 10, 50, 50, hWinParent, WM_CF_SHOW, _cbWinChild, 0); while (1) { GUI_Delay(100); } } Display More RegardsSven