- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个现代 WPF 应用程序。我想使用 TaskDialog,但我总是收到常见错误:
TaskDialog feature needs to load version 6 of comctl32.dll but a different version is current loaded in memory.
最佳答案
也许我的解决方案会对您有所帮助。
我的 C#“应用程序”是一个类库/dll,用作 WIX 的 CustomAction。我想要一个 TaskDialog 而不是 MessageBox 但我遇到了和你一样的异常,据我所知, list 文件不适用于 C# 类库。我不得不使用多种方法来让我的代码加载正确版本的 comctl32.dll。
我刚刚让它工作,所以我的代码有点困惑和油腻。
来源:
[Flags]
public enum TaskDialogButtons {
OK = 0x0001,
Cancel = 0x0008,
Yes = 0x0002,
No = 0x0004,
Retry = 0x0010,
Close = 0x0020
}
public enum TaskDialogIcon {
Information = UInt16.MaxValue - 2,
Warning = UInt16.MaxValue,
Stop = UInt16.MaxValue - 1,
Question = 0,
SecurityWarning = UInt16.MaxValue - 5,
SecurityError = UInt16.MaxValue - 6,
SecuritySuccess = UInt16.MaxValue - 7,
SecurityShield = UInt16.MaxValue - 3,
SecurityShieldBlue = UInt16.MaxValue - 4,
SecurityShieldGray = UInt16.MaxValue - 8
}
public enum TaskDialogResult {
None,
OK,
Cancel,
Yes,
No,
Retry,
Close
}
public class StatusDialog {
#region API
[DllImport( "comctl32.dll", CharSet = CharSet.Unicode )]
public static extern int TaskDialog( IntPtr hWndParent, IntPtr hInstance, string pszWindowTitle, string pszMainInstruction, string pszContent, int dwCommonButtons, IntPtr pszIzon, out int pnButton );
#endregion
#region Modal
public static TaskDialogResult Show( IWin32Window owner, string text ) {
return Show( owner, text, null, null, TaskDialogButtons.OK );
}
public static TaskDialogResult Show( IWin32Window owner, string text, string instruction ) {
return Show( owner, text, instruction, null, TaskDialogButtons.OK, 0 );
}
public static TaskDialogResult Show( IWin32Window owner, string text, string instruction, string caption ) {
return Show( owner, text, instruction, caption, TaskDialogButtons.OK, 0 );
}
public static TaskDialogResult Show( IWin32Window owner, string text, string instruction, string caption, TaskDialogButtons buttons ) {
return Show( owner, text, instruction, caption, buttons, 0 );
}
public static TaskDialogResult Show( IWin32Window owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon ) {
return ShowInternal( owner.Handle, text, instruction, caption, buttons, icon );
}
#endregion
#region Non-Modal
public static TaskDialogResult Show( string text ) {
return Show( text, null, null, TaskDialogButtons.OK );
}
public static TaskDialogResult Show( string text, string instruction ) {
return Show( text, instruction, null, TaskDialogButtons.OK, 0 );
}
public static TaskDialogResult Show( string text, string instruction, string caption ) {
return Show( text, instruction, caption, TaskDialogButtons.OK, 0 );
}
public static TaskDialogResult Show( string text, string instruction, string caption, TaskDialogButtons buttons ) {
return Show( text, instruction, caption, buttons, 0 );
}
public static TaskDialogResult Show( string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon ) {
return ShowInternal( IntPtr.Zero, text, instruction, caption, buttons, icon );
}
#endregion
#region Core Implementation
private static TaskDialogResult ShowInternal( IntPtr owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon ) {
int p;
using ( new EnableThemingInScope( true ) ) {
int resss = TaskDialog( owner, IntPtr.Zero, caption, instruction, text, (int) buttons, new IntPtr( (int) icon ), out p );
if ( resss != 0 )
throw new InvalidOperationException( "Something weird has happened." + resss.ToString() );
}
switch ( p ) {
case 1:
return TaskDialogResult.OK;
case 2:
return TaskDialogResult.Cancel;
case 4:
return TaskDialogResult.Retry;
case 6:
return TaskDialogResult.Yes;
case 7:
return TaskDialogResult.No;
case 8:
return TaskDialogResult.Close;
default:
return TaskDialogResult.None;
}
}
#endregion
}
try {
StatusDialog.Show( "About to test this...", "Heading I won't use.", "Dialog Title", TaskDialogButtons.OK );
} catch ( Exception e ) {
MessageBox.Show( e.ToString(), "Error Found", MessageBoxButtons.OK );
}
关于wpf - TaskDialog 需要在版本 6 中触发异常 : comctl32. dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16020136/
编辑: 我已经修复了代码包的源并上传了更新的 NuGet 包: https://www.nuget.org/packages/WindowsAPICodePack-Shell/ 感谢 dmex 修复错
我在 win32 应用程序中使用 TaskDialog API。我创建了一个带有是/否按钮的任务对话框,但我找不到任何选项来将“否”按钮设置为默认值。 YES 按钮始终是默认按钮。如果有办法将“否”按
在我维护的软件中,我计划用 TaskDialog 替换旧的 MessageBox,正如很久以前微软 UI 指南所建议的那样。 我需要解决的主要问题如下: 可以通过按 Esc 键关闭通过 Message
在我维护的软件中,我计划用 TaskDialog 替换旧的 MessageBox,正如很久以前微软 UI 指南所建议的那样。 我需要解决的主要问题如下: 可以通过按 Esc 键关闭通过 Message
我们最近更新了一个内部工具,以使用供应商的在线工具代替我们以前的自制功能。此更新中的一项任务是在用户单击用于执行操作的按钮时将他们重定向到网站。 我想直接在消息框上嵌入一个超链接,因为输入 URL 是
我的 TaskDialog 中的图标丢失了: 在任务栏中: 我的代码是这样的: using Microsoft.WindowsAPICodePack; using Microsoft.WindowsA
有没有办法让 TaskDialog 始终位于顶部(即系统模式)? 我已经检查了 TaskDialogConfig 结构( http://msdn.microsoft.com/en-us/library
我正在开发一个现代 WPF 应用程序。我想使用 TaskDialog,但我总是收到常见错误: TaskDialog feature needs to load version 6 of comctl3
我正在 Delphi 2007 上开发一个 Windows 应用程序,并且在其中使用“Ttaskdialog”组件。使用 Windows XP 它运行正常,但在 Windows 7 中我收到以下消息:
我们有一个较旧的 WPF 应用程序,它使用“Windows API 代码包”来显示任务对话框(在 Vista 中引入的东西,但在 Windows 8 中一直有效)。 我现在尝试在 Windows 10
我注意到我的任务对话框中有一个很大的垂直空间(命令链接的标题和说明文本之间的空间),看起来非常糟糕。它在我将 WindowsAPICodePack 升级到 1.1 版后立即开始出现。 代码如下: Ta
我正在使用以下代码来调用 TaskDialog。 [DllImport("ComCtl32", CharSet = CharSet.Unicode, PreserveSig = false)]
我正在编写一个应用程序并想使用 TaskDialogIndirect函数 - 但是我不想写大量的 P/Invoke 东西等等,所以我已经包含了 WinAPICodePack。不过有一个问题!当我为 T
我是一名优秀的程序员,十分优秀!