如何正确还原FMX表单? [英] How to properly restore an FMX form?

查看:97
本文介绍了如何正确还原FMX表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用菜单栏按钮最小化FMX表单,然后通过单击任务栏图标进行还原,将使该表单回到前台,但不会激活该窗口.还直接"最小化了表单,而是应用了将窗口缩小"到任务栏的动画.表单OnActivate事件不会被触发.

Minimizing an FMX form with the menu bar button and then restoring by clicking on the task bar icon will bring the form back to the foreground, but will not activate the window. The form is also minimized "directly" rather applying the animation that "shrinks" the window to the taskbar. The forms OnActivate event is not fired.

奇怪的是,如果我在不激活时修补WindowProc并用SW_RESTORE调用ShowWindow,则单击任务栏图标后,表单将正确还原.我不知道为什么.最小化动画仍然不会被触发.

Curiously, if I patch the WindowProc and call ShowWindow with SW_RESTORE upon deactivation the form will get restored properly after clicking the taskbar icon. I'm not sure why. The minimize animation still does not get fired though.

procedure TForm1.WindowProc(var Msg: TMessage);
begin
  case Msg.Msg of
    WM_ACTIVATE: if (Msg.WParamLo = WA_INACTIVE) then ShowWindow(WindowHandleToPlatform(Handle).Wnd, SW_RESTORE);
  end;
  Msg.Result := CallWindowProc(OrgWndProc, WindowHandleToPlatform(Handle).Wnd, Msg.Msg, Msg.WParam, Msg.LParam);
end;

我可以在Windows 8上使用空白的FMX HD表单来观察此行为.这对我来说似乎是个明显的错误,是否有更好的解决方法?

I can observe this behavior with a blank FMX HD form on Windows 8. This seems like an obvious bug to me, is there a better way to work around it ?

推荐答案

我认为我是通过修改 FMX.Platform.Win.pas 文件来解决此问题的.在 TPlatformWin.CreateAppHandle 方法中,您需要注释(或删除)这些行:

I think I got around this by modifying the FMX.Platform.Win.pas file. In the TPlatformWin.CreateAppHandle method you need to comment (or remove) those lines:

FApplicationHWND := CreateWindowEx(WS_EX_WINDOWEDGE or WS_EX_APPWINDOW, FMAppClass.lpszClassName,
  PChar(LApplicationTitle), WS_POPUP or WS_GROUP, 0, 0, 0, 0, GetDesktopWindow, 0, HInstance, nil);
Winapi.Windows.ShowWindow(FApplicationHWND, SW_SHOWNORMAL);

我认为该解决方案来自Embarcadero论坛.该消息不见了,但是无论如何我都会给您链接,以防它回来: https://forums.codegear.com/thread.jspa?messageID=556541&#556541

I think that solution came from the Embarcadero Discussion Forums. The message is gone, but I give you the link anyway in case it comes back: https://forums.codegear.com/thread.jspa?messageID=556541&#556541

这篇关于如何正确还原FMX表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