Physical buttons MUlTIPAGE switch problem

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • 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. :( :( :(
  • 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 Source Code

    1. hMultipage = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0);
    2. hClient = WM_GetFirstChild(hItem);
    3. 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 Source Code

    1. //
    2. // Catch key messages
    3. //
    4. case WM_KEY:
    5. pKeyInfo = (WM_KEY_INFO *)pMsg->Data.p; // Get information about the pressed key
    6. switch (pKeyInfo->Key) {
    7. case GUI_KEY_PGUP: // Page up key
    8. hItem = WM_GetParent(pMsg->hWin); // Get the parent of this dialog, it is the client area of the MULTIPAGE widget
    9. WM_SetFocus(hItem); // Set the focus on it
    10. WM_SendMessage(hItem, pMsg); // And send the message to it
    11. break;
    12. case GUI_KEY_PGDOWN: // Page down key
    13. hItem = WM_GetParent(pMsg->hWin); // Same as above
    14. WM_SetFocus(hItem);
    15. WM_SendMessage(hItem, pMsg);
    16. break;
    17. default:
    18. WM_DefaultProc(pMsg); // Any other keys should be handled by the default callback
    19. break;
    20. }
    21. break;
    Display All


    Regards,
    Sven