Tuesday, May 22nd 2018, 3:39pm UTC+2

You are not logged in.

  • Login
  • Register

Date of registration: Apr 6th 2018

Posts: 10

1

Tuesday, May 8th 2018, 10:12am

emwin calendar

Hi
In my parent window when i click a button i open a calendar dialog. i would like to know once i click in someother part of parent window how the calendar dialog can be hidden like under which event i can handle this situation. i tried during WM_PAINT where i am keep checking whether calendar window is visible && has not captured touch && has focus i will disable but its happening once i create the calendar i want to handle this kind of feature when user touches any other place other than widgets in parent window the calendar dialog gets hidden.

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 584

2

Tuesday, May 8th 2018, 10:52am

Hi,

Simply react on WM_TOUCH of the parent window (the dialog in the example below) and delete the calendar.

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "DIALOG.h"

/*********************************************************************
*
*   	Externals
*
**********************************************************************
*/

/*********************************************************************
*
*   	Defines
*
**********************************************************************
*/
#define ID_WINDOW_0     	(GUI_ID_USER + 0x00)
#define ID_BUTTON_0     	(GUI_ID_USER + 0x01)

/*********************************************************************
*
*   	Static data
*
**********************************************************************
*/
/*********************************************************************
*
*   	_aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Calendar", ID_BUTTON_0, 20, 20, 80, 20, 0, 0x0, 0 },
};

/*********************************************************************
*
*   	Static code
*
**********************************************************************
*/

/*********************************************************************
*
*   	_cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int 	NCode;
  int 	Id;

  switch (pMsg->MsgId) {
  case WM_NOTIFY_PARENT:
	Id	= WM_GetId(pMsg->hWinSrc);
	NCode = pMsg->Data.v;
	switch(Id) {
	case ID_BUTTON_0: // Notifications sent by 'Calendar'
  	switch(NCode) {
  	case WM_NOTIFICATION_RELEASED:
    	//
    	// Get CALENDAR handle and check if already opened, if not create a calendar
    	//
    	hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CALENDAR0);
    	if (!hItem) {
      	CALENDAR_Create(pMsg->hWin, 20, 20, 2018, 5, 8, 2, GUI_ID_CALENDAR0, WM_CF_SHOW);
    	}
    	break;
  	}
  	break;
	}
	break;
  case WM_TOUCH:
	//
	// On touch, check if CALENDAR is present, if true delete it
	//
	hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CALENDAR0);
	if (hItem) {
  	WM_DeleteWindow(hItem);
	}
	//
	// Call default handler
	//
	WM_DefaultProc(pMsg);
	break;
  default:
	WM_DefaultProc(pMsg);
	break;
  }
}

/*********************************************************************
*
*   	_cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) {
  switch (pMsg->MsgId) {
  case WM_PAINT:
	GUI_SetBkColor(GUI_DARKGREEN);
	GUI_Clear();
	break;
  default:
	WM_DefaultProc(pMsg);
	break;
  }
}

/*********************************************************************
*
*   	Public code
*
**********************************************************************
*/
/*********************************************************************
*
*   	MainTask
*/
void MainTask(void) {
  GUI_Init();
  WM_SetCallback(WM_HBKWIN, _cbBk);
  GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  while (1) {
	GUI_Delay(100);
  }
}

/*************************** End of file ****************************/


Regards,
Sven

Date of registration: Apr 6th 2018

Posts: 10

3

Tuesday, May 8th 2018, 11:19am

hi
thanks

i tried its getting deleted if i touch on the parent window but if i selecting any date in the calendar that time also its getting deleted.
i would like to delete the calendar once the user click on parent window not when he is selecting any date in the calendar r doing right left scroll to change the month

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 584

4

Tuesday, May 8th 2018, 3:36pm

Hi,

On my end doesn't gets deleted when I select a date.
I can't say why it behaves like this on your side.

Regards,
Sven

Date of registration: Apr 6th 2018

Posts: 10

5

Wednesday, May 9th 2018, 4:25am

Hello Sven,

i am using stemwin5.40. is it related to the lib issue.?

Date of registration: Apr 6th 2018

Posts: 10

6

Wednesday, May 9th 2018, 7:46am

hello sven

also i would like to know about the scroll buttons provided in calendar. as when i press the scroll buttons rarely it changes the months.
how can i manually increment decrement months based on case WM_NOTIFICATION_SCROLL_CHANGED: where i need to identify which scroll button is pressed left or right one.

thanks

Similar threads