1.5k views
in Getting started by
Hello,

How can I programme the slot for the button to close or exit the main UI application? I use the Win32 application for Windows 10

1 Answer

0 votes
by

Hello,

in order to exit a Win32 application Microsoft has provided the API function PostQuitMessage( int aExitCode ). The implementation of your slot method should thus invoke this function. To do this you have to enclose the function invocation within a native block. The following could be the implementation:

$if !$prototyper
  native
  {
    /* Predeclaration of the Win32 API */
    extern void __stdcall PostQuitMessage( int nExitCode );

    /* Invocation of the API */
    PostQuitMessage(0);
  }
$endif

Please note the used $if .. $endif directives to ensure that the native code is not used when you test your application within Embedded Wizard.

Does it answer your question?

Best regards

Paul Banach

by
Thank you, Paul.

Yes, It was helpful.
by
How would one do this same thing with an application running on a raspberry pi? Or even if possible just shutdown the pi safely.
by
On a Raspberry Pi target you will quit the main loop when you press 'p' in the terminal window.

If you want to do similar from your GUI code, you can set a 'C' variable within the native code and evaluate it within the main loop (see file ewmain.c).
by
Hi, could explain better how to do it? I'm using Raspberry Pi 4B and I'm trying to close the GUI using a button
by

Hi,

place a variable into your file ewmain.c, e.g.

int ExitApplication = 0;

In the slot method of your button you can place a native code to set the 'C' variable:

extern int ExitApplication;
ExitApplication = 1;

Within the main loop of the application you can evaluate the 'C' variable and use it as return value for EwProcess(). As a result, the main loop will run until your variable ExitApplication is 1. See also Life Cycle of the GUI Application.

by
Thanks! It worked out for me!

 

Giuseppe

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...