Function SendMessage not work

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

  • Function SendMessage not work

    Hello everybody

    i can't use WM_SendMessage() - WM_SendMessageNoPara() - WM_SendToParent() functions. I have this code:

    Source Code

    1. static void _cbDialog(WM_MESSAGE * pMsg)
    2. {
    3. int NCode;
    4. int Id;
    5. .
    6. .
    7. .
    8. case MY_MESSAGE:
    9. __NOP();
    10. break;
    11. }
    12. hMyHandle = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    13. WM_SendMessageNoPara( hMyHandle,MY_MESSAGE);
    Display All


    but I can not get into the branch MY_MESSAGE.
    But to go in there if I can use the function WM_BroadcastMessage()
    I ask for help to solve the problem
    thanks to all
    Andrea
  • Thanks Adrian,

    but I do not undersand. I have this code

    Source Code

    1. static void _cbDialog(WM_MESSAGE * pMsg) {
    2. int NCode;
    3. int Id;
    4. .
    5. .
    6. .
    7. case WM_MY_MESSAGE:
    8. __NOP();
    9. break;
    10. .
    11. .
    12. .
    13. }
    14. void main()
    15. {
    16. hMyhandle = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog,WM_HBKWIN, 0, 0);
    17. mess.MsgId = WM_MY_MESSAGE;
    18. hButtonHandle = WM_GetClientWindow(hButtonHandle);
    19. mess.hWinSrc = hMyhandle;
    20. mess.hWin = hButtonHandle;
    21. WM_SendMessage(hButtonHandle, &mess);
    22. }
    Display All


    Using the breakpoint, i can't log in WM_MY_MESSAGE branch
    thanks for any help
    Andrea
  • Hi Adrian,

    I would like to be able to send a message to a callback when i touch a button. i tried several test. For example, I have 2 file.c
    FILE_1

    Source Code

    1. void _cbDialog_1(WM_MESSAGE * pMsg) {
    2. int NCode;
    3. int Id;
    4. .
    5. .
    6. switch (pMsg->MsgId)
    7. {
    8. case WM_MY_MESSAGE:
    9. __NOP();
    10. break;
    11. .
    12. .
    13. }
    14. WM_HWIN main (void)
    15. {
    16. .
    17. .
    18. hFile1 = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog_1, WM_HBKWIN, 0, 0);
    19. }
    Display All


    FILE_2

    Source Code

    1. void _cbDialog_2(WM_MESSAGE * pMsg)
    2. {
    3. .
    4. .
    5. case ID_BUTTON_2: // Notifications sent by '2'
    6. switch(NCode)
    7. {
    8. case WM_NOTIFICATION_CLICKED:
    9. break;
    10. case WM_NOTIFICATION_RELEASED:
    11. hButton2 = WM_GetDialogItem(hFile2, ID_BUTTON_2);
    12. mess.MsgId = WM_MY_MESSAGE;
    13. mess.hWinSrc = hFile1;
    14. mess.hWin = hButton2 ;
    15. WM_SendMessage(hButton2, &mess);
    16. break;
    17. }
    18. }
    Display All


    the button handle are global variables. When I get to the line WM_SendMessage, I expect to get at the case WM_MY_MESSAGE, but this does not happen. I hope I explained correctly
    thanks Adrian
    Andrea
  • Hello Andrea,

    I can help you implement this in one way. As I try to help you, please do NOT change the way you are going to do that.

    Actually it should be already working if you would have implemented what I told you in my first post according to your first post. Please compare your first 2 posts. You should be able to see what I am trying to tell you.

    Best regards,
    Adrian
  • hi Adrian,

    Thanks, I solved my problem.
    It 's important to use WM_GetClientWindow. But I was not yet clear the difference between WM_GetClientWindow and WM_GetDialogItem().
    I think I have to study a lot more
    Thanks
    Andrea