Skip to content

File dialog controls #7256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Compat issues with assembly PresentationFramework:
CannotMakeMemberNonVirtual : Member 'public System.Boolean Microsoft.Win32.FileDialog.CheckFileExists' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'public System.Boolean Microsoft.Win32.FileDialog.CheckFileExists.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'public void Microsoft.Win32.FileDialog.CheckFileExists.set(System.Boolean)' is non-virtual in the implementation but is virtual in the contract.
MembersMustExist : Member 'internal MS.Internal.AppModel.IFileDialog Microsoft.Win32.FileDialog.CreateVistaDialog()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'protected System.Int32 Microsoft.Win32.FileDialog.Options.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'internal System.String[] Microsoft.Win32.FileDialog.ProcessVistaFiles(MS.Internal.AppModel.IFileDialog)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'internal System.Boolean Microsoft.Win32.FileDialog.RunFileDialog(MS.Win32.NativeMethods.OPENFILENAME_I)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.AttachedPropertyBrowsableForChildrenAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
Compat issues with assembly PresentationFramework:
MembersMustExist : Member 'internal MS.Internal.AppModel.IFileDialog Microsoft.Win32.FileDialog.CreateVistaDialog()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'internal System.String[] Microsoft.Win32.FileDialog.ProcessVistaFiles(MS.Internal.AppModel.IFileDialog)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'internal System.Boolean Microsoft.Win32.FileDialog.RunFileDialog(MS.Win32.NativeMethods.OPENFILENAME_I)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected MS.Internal.AppModel.IFileDialog Microsoft.Win32.CommonItemDialog.CreateDialog()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected System.String[] Microsoft.Win32.FileDialog.ProcessFiles(MS.Internal.AppModel.IFileDialog)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected void Microsoft.Win32.FileDialogControl.RealizeInto(MS.Internal.AppModel.IFileDialogCustomize)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected void Microsoft.Win32.Controls.FileDialogControl.LockAndAttachInternal(MS.Internal.AppModel.IFileDialogCustomize)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected MS.Internal.Interop.CDCS Microsoft.Win32.Controls.FileDialogControlBase.GetState()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected void Microsoft.Win32.Controls.FileDialogControlBase.SetState(MS.Internal.Interop.CDCS)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected Microsoft.Win32.Controls.FileDialogItemsControl Microsoft.Win32.Controls.FileDialogItemsControl.CloneContainer()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'private protected void Microsoft.Win32.Controls.FileDialogItemsControl.LockAndAttachContainer(MS.Internal.AppModel.IFileDialogCustomize)' does not exist in the implementation but it does exist in the contract.
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.ComponentModel.DesignerProperties.GetIsInDesignMode(System.Windows.DependencyObject)' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'System.Windows.AttachedPropertyBrowsableForChildrenAttribute' changed from '[AttributeUsageAttribute(64, AllowMultiple=false)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple=false)]' in the implementation.
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.DataTemplate.Triggers' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ internal static class IID
public const string EnumObjects = "2c1c7e2e-2d0e-4059-831e-1e6f82335c2e";
/// <summary>IID_IFileDialog</summary>
public const string FileDialog = "42f85136-db7e-439c-85f1-e4075d135fc8";
/// <summary>IID_IFileDialog2</summary>
public const string FileDialog2 = "61744fc7-85b5-4791-a9b0-272276309b13";
/// <summary>IID_IFileDialogControlEvents</summary>
public const string FileDialogControlEvents = "36116642-D713-4B97-9B83-7484A9D00433";
/// <summary>IID_IFileDialogCustomize</summary>
public const string FileDialogCustomize = "E6FDD21A-163F-4975-9C8C-A69F1BA37034";
/// <summary>IID_IFileDialogEvents</summary>
public const string FileDialogEvents = "973510DB-7D7F-452B-8975-74A85828D354";
/// <summary>IID_IFileOpenDialog</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,65 @@ internal interface IShellLinkW
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}

