本文整理汇总了C#中Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog.GetWindowHandle方法的典型用法代码示例。如果您正苦于以下问题:C# CommonOpenFileDialog.GetWindowHandle方法的具体用法?C# CommonOpenFileDialog.GetWindowHandle怎么用?C# CommonOpenFileDialog.GetWindowHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog
的用法示例。
在下文中一共展示了CommonOpenFileDialog.GetWindowHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowFileOpenDialog
public void ShowFileOpenDialog()
{
string[] fileNames;
List<Agent.KeyConstraint> constraints = new List<Agent.KeyConstraint>();
if (mAgent is PageantClient) {
// Client Mode with Pageant - Show standard file dialog since we don't
// need / can't use constraints
using (var openFileDialog = new OpenFileDialog()) {
openFileDialog.Multiselect = true;
openFileDialog.Filter = string.Join ("|",
Strings.filterPuttyPrivateKeyFiles, "*.ppk",
Strings.filterAllFiles, "*.*");
var result = openFileDialog.ShowDialog ();
if (result != DialogResult.OK) {
return;
}
fileNames = openFileDialog.FileNames;
}
} else if (CommonOpenFileDialog.IsPlatformSupported) {
// Windows Vista/7/8 has new style file open dialog that can be extended
// using the Windows API via the WindowsAPICodepack library
var win7OpenFileDialog = new CommonOpenFileDialog ();
win7OpenFileDialog.Multiselect = true;
win7OpenFileDialog.EnsureFileExists = true;
var confirmConstraintCheckBox =
new CommonFileDialogCheckBox (cConfirmConstraintCheckBox,
"Require user confirmation");
var lifetimeConstraintTextBox =
new CommonFileDialogTextBox (cLifetimeConstraintTextBox, string.Empty);
lifetimeConstraintTextBox.Visible = false;
var lifetimeConstraintCheckBox =
new CommonFileDialogCheckBox (cLifetimeConstraintCheckBox,
"Set lifetime (in seconds)");
lifetimeConstraintCheckBox.CheckedChanged +=
delegate(object aSender, EventArgs aEventArgs) {
lifetimeConstraintTextBox.Visible =
lifetimeConstraintCheckBox.IsChecked;
};
var confirmConstraintGroupBox = new CommonFileDialogGroupBox ();
var lifetimeConstraintGroupBox = new CommonFileDialogGroupBox ();
confirmConstraintGroupBox.Items.Add (confirmConstraintCheckBox);
lifetimeConstraintGroupBox.Items.Add (lifetimeConstraintCheckBox);
lifetimeConstraintGroupBox.Items.Add (lifetimeConstraintTextBox);
win7OpenFileDialog.Controls.Add (confirmConstraintGroupBox);
win7OpenFileDialog.Controls.Add (lifetimeConstraintGroupBox);
var filter = new CommonFileDialogFilter (
Strings.filterPuttyPrivateKeyFiles, "*.ppk");
win7OpenFileDialog.Filters.Add (filter);
filter = new CommonFileDialogFilter (Strings.filterAllFiles, "*.*");
win7OpenFileDialog.Filters.Add (filter);
win7OpenFileDialog.FileOk += win7OpenFileDialog_FileOk;
/* add help listeners to win7OpenFileDialog */
// declare variables here so that the GC does not eat them.
WndProcDelegate newWndProc, oldWndProc = null;
win7OpenFileDialog.DialogOpening += (sender, e) =>
{
var hwnd = win7OpenFileDialog.GetWindowHandle();
// hook into WndProc to catch WM_HELP, i.e. user pressed F1
newWndProc = (hWnd, msg, wParam, lParam) =>
{
const short shellHelpCommand = 0x7091;
var win32Msg = (Win32Types.Msg)msg;
switch (win32Msg) {
case Win32Types.Msg.WM_HELP:
var helpInfo = (HELPINFO)Marshal.PtrToStructure(lParam, typeof(HELPINFO));
// Ignore if we are on an unknown control or control 100.
// These are the windows shell control. The help command is
// issued by these controls so by not ignoring, we would call
// the help method twice.
if (helpInfo.iCtrlId != 0 && helpInfo.iCtrlId != 100)
OnAddFromFileHelpRequested(win7OpenFileDialog, EventArgs.Empty);
return (IntPtr)1; // TRUE
case Win32Types.Msg.WM_COMMAND:
var wParamBytes = BitConverter.GetBytes(wParam.ToInt32());
var highWord = BitConverter.ToInt16(wParamBytes, 0);
var lowWord = BitConverter.ToInt16(wParamBytes, 2);
if (lowWord == 0 && highWord == shellHelpCommand) {
OnAddFromFileHelpRequested(win7OpenFileDialog, EventArgs.Empty);
return (IntPtr)0;
}
break;
}
return CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam);
};
var newWndProcPtr = Marshal.GetFunctionPointerForDelegate(newWndProc);
var oldWndProcPtr = SetWindowLongPtr(hwnd, WindowLongFlags.GWL_WNDPROC, newWndProcPtr);
oldWndProc = (WndProcDelegate)
//.........这里部分代码省略.........