Hello to everyone,
there are some widgets in emWin that accept a PID and do things accordingly to a PID state. For example, SLIDER widget.
When motion option enabled in a parent window then PID state is to be trasmitted to parent window and slider loses its correct "sliding functionality" since parent window moves instead of slider.
My question: how to avoid this behaviour? Of course we can handle PID-messages in slider callback and manually enable/disable motion in a parent window.
But maybe there is an easier way?
Here is a simple code:
Display All
Thanks,
Alex.
there are some widgets in emWin that accept a PID and do things accordingly to a PID state. For example, SLIDER widget.
When motion option enabled in a parent window then PID state is to be trasmitted to parent window and slider loses its correct "sliding functionality" since parent window moves instead of slider.
My question: how to avoid this behaviour? Of course we can handle PID-messages in slider callback and manually enable/disable motion in a parent window.
But maybe there is an easier way?
Here is a simple code:
C Source Code
- #include "DIALOG.h"
- WM_HWIN hCheck, hText;
- void _cbWin(WM_MESSAGE * pMsg) {
- GUI_RECT Rect;
- switch (pMsg->MsgId) {
- case WM_CREATE:
- SLIDER_CreateEx(60, 60, 200, 30, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_SLIDER0);
- hCheck = CHECKBOX_CreateEx(60, 100, 100, 20, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_CHECK0);
- CHECKBOX_SetText(hCheck, "Motion disabled");
- hText = TEXT_CreateEx(0, 10, 320, 50, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_TEXT0, "Slider is moving separately from parent window");
- TEXT_SetTextAlign(hText, GUI_TA_CENTER);
- break;
- case WM_NOTIFY_PARENT:
- if ((pMsg->hWinSrc == hCheck) && (pMsg->Data.v == WM_NOTIFICATION_VALUE_CHANGED)) {
- if (CHECKBOX_IsChecked(hCheck)) {
- CHECKBOX_SetText(hCheck, "Motion enabled");
- TEXT_SetText(hText, "Slider makes parent window to move\nHow to avoid it?");
- WM_MOTION_SetMoveable(pMsg->hWin, WM_CF_MOTION_X, 1);
- }
- else {
- CHECKBOX_SetText(hCheck, "Motion disabled");
- TEXT_SetText(hText, "Slider is moving separately from parent window");
- WM_MOTION_SetMoveable(pMsg->hWin, WM_CF_MOTION_X, 0);
- }
- }
- break;
- case WM_PAINT:
- WM_GetClientRect(&Rect);
- GUI_SetBkColor(GUI_WHITE);
- GUI_ClearRectEx(&Rect);
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- void MainTask(void) {
- GUI_Init();
- WM_MULTIBUF_Enable(1);
- WM_SetDesktopColor(GUI_BLACK);
- WM_SetScreenSize(800, 600);
- WM_CreateWindow(240, 180, 320, 240, WM_CF_SHOW, _cbWin, 0);
- WM_MOTION_Enable(1);
- while (1) {
- GUI_Delay(50);
- }
- }
Alex.