#include "DIALOG.h" #include #define ID_BUTTON 1 /********************************************************************* * * Static code * ********************************************************************** */ static void _cbWin(WM_MESSAGE * pMsg) { int Id, NCode; static int Clicked, Released; BUTTON_Handle hButton; char acBuffer[64]; switch(pMsg->MsgId) { case WM_CREATE: // // Create a button as child of this window. // hButton = BUTTON_CreateEx(10, 10, 80, 20, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON); BUTTON_SetText(hButton, "Click me"); break; case WM_PAINT: GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_SetColor(GUI_BLACK); if(Clicked) { sprintf(acBuffer, "Button was clicked at: %d.", Clicked); GUI_DispStringAt(acBuffer, 10, 40); // GUI_Delay(500); } if(Released) { sprintf(acBuffer, "Button was released at: %d.", Released); GUI_DispStringAt(acBuffer, 10, 60); } break; case WM_NOTIFY_PARENT: // // Since the button is a child of this window, reacts on the button // are sent to its parent window. // Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; // // Check if notification was sent from the button. // switch(Id) { case ID_BUTTON: // // Check for the correct notification code. // switch(NCode) { case WM_NOTIFICATION_CLICKED: Clicked = GUI_GetTime(); WM_InvalidateWindow(pMsg->hWin); break; case WM_NOTIFICATION_RELEASED: Released = GUI_GetTime(); WM_InvalidateWindow(pMsg->hWin); break; } break; } break; default: WM_DefaultProc(pMsg); } } /********************************************************************* * * Public code * ********************************************************************** */ /********************************************************************* * * MainTask */ void MainTask(void) { // // Init emWin. // GUI_Init(); GUI_CURSOR_Show(); // // Create window. // WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), LCD_GetYSize(), WM_HBKWIN, WM_CF_SHOW, _cbWin, 0); while (1) { GUI_Delay(100); } } /*************************** End of file ****************************/