Thursday, April 19th 2018, 3:49pm UTC+2

You are not logged in.

  • Login
  • Register

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.

zhouxinjie1

Beginner

Date of registration: Jun 14th 2016

Posts: 1

1

Wednesday, June 15th 2016, 4:36am

Physical buttons MUlTIPAGE switch problem

/////////////////////// ver5.22/////////////////////////////
case GUI_KEY_UP: /*方向上*/
GUI_SendKeyMsg(GUI_KEY_UP, 1);
break;

case GUI_KEY_DOWN: /*方向下*/
GUI_SendKeyMsg(GUI_KEY_DOWN, 1);
break;

case GUI_KEY_LEFT: /*方向左*/
GUI_SendKeyMsg(GUI_KEY_LEFT, 1);
break;

case GUI_KEY_RIGHT: /*方向右*/
GUI_SendKeyMsg(GUI_KEY_RIGHT, 1);
break;

case GUI_KEY_PGUP: /*+*/
if(KeyPageSt==0)
GUI_SendKeyMsg(GUI_KEY_PGUP, 0);//
else
GUI_SendKeyMsg(GUI_KEY_PGUP, 1);
break;
case GUI_KEY_PGDOWN: /*-*/
if(KeyPageSt==0)
GUI_SendKeyMsg(GUI_KEY_PGDOWN, 0);
else
GUI_SendKeyMsg(GUI_KEY_PGDOWN, 1);
break;
////////////////////////////////////////////////////////

static const GUI_WIDGET_CREATE_INFO _aYXDialogCreate[] = {
{ FRAMEWIN_CreateIndirect,"",ID_FRAMEWIN_0, 0, 0, 320, 240,0,0},
{ MULTIPAGE_CreateIndirect, "Multipage", ID_MULTIPAGE_0, 0, 2, 314, 204, 0, 0x0, 0 },
};
static const GUI_WIDGET_CREATE_INFO _aYX_1_DialogCreate[] = {
{ WINDOW_CreateIndirect, "P1", ID_WINDOW_0, 0, 80, 310, 180, 0, 0x0, 0 },
{ LISTVIEW_CreateIndirect, "Listview1", ID_LISTVIEW_0, 0, 0, 310, 175, 0, 0x0, 0 },
};
static const GUI_WIDGET_CREATE_INFO _aYX_2_DialogCreate[] = {
{ WINDOW_CreateIndirect, "P2", ID_WINDOW_1, 0, 80, 310, 180, 0, 0x0, 0 },
{ LISTVIEW_CreateIndirect, "Listview2", ID_LISTVIEW_1, 0, 0, 310, 175, 0, 0x0, 0 },
};
static const GUI_WIDGET_CREATE_INFO _aYX_3_DialogCreate[] = {
{ WINDOW_CreateIndirect, "P3", ID_WINDOW_2, 0, 80, 310, 180, 0, 0x0, 0 },
{ LISTVIEW_CreateIndirect, "Listview3", ID_LISTVIEW_2, 0, 0, 310, 175, 0, 0x0, 0 },
};
static const GUI_WIDGET_CREATE_INFO _aYX_4_DialogCreate[] = {
{ WINDOW_CreateIndirect, "P4", ID_WINDOW_3, 0, 80, 310, 180, 0, 0x0, 0 },
{ LISTVIEW_CreateIndirect, "Listview4", ID_LISTVIEW_3, 0, 0, 310, 175, 0, 0x0, 0 },
};

////////////////////////////////////////////////////////

Q1:FRAMEWIN->P1->LISTVIEW
->P2->LISTVIEW
->P3->LISTVIEW
->P4->LISTVIEW
Focus always in LISTVIEW when the window is open, not in MULTIPAGE, change the focus setting has no effect, PAUP / PADOWN button does not respond to page switch (focus in listview ),
I can only send GUI_SendKeyMsg (GUI_KEY_PGUP, 0) message to the parent window, by manually change MULTIPAGE_SelectPage to switch.

Q2:MULTIPAGE after switching found, the window has been switched, the focus and message response is still in P1‘callbackfun, When I chose P2 to exit the window and open it again, focus in P2,but the message response is still in P1.
What can I do. :( :( :(

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 558

2

Tuesday, July 5th 2016, 9:43am

Hi,

this is a bit tricky.

A MULTIPAGE widget consists of two windows. One is the tab and another window for the client area. If you call WM_Focus(hMultipage) the tab of the MULTIPAGE widget has the focus. But, since the client of a MULTIPAGE widget handels the key messages, you have to get the first child of the MULTIPAGE widget and then set the focus on it.

The following code shows how to get the proper window handle:

C/C++ Source code

1
2
3
hMultipage = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0);
hClient	= WM_GetFirstChild(hItem);
WM_SetFocus(hClient);


Unfortunately, after switching the tab, the focus changes again. If you want to react on GUI_KEY_PGUP and GUI_KEY_PGDOWN you have to catch these messages and send them further to the client area of the MULTIPAGE widget.

Try the following in the callback function of one of your dialogs attached to a MULTIPAGE widget page.

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
  //
  // Catch key messages
  //
  case WM_KEY:
	pKeyInfo = (WM_KEY_INFO *)pMsg->Data.p;  // Get information about the pressed key
	switch (pKeyInfo->Key) {
	case GUI_KEY_PGUP:                   	// Page up key
  	hItem = WM_GetParent(pMsg->hWin);  	// Get the parent of this dialog, it is the client area of the MULTIPAGE widget
  	WM_SetFocus(hItem);                	// Set the focus on it
  	WM_SendMessage(hItem, pMsg);       	// And send the message to it
  	break;
	case GUI_KEY_PGDOWN:                 	// Page down key
  	hItem = WM_GetParent(pMsg->hWin);  	// Same as above
  	WM_SetFocus(hItem);
  	WM_SendMessage(hItem, pMsg);
  	break;
	default:
  	WM_DefaultProc(pMsg);              	// Any other keys should be handled by the default callback
  	break;
	}
	break;


Regards,
Sven