FRAMEWIN_AddButton

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRAMEWIN_AddButton

874 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ankit.sciter on Mon Feb 08 01:49:51 MST 2016
I can call the FRAMEWIN_AddButton to put a button on the titlebar. The button appears, and I can use the window handle to set text and resize it. I can't seem to figure out what event is triggered by clicking the button. It doesn't seem to fire a notification on it's ID in the FRAMEWIN's _cbDialog.  for that i have used wm_setcallback() to receive events of buttons.i received button event successfully using custom callback function.


     My problem is that framewindow's outer border is gone after using wm_setcallback().please refer my code below:


/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.22                          *
*        Compiled Jul  4 2013, 15:16:01                              *
*        (c) 2013 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_LISTVIEW_0 (GUI_ID_USER + 0x01)


// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { FRAMEWIN_CreateIndirect, "Lawless", ID_FRAMEWIN_0, 0, 80, 160, 400, 0, 0x64, 0 },
  { LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_0, 0, 0, 150, 360, 0, 0x0, 0 },

  // USER START (Optionally insert additional widgets)
  // USER END
};


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

// USER START (Optionally insert additional static code)
// USER END


static void _btncb1(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId)
{
case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;

 

    switch(Id) {
   
case WM_TOUCH: // Notifications sent by 'Listview'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
       
// USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;


    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
}
}

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
WM_HWIN hChild;
  // USER START (Optionally insert additional variables)
  // USER END
printf("\r\n\pMsg->MsgId is:%d\n\r",pMsg->MsgId);
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Lawless'
    //
GUI_SetBkColor(GUI_BLUE);
GUI_Clear();
printf("\r\nInitialization of 'Lawless'\n\r");
    hItem = pMsg->hWin;


FRAMEWIN_SetTitleHeight(hItem, 25);

    
FRAMEWIN_AddButton(hItem,FRAMEWIN_BUTTON_RIGHT,5,GUI_ID_USER + 10);
FRAMEWIN_AddButton(hItem,FRAMEWIN_BUTTON_RIGHT,5,GUI_ID_USER + 11);


//
    // Initialization of 'Listview'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    LISTVIEW_SetHeaderHeight(hItem,0);
LISTVIEW_SetAutoScrollH(hItem, 1);
    LISTVIEW_SetAutoScrollV(hItem, 1);
LISTVIEW_SetTextColor(hItem,LISTVIEW_CI_UNSEL,GUI_BLACK);
LISTVIEW_SetRowHeight(hItem,25);
LISTVIEW_SetColumnWidth(hItem,0,25);
LISTVIEW_SetColumnWidth(hItem,1,100);

LISTVIEW_AddColumn(hItem, 25, "", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 290, "", GUI_TA_HCENTER | GUI_TA_VCENTER);
   
LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
    LISTVIEW_AddRow(hItem, 0);
     LISTVIEW_SetItemText(hItem,1,0,"A");
LISTVIEW_SetItemText(hItem,1,1,"B");
LISTVIEW_SetItemText(hItem,1,2,"C");
  
// USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;

    switch(Id) {
   
case ID_LISTVIEW_0: // Notifications sent by 'Listview'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;


    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}



/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateLawless
*/
WM_HWIN CreateWindow(void);
WM_HWIN CreateWindow(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);



  WM_SetCallback(WM_GetClientWindow(hWin), _btncb1);

while(1){
GUI_Delay(1);

}
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/
Labels (1)
0 Kudos
Reply
0 Replies