Hello.
I would like to understand if there is the strange behaviour of SPINBOX or I do something wrong.
In attachment - source code (on base of demo-code of SPINBOX-widget).
I have added a BUTTON (id GUI_ID_BUTTON0) for disable/enable SPINBOX-widget (id GUI_ID_SPINBOX2) by its cklicking.
But If you run this sample you will see, that the state disable/enable of this SPINBOX-widget is changed by cklicking on every widget, even from itself.
The code of enable/disable by pressing BUTTON starts from line 39.
And this code gets entry by pressing of ALL widgets, not only by BUTTON with id GUI_ID_BUTTON0.
And why if I click right arrow of SPINBOX with id GUI_ID_SPINBOX2 it starts increasing continuously?
Display All
I would like to understand if there is the strange behaviour of SPINBOX or I do something wrong.
In attachment - source code (on base of demo-code of SPINBOX-widget).
I have added a BUTTON (id GUI_ID_BUTTON0) for disable/enable SPINBOX-widget (id GUI_ID_SPINBOX2) by its cklicking.
But If you run this sample you will see, that the state disable/enable of this SPINBOX-widget is changed by cklicking on every widget, even from itself.
The code of enable/disable by pressing BUTTON starts from line 39.
And this code gets entry by pressing of ALL widgets, not only by BUTTON with id GUI_ID_BUTTON0.
And why if I click right arrow of SPINBOX with id GUI_ID_SPINBOX2 it starts increasing continuously?
C Source Code
- #include "GUI.h"
- #include "DIALOG.h"
- static const GUI_WIDGET_CREATE_INFO _aDialogSpinbox[] = {
- { FRAMEWIN_CreateIndirect, "Spinbox", 0, 0, 0, 320, 240, 0, 0, 0 },
- { SPINBOX_CreateIndirect, NULL, GUI_ID_SPINBOX0, 10, 15, 60, 21, 0, 0, 0 },
- { SPINBOX_CreateIndirect, NULL, GUI_ID_SPINBOX1, 10, 42, 60, 21, 0, 0, 0 },
- { SPINBOX_CreateIndirect, NULL, GUI_ID_SPINBOX2, 10, 75, 220, 80, 0, 0, 0 },
- { BUTTON_CreateIndirect, "Click", GUI_ID_BUTTON0, 10, 170, 80, 24, 0, 0, 0 },
- };
- static void _cb(WM_MESSAGE * pMsg) {
- EDIT_Handle hEdit;
- WM_HWIN hItem;
- int Value;
- int NCode;
- int Id;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX0);
- hEdit = SPINBOX_GetEditHandle(hItem);
- EDIT_SetDecMode(hEdit, 1, 1, 10, 0, 0);
- hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX1);
- hEdit = SPINBOX_GetEditHandle(hItem);
- EDIT_SetDecMode(hEdit, 1, 0, 99999, 0, 0);
- hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX2);
- SPINBOX_SetEdge(hItem, SPINBOX_EDGE_CENTER);
- SPINBOX_SetEditMode(hItem, SPINBOX_EM_EDIT);
- SPINBOX_SetRange(hItem, 0, 99999);
- break;
- case WM_NOTIFY_PARENT:
- NCode = pMsg->Data.v;
- Id = WM_GetId(pMsg->hWinSrc);
- switch (NCode) {
- case WM_NOTIFICATION_CLICKED:
- if (Id = GUI_ID_BUTTON0) {
- hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX2);
- WM_SetEnableState(hItem, !WM_IsEnabled(hItem));
- }
- break;
- case WM_NOTIFICATION_VALUE_CHANGED:
- if (Id == GUI_ID_SPINBOX0) {
- Value = SPINBOX_GetValue(pMsg->hWinSrc);
- hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX1);
- SPINBOX_SetStep(hItem, Value);
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- }
- }
- void MainTask(void) {
- GUI_Init();
- GUI_CreateDialogBox(_aDialogSpinbox, GUI_COUNTOF(_aDialogSpinbox), _cb, WM_HBKWIN, 30, 30);
- while (1) {
- GUI_Delay(100);
- }
- }
Best regards,
Volodymyr.
Volodymyr.