Home > Back-end >  How do I get application gained or lost focus event.
How do I get application gained or lost focus event.

Time:10-05

Is the entire application, not a certain form, because the entire program has multiple forms, in the form to switch focus were still in the application.

CodePudding user response:

Application no focus said today (Monday)? Focus is on the window, what do you want to achieve?

CodePudding user response:

reference 1st floor ccrun response:
application no focus on say? Focus is on the window, what do you want to achieve?


I in order to ensure that the program of some form of sequence, so some of the forms are fsStayOnTop program, but must focus on the switch to other application fsNormal instead, or it will block other applications, set back when switching to this application.



CodePudding user response:

refer to the second floor hyz_cs response:
Quote: refer to 1st floor ccrun response:

Application no focus said today (Monday)? Focus is on the window, what do you want to achieve?


I in order to ensure that the program of some form of sequence, so some of the forms are fsStayOnTop program, but must focus on the switch to other application fsNormal instead, or it will block other applications, set back when switching to this application.





This requirement, dispatch form to immediately cancel after top fsStayOnTop properties, can?

CodePudding user response:

reference KFRGHT reply: 3/f
Quote: refer to the second floor hyz_cs response:

Quote: refer to 1st floor ccrun response:

Application no focus said today (Monday)? Focus is on the window, what do you want to achieve?


I in order to ensure that the program of some form of sequence, so some of the forms are fsStayOnTop program, but must focus on the switch to other application fsNormal instead, or it will block other applications, set back when switching to this application.



This requirement, dispatch form to immediately cancel after top fsStayOnTop properties, can?


Should be ok, because there are multiple Windows need to set up fsStayOnTop, between them may switch from each other. And there are more serious problems, such as when switching over from other applications, events, also should have access to set back in fsStayOnTop.

CodePudding user response:

The effect of the roughly

CodePudding user response:

His top.

CodePudding user response:

Don't put the window is placed at the top in your application, you can model window is used to achieve the effect you want,

CodePudding user response:

refer to 7th floor zzbinfo response:
don't put the top window in your application, you can model window is used to achieve the effect you want,


To be placed at the top is not a window, like that in figure 3, video, images, a weather a (actual situation may be arbitrary, so the way you said can't solve the problem). Under the three window is the window shows the mode of the window.

CodePudding user response:

This problem I encountered in a project, then use a code like this:

 
//form temporary will be dispatched to the front of usage:

Void __fastcall TForm1: : FormCreate (TObject * Sender)
{
If (FormStyle!=fsStayOnTop)
{
TFormStyle TFormStyle=FormStyle;//before you begin to remember the original Settings
FormStyle=fsStayOnTop;//let the window is always in the front (transferred to the front, would have been effective, after may cause model form the pop-up interface in the case of suspected lock)
FormStyle=tFormStyle;//restore original Settings
}
}

CodePudding user response:

If the form itself is fsStayOnTop, then Application - & gt; BringToFront ();//the application in the activated state and has the focus

 
Void __fastcall TForm1: : FormCreate (TObject * Sender)
{
If (FormStyle!=fsStayOnTop)
{
TFormStyle TFormStyle=FormStyle;//before you begin to remember the original Settings
FormStyle=fsStayOnTop;//let the window is always in the front (transferred to the front, would have been effective, after may cause model form the pop-up interface in the case of suspected lock)
FormStyle=tFormStyle;//restore original Settings
} else {
Application - & gt; BringToFront ();//the application in the activated state and has the focus
}
}


The complete code, you test the watch is not working

The key point is to make the final total window displayed on the front, at the same time does not affect the other later window display

CodePudding user response:

Written Application - & gt; OnActivate and Application - & gt; OnDeactivate event handling,

CodePudding user response:

The
references to the tenth floor KFRGHT response:
if the form itself is fsStayOnTop, so Application - & gt; BringToFront ();//the application in the activated state and has the focus


Not all Windows are fsStayOnTop, only part of the window.

CodePudding user response:

The
refer to 12 floor hyz_cs reply:
Quote: reference to the tenth floor KFRGHT response:

If the form itself is fsStayOnTop, then Application - & gt; BringToFront ();//the application in the activated state and has the focus


Not all Windows are fsStayOnTop, is only part of the window.


So my code inside record form of the original state, after the completion of the reduction:

TFormStyle TFormStyle=FormStyle;//before you begin to remember the original Settings
FormStyle=fsStayOnTop;//let the window always in front of the
FormStyle=tFormStyle;//restore original Settings

CodePudding user response:

My forehead code in FormActivate event may be better

CodePudding user response:

On the 14th floor KFRGHT
reference response:
my forehead code in FormActivate events might be better


This just guarantee window always on top, such as users switch to the other software, this software is blocked the other software, or return to the theme of this post.

CodePudding user response:

Three Windows of the building Lord are modal displayed?
Can you make a simple example code, send mail me I help you see, indicating your version of development tools and operating system version,

CodePudding user response:

reference 16 floor ccrun response:
three Windows of the building Lord are modal displayed?
Can you make a simple example code, send mail me I help you see, indicating your version of development tools and operating system version,


Not, that three window is the window of the ordinary, just set to fsStayOnTop. Now to do is, if users to switch to other software, the three window cannot be fsStayOnTop, because it will block other software, so I want to at the time of user switching software dynamic Settings fsStayOnTop and fsNormal.

CodePudding user response:

Can iterate over all his program in your spare time window, check whether there is your window, but the slope time-consuming, or start from every form has its own idealnullnullnull
  • Related