Capturing a Key/Slider Event inside While Loop

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

  • Capturing a Key/Slider Event inside While Loop

    Is it possible to capture (or wait for) a Key Event/Slider Event inside a while loop?

    I have created a Window that can play a sound. The window is composed of:
    1. Button - (starts the playing of sound when pressed)
    2. Slider - (changes the volume level when moved)

    When I pressed the Button, it starts playing the sound. The playing of sound is implemented in a while loop.

    ====================================
    code snippet:
    BUTTON PRESSED EVENT:
    while
    {
    PlaySound()
    }
    ====================================


    Inside the while loop, I would like to add a handle that can process the WM_NOTIFICATION_VALUE_CHANGED event whenever I moved the Slider, so that the volume level can be changed.

    Code snippet will be something like this:


    while
    {

    HandleSliderEvent(); //change the volume level
    PlaySound()

    }


    How do I implement this in EMWIN? Is there any EMWIN API I can use to wait for certain key events inside a while loop?


    Regards,
    Den

    The post was edited 2 times, last by dgajudo ().

  • Hello dgajudo,

    I recommend creating a callback function for the parent window of the slider. Then just play the sound, whenever a WM_NOTIFY_PARENT -> WM_NOTIFY_VALUE_CHANGED message is sent. For detailed information please refer to the chapter 15.2 "The Window Manager (WM)" -> "Callback mechanism, ..."

    If you have any further questions, please let me know.

    Best regards,
    Adrian