Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

delphi - How can I make a form that is not disabled when another form is shown modally?

I have a utility dialog (non-modal and stay-on-top) that should be accessible at all times when using the application (think of a dialog that can be used to take notes while working with the application) even if a modal dialog is displayed.

The rest of the application cannot be changed.

Is it possible? How could I go about it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When ShowModal is called, all existing top level windows are disabled. That's how modality is meant to work. If you have a window with which interaction is reasonable, you just need to enable it again.

For example, you could add this to your utility window:

type
  TMyUtilityForm = class(TForm)
  protected
    procedure WMEnable(var Message: TWMEnable); message WM_ENABLE;
  end;
....
procedure TMyUtilityForm.WMEnable(var Message: TWMEnable);
begin
  if not Message.Enabled then
    EnableWindow(Handle, True);
  inherited;
end;

This will make sure that your utility window can never be disabled.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...