Simple MessageBox

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

  • Simple MessageBox

    Hello,
    I just stated getting in touch with EmWin.
    When I create a Messagebox with
    GUI_MessageBox("This text is shown\nin a message box",
    "Caption/Title", GUI_MESSAGEBOX_CF_MOVEABLE);
    how can I control what happens when I hit the OK button? Do I have to set a proper callback funktion? How can I do that?
    In the most simple case, I just want the MessageBox to disappear when I click OK.
    Thank you!
  • Hello,

    The MessageBox disappears when clicking the "Ok" button. If you want to customize it, you will have to use a custom callback function. Please note that the MessageBox is based on a FRAMEWIN widget. You might want to overwrite the callback function of the client window. Please find details on how to do that in the chapter "The Window Manager" in the emWin user manual.

    Best regards,
    Adrian
  • Thank you very much. It worked as soon as I added a Callback Function to WM_HBKWIN processing the WM_PAINT message.

    I have another question:

    Basing on the HBKWIN (which is the parent of all following windows), I create 2 windows:

    WM_HWIN child1, child2;

    Both divide the screen:

    -------------------
    | child 1 |
    -------------------
    | child 2 |
    -------------------

    As far as I understood the documentation, the whole content of a window is described in the callback-Function (case WM_PAINT).
    Examples: Text, Bitmaps ...

    Now I want to create a button in child1.
    Question: How can I "connect" the button to child 1?
    In other words, how does the button know when child1 is inactive?
    I think it makes no sense using BUTTON_CreateEx() in the WM_PAINT section. How can I "refresh" the button when the child1 window is repainted? Should I just call the Callback Function of the button itself out of the child1 Callback function? Or is this done automatically?

    I hope you can understand my question. What is the "usual" way to create a button in a specific window and how is the button refreshed?

    Thank you very much!

    Regards

    Michael

    Edit: When I use functions like GUI_DrawBitmap(). How can I control in which of the windows the bitmap is drawed?

    The post was edited 1 time, last by mfk ().

  • Hello Michael,

    The function BUTTON_CreateEx() takes a parameter "hParent". This parameter allows you to specify the parent window.

    Drawing operations like GUI_DrawBitmap() should be performed within the WM_PAINT event. Events are processed in callback functions and callback functions are associated with a certain window.

    Best regards,
    Adrian
  • Thank you for your reply. I got everything working over the weekend.

    And now I'm starting to see the big advantages of emWin in relation to the time effort necessary to get used to it.

    Regards