RAD Studio [Possible solution] for that MODELESS WINDOW cannot stay "LOST" (in background) under the MAIN application WINDOW!

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,438
Credits
573
[Possible solution] for that MODELESS WINDOW cannot stay "LOST" (in background) under the MAIN application WINDOW!
[SHOWTOGROUPS=4,20]
Morrison;
How to do this so that the modeless window cannot be "lost" under the main application window?
  • When a windows stay under main-window if you change of application or any other cause in yourself app (like a long process to show some on screen)
  • I dont want use ALT+TAB or similar to go back to it
  • My app is in "critical process" and my message windows "disappears" - it is under my main window on the screen!


Possible solutions:

Solution 1:
//*******************************************************************************
Radek:
Код:
TSuggestControl procedure . CreateParams ( var Params : TCreateParams ) ;
begin
  inherited CreateParams ( Params ) ;
  Params.WindowClass.Style  : = Params.WindowClass.Style  or  ( CS_VREDRAW + CS_HREDRAW ) ;
  with Params do
  begin
    // Style: = WS_THICKFRAME OR WS_POPUP or Style;
    ExStyle : =  {WS_EX_TOOLWINDOW or} WS_EX_TOPMOST ;
  end ;
end ;

Morrison:
Thanks, WS_EX_TOPMOST works. I apologize for the useless question. I don't know how I figured it out, but I thought that when the form is set to FormStyle: = fsStayOnTop, then it's above all other windows of other applications. However, fsStayOnTop seems to be only within my application.

Radek:
I also think that fsStayOnTop which is transformed to HWND_TOPMOST according to the source is above all windows (or used to be), so WS_EX_TOPMOST, but I didn't bother much.

Morrison:
Maybe it's changed in Windows 10. I would also just say that previously fsStayOnTop was above all other windows. Unfortunately, I don't have an older Windows right now to try it out.

Geby:
NOTE: see Для просмотра ссылки Войди или Зарегистрируйся

Radek:
Because until now I thought that it only applies to modal windows, but according to the description it could also work on non-modal

JDB:
Lately, it has become more and more common for me to hide the modal dialog behind the main form, then it is "modally hidden" and the main one is inactive ...
Sometimes even the login window hides behind the split logo. It most often happens on Win Server 2008 in the terminal, but I've already solved it on Win10.
While searching the web, I only came across a forum where there was no solution - windows error. Would anyone have an idea how to restore the display of a modal window?



Solution 2:
//*******************************************************************************
Karel:
We've had this in our programs for years, and since then no one has complained about the modal window in the background (but even before that it was rare):

Код:
procedure DisableProcessWindowsGhosting ;
var
  DisableProcessWindowsGhostingProc :  procedure ;
begin
  DisableProcessWindowsGhostingProc : = GetProcAddress(GetModuleHandle ( 'user32.dll' ), 'DisableProcessWindowsGhosting' ) ;
  if  Assigned ( DisableProcessWindowsGhostingProc )  then  begin
    DisableProcessWindowsGhostingProc ;
  end ;
end ;

This is called from the Create main application window.

[/SHOWTOGROUPS]
 
Последнее редактирование: