lpcware

Problem when sending a message to a Windows

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by rabbi_jaccob on Fri Jan 16 02:19:33 MST 2015
Hello everybody,

In my application on a lpc1768 with FreeRTOS running emwin v5.14, i have a problem to Send Message to a window.

I create the windowd ( a framewin with the GUIBuilder)

In one task, i create the windows like this :
static portTASK_FUNCTION(vGUITask, pvParameters) {

BASE=CreatefrmBase();

while (1) {
//Acquisition de la position
if(xSemaphoreTake(xADCSemMut, portMAX_DELAY)== pdTRUE)
{
GUI_TOUCH_Exec();
xSemaphoreGive(xADCSemMut);
}
GUI_Exec();

vTaskDelay(configTICK_RATE_HZ / 100);
}

vTaskDelete(NULL);


The window is well created. The callback routine is operational for initialisation and for event linked to children widgets.

This is the callback routine :

static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  // USER START (Optionally insert additional variables)
char Ligne[30];
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'frmBase'
    //
    hItem = pMsg->hWin;
    FRAMEWIN_SetText(hItem, "Base");
    //
    // Initialization of 'txtPick'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetText(hItem, "PiC_k :");
    //
    // Initialization of 'txtPicp'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetText(hItem, "PiC_p :");
    //
    // Initialization of 'btnSave'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, "Sauvegarder");
    //
    // Initialization of 'btnLoad'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem, "Charger");
    //
    // Initialization of 'edtPick'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "");
    //
    // Initialization of 'edtPicp'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
    EDIT_SetText(hItem, "");
    // 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_BUTTON_0: // Notifications sent by 'btnSave'
      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;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'btnLoad'
      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;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_0: // Notifications sent by 'edtPick'
      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_VALUE_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;
    case ID_EDIT_1: // Notifications sent by 'edtPicp'
      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_VALUE_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)
case WM_USER :
sprintf(Ligne,"%f",Ram_Coef.PI_C.k);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
EDIT_SetText(hItem,Ligne);
sprintf(Ligne,"%f",Ram_Coef.PI_C.p);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
EDIT_SetText(hItem,Ligne);

  // USER END

  default:
    WM_DefaultProc(pMsg);
    break;
  }
}


I insert a WM-USER message that I try to call in an other task :
//Activation PWM
LPC_MCPWM->CON_SET=0x00000101;
Board_UARTPutSTR("Lancement de la PWM\n");

while (1) {

WM_SendMessageNoPara(BASE,WM_USER);
vTaskDelay(configTICK_RATE_HZ / 100);
}

vTaskDelete(NULL);


In this case, the message is not received by the windows even though BASE is the correct handle of the window.
However when i Broadcast the message it works.

Could everyone send me some clue to solve this problem.

Tank you very much.

Outcomes