简体   繁体   English

无法隐藏 NSIS 卸载程序中的后退按钮

[英]Unable to hide back button in NSIS Uninstaller

I have an uninstaller created in NSIS.我在 NSIS 中创建了一个卸载程序。
It has 3 pages (1 custom page (Confirm), the macro MUI_UNPAGE_INSTFILES and another custom page (Finish)).它有 3 个页面(1 个自定义页面(确认)、宏MUI_UNPAGE_INSTFILES和另一个自定义页面(完成))。

My problem is that I'm unable to hide the 'Back' button in the "INSTFILES" page.我的问题是我无法隐藏“INSTFILES”页面中的“返回”按钮。 I have tried various things to hide it, but it simply stays there in disabled state.我尝试了各种方法来隐藏它,但它只是停留在禁用状态。

This is the code that I'm using to hide the Back button:这是我用来隐藏后退按钮的代码:

GetDlgItem $1 $HWNDPARENT 3
ShowWindow $1 ${SW_HIDE}

Above code works fine for Next and Cancel button when used with ID 1 and 2.当与 ID 1 和 2 一起使用时,上面的代码适用于 Next 和 Cancel 按钮。

I have tried the above code in various places我在各个地方都尝试过上面的代码

  • un.OnInit un.OnInit
  • myGuiInit (custom) myGuiInit(自定义)
  • Page LEAVE callback of confirm page确认页面的页面 LEAVE 回调
  • Page PRE callback of INSTFILES page INSTFILES 页面的页面 PRE 回调
  • Page SHOW callback of INSTFILES page INSTFILES 页面的页面 SHOW 回调

Code:代码:

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.InstShow
UninstPage custom un.UninstConfirm_Show
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.InstShow
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.InstShow
!insertmacro MUI_UNPAGE_INSTFILES
UninstPage custom un.UninstFinish_Show

un.InstShow has the logic to hide the button. un.InstShow具有隐藏按钮的逻辑。

Any help would be appreciated.任何帮助,将不胜感激。 I have spent close to 4-5 hours on this with no luck.我在这上面花了将近 4-5 个小时,但没有运气。
This is how the screen looks now (Note that I have hidden Next and Cancel buttons in the image, to illustrate that hiding those buttons are working fine for me) :这就是屏​​幕现在的样子(请注意,我在图像中隐藏了 Next 和 Cancel 按钮,以说明隐藏这些按钮对我来说效果很好):

在此处输入图片说明

GetDlgItem $1 $HWNDPARENT 3
ShowWindow $1 ${SW_HIDE}

This code is perfectly correct and working fine (tested).这段代码是完全正确的并且工作正常(经过测试)。

I think there is some other code which shows the button again.我认为还有一些其他代码可以再次显示该按钮。

Eg in scenario when you hide the button in LEAVE function of page X, the following page may show the button again.例如,当您在 X 页面的 LEAVE 功能中隐藏按钮时,下一页可能会再次显示该按钮。 This happens often in regular UI.这在常规 UI 中经常发生。

The solution is to check all your custom pages and also the standard pages for any operations regarding this button.解决方案是检查所有自定义页面以及标准页面,以了解有关此按钮的任何操作。

The internal page flag PF_BACK_SHOW in NSIS is set for all pages except the first page, you have to hack your way around it. NSIS 中的内部页面标志 PF_BACK_SHOW 为除第一页之外的所有页面设置,您必须绕过它。

If the InstFiles page is the last page or if you don't want the back button on the pages after then you can move the button:如果 InstFiles 页面是最后一页,或者如果您不想在页面上显示后退按钮,则可以移动该按钮:

Section -un.Main
GetDlgItem $1 $hwndParent 3
System::Call USER32::MoveWindow(pr1,i-9,i-9,i1,i1,i1)
SectionEnd

If you only want to hide it on the InstFiles page but not on the pages after then you must use a timer and call ShowWindow in the timer callback.如果您只想在 InstFiles 页面上隐藏它而不是在之后的页面上隐藏它,那么您必须使用计时器并在计时器回调中调用ShowWindow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM