Bring your program to the front desk or background

xiaoxiao2021-03-06  25

This article will show you how to control them and how to control them when you get or lose your screen focus.

Start when the focus changes. The SERIES 60 series of frames will send a notification via Caknappui :: HandleForeGroup, when the program gets or loses the screen focus. When your program gets focus, the parameter AFOREGROUND is ETRUE, and when the focus is lost, it is Efalse.

If you need to do some specific operations, you need to overload this function. This has an example that does not lose focus

Void CMYAPPUI :: HandleForegroundEventl (TBool Areground)

{

// Call Base Class Method

Caknappui :: HandleForegroundEventl (Afeground);

IF (Afeground)

{

// we have gained the focus

...

}

Else

{

// We have lost the focus

...

}

}

Change the focus. You can always request to change the focus of your program Use the command Tapatask :: SendtOBackground () and tapatask :: bringtoforeground (). The following code snippet shows how to use them from AppUI:

Void CMYAPPUI :: bringtoforeground ()

{

// construct en Empty Tapatask Object

// giving it a reason to the window server session

Tapatask Task (ieikonenv-> wssession ());

// Initialise the Object with the window group id of

// out (So That Reperesent Our A)

Task.Setwgid (Ceikonenv :: Static () -> Rootwin (). Identifier ());

// Request Window Server to Bring Our Application

// TO Foreground

Task.bringtoforeground ();

}

I have not tested the following code, but you may have to control other programs using the following code:

// Bring the application "theapp" to background

Tapatasklist Tasklist (Icoeenv-> WSSession ());

Tapatask Task (Tasklist.findApp ")))))))))));

Task.sendtobackground (); // or bringtoforeground ()

转载请注明原文地址:https://www.9cbs.com/read-39759.html

New Post(0)