HI,
I am working on Multiple windows and have problems being able to get it to function correctly. I hope someone here can guide me.
1. I have two windows currently.
2. Window 1- Parent window with a settings button.
3. Pressing the settings button opens up child window.
4. Window 2- Child window consists of three buttons.
Question: I am pressing the button in child window, I don't understand how to control this? where will the control be passed to? Parent window? or the WM_NOTIFICATION_RELEASED in the child window? I have tried both of these and don't seem to understand what's going on.
I have seen sample codes where there is only one button and reaction to the touch of the button changes the text on the button. Did not have any luck while I followed the same logic. I am also attaching the code I am currently working on.
Display All
Really appreciate any help at this point.
Best regards,
BMD
I am working on Multiple windows and have problems being able to get it to function correctly. I hope someone here can guide me.
1. I have two windows currently.
2. Window 1- Parent window with a settings button.
3. Pressing the settings button opens up child window.
4. Window 2- Child window consists of three buttons.
Question: I am pressing the button in child window, I don't understand how to control this? where will the control be passed to? Parent window? or the WM_NOTIFICATION_RELEASED in the child window? I have tried both of these and don't seem to understand what's going on.
I have seen sample codes where there is only one button and reaction to the touch of the button changes the text on the button. Did not have any luck while I followed the same logic. I am also attaching the code I am currently working on.
C Source Code
- #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
- extern void DrawBMPExternalMemory();
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
- {
- { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0},
- { BUTTON_CreateIndirect, "Tools", GUI_ID_BUTTON5, 50, 193, 40, 40, 0, 0, 0 },
- };
- /*********************************************************************
- * Tools Callback
- **********************************************************************/
- static void _cbTools(WM_MESSAGE * pMsg)
- {
- switch (pMsg->MsgId)
- {
- case WM_PAINT:
- if(BUTTON_IsPressed(pMsg->hWin))
- {
- DrawBMPExternalMemory("GearDown.bmp");
- }
- else
- {
- DrawBMPExternalMemory("GearUp.bmp");
- }
- break;
- default:
- BUTTON_Callback(pMsg); // The original callback
- break;
- }
- }
- static void _cbCreateToolsScreen(WM_MESSAGE * pMsg)
- {
- BUTTON_Handle hButton1, hButton2, hButton3;
- int NCode;
- int Id;
- WM_HWIN hDlg;
- WM_PID_STATE_CHANGED_INFO * pInfo;
- hDlg = pMsg->hWin;
- switch (pMsg->MsgId)
- {
- case WM_CREATE:
- hButton1 = BUTTON_CreateEx(25, 50, 220, 45, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON8);
- BUTTON_SetText(hButton1, "O2 Cell calibration");
- hButton2 = BUTTON_CreateEx(25, 110, 220, 45, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON9);
- BUTTON_SetText(hButton2, "TouchScreen calibration");
- break;
- case WM_PAINT:
- //
- // Draw the background. This is quite important because otherwise we would still see the child window although it gets deleted.
- // With this drawing the background wouldn't "know" how to draw itself.
- //
- GUI_SetBkColor(GUI_BLACK);
- GUI_Clear();
- break;
- case WM_PID_STATE_CHANGED:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch (NCode)
- {
- pInfo = (WM_PID_STATE_CHANGED_INFO *)pMsg->Data.p;
- if (pInfo)
- {
- GUI_DispStringAt("Pressed", 10,10);
- if(Id == GUI_ID_BUTTON8)
- {
- GUI_SetBkColor(GUI_RED);
- }
- }
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg)
- {
- static WM_HWIN hWin;
- WM_HWIN hItem;
- int NCode;
- int Id;
- BUTTON_Handle hButton;
- TEXT_Handle hText1;
- TEXT_Handle hText2;
- hItem = pMsg -> hWin;
- switch (pMsg->MsgId)
- {
- case WM_INIT_DIALOG:
- WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(GUI_BEIGE_BACKGROUND));
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch (NCode)
- {
- case WM_NOTIFICATION_RELEASED: // React only if released
- hItem = WM_GetDialogItem(pMsg->hWin, ID_WINDOW_0);
- if(Id == GUI_ID_BUTTON5)// ToolsScreen
- {
- hWin = WM_CreateWindowAsChild(0, 0, 320, 240, pMsg->hWin, WM_CF_SHOW, _cbCreateToolsScreen, 0);
- }
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * MainTask
- */
- void BitmapOnButton(void)
- {
- //
- // Use memory devices for all windows
- //
- #if GUI_SUPPORT_MEMDEV
- WM_SetCreateFlags(WM_CF_MEMDEV);
- WM_EnableMemdev(WM_HBKWIN);
- #endif
- WM_SetDesktopColor(GUI_BLACK);
- while (1)
- {
- GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, 0, 0, 0);
- GUI_Delay(10);
- }
- }
- /*************************** End of file ****************************/
Really appreciate any help at this point.
Best regards,
BMD