Saturday, December 16th 2017, 4:32am UTC+1

You are not logged in.

  • Login
  • Register

Reply

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Message information
Message
Settings
Automatically converts internet addresses into links by adding [url] and [/url] around them.
Smiley code in your message such as :) is automatically displayed as image.
You can use BBCode to format your message, if this option is enabled.
Security measure

Please enter the letters that are shown in the picture below (without spaces, and upper or lower case can be used).

The last 3 posts

Thursday, December 7th 2017, 10:47am

by kenmux

Thanks for your reply, Sven
Okay, I see.
This is not the same as handling a key message, right?
A key message will be posted to the focused window.
If it is not handled by the focused window, it will be posted to its parent.

Thursday, December 7th 2017, 10:21am

by SEGGER - Schoenen

Hi,

Do I get you right that you expect that a message which is not handled by a child should be passed to its parent?

but this is not the case. If you send a message to a specific window, only that single window will receive the message. If you want that the parent react on a non-handled message you have to manually pass it to the parent.

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
#include "DIALOG.h"

/*********************************************************************
*
*   	_cbText
*/
static void _cbText(WM_MESSAGE * pMsg) {
  switch (pMsg->MsgId) {
  case 1100:
	//
	// Do something
	//
	WM_SendMessageNoPara(WM_GetParent(pMsg->hWin), 1100);  // Send message to the parent
	break;
  default:
	TEXT_Callback(pMsg);
	break;
  }
}

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

/*********************************************************************
*
*   	Public code
*
**********************************************************************
*/
/*********************************************************************
*
*   	MainTask
*/
void MainTask(void) {
  WM_HWIN hWin;
  WM_HWIN hText;
  int 	xSize;
  int 	ySize;

  GUI_Init();
  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  hWin  = WM_CreateWindow(0, 0, xSize, ySize, WM_CF_SHOW, _cbParent, 0);
  hText = TEXT_CreateEx(20, 20, 80, 20, hWin, WM_CF_SHOW, 0, GUI_ID_TEXT0, "Text");
  WM_SetCallback(hText, _cbText);
  GUI_Delay(50);
  WM_SendMessageNoPara(hText, 1100);  // Send message to the TEXT widget
  while (1) {
	GUI_Delay(100);
  }
}


Regards
Sven

Thursday, December 7th 2017, 7:51am

by kenmux

Message cannot be posted from child to parent via default callback?

Hello all,

In my opinion, the message will be posted from child to parent via default callback.
Is it right? To make it clear, I wrote the test code as followed:

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
static TEXT_Handle _hText;
static WM_HWIN     _hDialog;

static void _cbText(WM_MESSAGE * pMsg) {
  /* Handle the message(s) needed */
  switch (pMsg->MsgId) {
  case 1100:
    printf("TXT::1100\n");
    break;  //no return here ... let parent do something
  }

  /* Default message handler */
  TEXT_Callback(pMsg);
}

static void _cbDialog(WM_MESSAGE * pMsg) {
  /* Handle the message(s) needed */
  switch (pMsg->MsgId) {
  case 1100:
    printf("DLG::1100\n");
    return;
  }

  /* Default message handler */
  WM_DefaultProc(pMsg);
}

void Test(void) {
  WM_HWIN hClient = WM_GetClientWindow(_hDialog);
    
  _hText = TEXT_CreateEx(0, 0, 80, 40, hClient, WM_CF_SHOW, 0x0, GUI_ID_TEXT0, 0);
  WM_SetCallback(_hText, _cbText);
  GUI_Delay(50);

  WM_SendMessageNoPara(_hText, 1100);
}


The test result is, the message cannot be posted from child to parent via default callback?!!
Did I do something wrong? If not, then some strange issues in my project do make sense...
My emWin version is: v5.44b

Thanks,
Kenmux