[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid(IID.FileDialogCustomize),
]
internal interface IFileDialogCustomize
{
void EnableOpenDropDown(int dwIDCtl);
void AddMenu(int dwIDCtl, [MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
void AddPushButton(int dwIDCtl, [In, MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
void AddComboBox(int dwIDCtl);
void AddRadioButtonList(int dwIDCtl);
void AddCheckButton(int dwIDCtl, [MarshalAs(UnmanagedType.LPWStr)] string pszLabel, bool bChecked);
void AddEditBox(int dwIDCtl, [MarshalAs(UnmanagedType.LPWStr)] string pszText);
void AddSeparator(int dwIDCtl);
void AddText(int dwIDCtl, [MarshalAs(UnmanagedType.LPWStr)] string pszText);
void SetControlLabel(int dwIDCtl, [MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
CDCS GetControlState(int dwIDCtl);
void SetControlState(int dwIDCtl, CDCS dwState);
[return:MarshalAs(UnmanagedType.LPWStr)]
string GetEditBoxText(int dwIDCtl);
void SetEditBoxText(int dwIDCtl, [MarshalAs(UnmanagedType.LPWStr)] string pszText);
[return:MarshalAs(UnmanagedType.Bool)]
bool GetCheckButtonState(int dwIDCtl);
void SetCheckButtonState(int dwIDCtl, bool bChecked);
void AddControlItem(int dwIDCtl, int dwIDItem, [MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
void RemoveControlItem(int dwIDCtl, int dwIDItem);
void RemoveAllControlItems(int dwIDCtl);
CDCS GetControlItemState(int dwIDCtl, int dwIDItem);
void SetControlItemState(int dwIDCtl, int dwIDItem, CDCS dwState);
[PreserveSig]
HRESULT GetSelectedControlItem(int dwIDCtl, out int dwIDItem);
void SetSelectedControlItem(int dwIDCtl, int dwIDItem);
void StartVisualGroup(int dwIDCtl, [MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
void EndVisualGroup();
void MakeProminent(int dwIDCtl);
void SetControlItemText(int dwIDCtl, int dwIDItem, [MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
}

[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid(IID.FileDialogControlEvents),
]
internal interface IFileDialogControlEvents
{
[PreserveSig]
HRESULT OnItemSelected(IFileDialogCustomize pfdc, int dwIDCtl, int dwIDItem);

[PreserveSig]
HRESULT OnButtonClicked(IFileDialogCustomize pfdc, int dwIDCtl);

[PreserveSig]
HRESULT OnCheckButtonToggled(IFileDialogCustomize pfdc, int dwIDCtl, bool bChecked);

[PreserveSig]
HRESULT OnControlActivating(IFileDialogCustomize pfdc, int dwIDCtl);
}

[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Expand Down Expand Up @@ -479,6 +538,73 @@ internal interface IFileDialog : IModalWindow
void SetFilter([MarshalAs(UnmanagedType.Interface)] object pFilter);
}

[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid(IID.FileDialog2),
]
internal interface IFileDialog2 : IFileDialog
{
#region IFileDialog redeclarations
#region IModalWindow redeclarations
[PreserveSig]
new HRESULT Show(IntPtr parent);
#endregion

new void SetFileTypes(uint cFileTypes, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] COMDLG_FILTERSPEC[] rgFilterSpec);

new void SetFileTypeIndex(uint iFileType);

new uint GetFileTypeIndex();

new uint Advise(IFileDialogEvents pfde);

new void Unadvise(uint dwCookie);

new void SetOptions(FOS fos);

new FOS GetOptions();

new void SetDefaultFolder(IShellItem psi);

new void SetFolder(IShellItem psi);

new IShellItem GetFolder();

new IShellItem GetCurrentSelection();

new void SetFileName([MarshalAs(UnmanagedType.LPWStr)] string pszName);

[return: MarshalAs(UnmanagedType.LPWStr)]
new string GetFileName();

new void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pszTitle);

new void SetOkButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string pszText);

new void SetFileNameLabel([MarshalAs(UnmanagedType.LPWStr)] string pszLabel);

new IShellItem GetResult();

new void AddPlace(IShellItem psi, FDAP alignment);

new void SetDefaultExtension([MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);

new void Close([MarshalAs(UnmanagedType.Error)] int hr);

new void SetClientGuid([In] ref Guid guid);

new void ClearClientData();

new void SetFilter([MarshalAs(UnmanagedType.Interface)] object pFilter);
#endregion

void SetCancelButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string pszLabel);

void SetNavigationRoot(IShellItem psi);
}


[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public object Tag
//---------------------------------------------------
#region Protected Methods


// This method is not used by IFileDialog API. Keeping for API compatibility with .NET Framework.
/// <summary>
/// Defines the common dialog box hook procedure that is overridden to
/// add specific functionality to a common dialog box.
Expand All @@ -247,6 +247,7 @@ protected virtual IntPtr HookProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lP
return IntPtr.Zero;
}

/// <summary>
/// <summary>
/// When overridden in a derived class, displays a particular type of common dialog box.
/// </summary>
Expand Down Expand Up @@ -275,13 +276,14 @@ protected virtual void CheckPermissionsToShowDialog()
//---------------------------------------------------
#region Internal Methods

// This method is not used by IFileDialog API. Keeping for API compatibility with .NET Framework.
/// <summary>
/// Centers the given window on the screen. This method is used by HookProc
/// to center the dialog on the screen before it is shown. We can't mark it
/// private because we need to call it from our derived classes like
/// FileDialog.
/// </summary>
internal void MoveToScreenCenter(HandleRef hWnd)
private void MoveToScreenCenter(HandleRef hWnd)
{
// Create an IntPtr to store a handle to the monitor.
IntPtr hMonitor = IntPtr.Zero;
Expand Down Expand Up @@ -343,9 +345,8 @@ internal void MoveToScreenCenter(HandleRef hWnd)
// Internal Properties
//
//---------------------------------------------------
#region Internal Properties

#endregion Internal Properties
//#region Internal Properties
//#endregion Internal Properties

//---------------------------------------------------
//
Expand Down
Loading