How to create a custom parametized widget

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

  • How to create a custom parametized widget

    I need a custom widget. I read "AN03002 Custom Widget Type Creation Guide". Since my custom widgets are made up of several child widgets I used the message WM_CREATE in the callback, as described in "UM03001 User & Reference Guide for emWin V5.40" 18.6.2:
    [img]https://s7.postimg.org/3re220x1n/STem_Win540_WM_CREATE.jpg[/img]

    The problem is that my widget must be parameterized. For example, depending on the value of a parameter my wigdet can have 2 or 4 child widgets.
    How can I pass these parameters to the WM_CREATE message?

    best regards
    Max
  • Hi,

    It is possible to set user data for a window with WM_SetUserData() and receive them with WM_GetUserData(). Unfortunately this user data won't be available when the WM_CREATE message appears.

    In the latest version of emWin (5.44) we have added a message (WM_USER_DATA) which will automatically send to a window and allows the user to react on data. With older version you have to do it on your own with a user message.

    Instead of reacting on WM_CREATE to create the child widgets you can react on the message send after setting the user data. This will allow you to use the parameter in the user data to create the child widgets.

    Attached is an example on how this could be done.

    Regards
    Sven
    Files
    • SetUserData.zip

      (837 Byte, downloaded 338 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.