- SharpShell_Core_Library.zip
- SharpShell_Source_Code.zip
- Sharpshell
- Dependencies
- Apex
- Apex.WinForms.dll
- SharpShell
- packages
- Apex.1.5.0
- Apex.1.5.0.nupkg
- lib
- net35
- Apex.dll
- net40
- Apex.dll
- sl30
- Apex.Silverlight.dll
- sl3-wp
- Apex.WP7.dll
- sl40
- Apex.Silverlight4.dll
- sl4-wp71
- Apex.WP7.dll
- sl50
- Apex.Silverlight.dll
- repositories.config
- Samples
- ContextMenu
- CountLinesExtension
- DropHandler
- XsdDropHandler
- IconHandler
- DllIconHandler
- InfoTipHandler
- FolderInfoTipHandler
- PropertySheet
- DrivePropertySheet
- TextFilePropertySheet
- SharedAssemblyInfo.cs
- SharpShell.sln
- SharpShell
- SharpShellNativeBridge
- Todo.txt
- Tools
- ServerInspector
- ServerManager
- SharpShell_Tools.zip
- SharpShell Tools
- Apex.dll
- Apex.WinForms.dll
- ServerInspector.exe
- ServerManager.exe
- SharpShell.dll
- System.Windows.Interactivity.dll
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using SharpShell.Diagnostics;
using SharpShell.Extensions;
using SharpShell.Interop;
namespace SharpShell.SharpPropertySheet
{
/// <summary>
/// The PropertyPageProxy is the object used to pass data between the
/// shell and the SharpPropertyPage.
/// </summary>
internal class PropertyPageProxy
{
/// <summary>
/// Prevents a default instance of the <see cref="PropertyPageProxy"/> class from being created.
/// </summary>
private PropertyPageProxy()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PropertyPageProxy"/> class.
/// </summary>
/// <param name="parent">The parent.</param>
/// <param name="propertyPage">The target property page.</param>
internal PropertyPageProxy(SharpPropertySheet parent, ISharpPropertyPage propertyPage)
{
// Set the target.
Parent = parent;
Target = propertyPage;
// Create the dialog proc delegate (as a class member so it won't be garbage collected).
dialogProc = new DialogProc(WindowProc);
callbackProc = new PropSheetCallback(CallbackProc);
}
/// <summary>
/// The WindowProc. Called by the shell and must delegate messages via the proxy to the user control.
/// </summary>
/// <param name="hWnd">The h WND.</param>
/// <param name="uMessage">The u message.</param>
/// <param name="wParam">The w param.</param>
/// <param name="lParam">The l param.</param>
/// <returns></returns>
private bool WindowProc(IntPtr hWnd, uint uMessage, IntPtr wParam, IntPtr lParam)
{
switch (uMessage)
{
case WindowsMessages.WM_INITDIALOG:
Logging.Log("WM_INITDIALOG Start");
try
{
// Set the parent of the property page to the host.
User32.SetParent(Target.Handle, hWnd);
// Update the page.
Target.OnPageInitialised(Parent);
}
catch (Exception exception)
{
Logging.Error("Failed to set the parent to the host.", exception);
}
Logging.Log("WM_INITDIALOG End");
break;
}
return false;
}
/// <summary>
/// The CallbackProc. Called by the shell to inform of key property page events.
/// </summary>
/// <param name="hWnd">The h WND.</param>
/// <param name="uMsg">The u MSG.</param>
/// <param name="ppsp">The PPSP.</param>
/// <returns></returns>
private uint CallbackProc(IntPtr hWnd, uint uMsg, ref PROPSHEETPAGE ppsp)
{
switch ((PSPCB)uMsg)
{
case PSPCB.ADDREF:
break;
case PSPCB.RELEASE:
break;
case PSPCB.CREATE:
// Allow the sheet to be created.
return 1;
}
return 0;
}
/// <summary>
/// Creates the property page handle.
/// </summary>
public void CreatePropertyPageHandle(NativeBridge.NativeBridge nativeBridge)
{
Logging.Log("Creating property page handle via bridge.");
// Create a prop sheet page structure.
var psp = new PROPSHEETPAGE();
// Set the key properties.
psp.dwSize = Marshal.SizeOf(psp);
//psp.dwFlags = PSP.USETITLE | PSP.USECALLBACK/* | PSP.DEFAULT |*/| PSP.DLGINDIRECT;
//psp.dwFlags = PSP.DEFAULT | PSP.USETITLE | PSP.DLGINDIRECT;
//psp.hInstance = nativeBridge.GetInstanceHandle();
psp.hInstance = nativeBridge.GetInstanceHandle();
psp.dwFlags = PSP.DEFAULT| PSP.USETITLE | PSP.USECALLBACK;
Logging.Log("Getting proxy host...");
psp.pTemplate = nativeBridge.GetProxyHostTemplate();
psp.pfnDlgProc = dialogProc;
psp.pcRefParent = 0;
psp.pfnCallback = callbackProc;
psp.lParam = IntPtr.Zero;
// If we have a title, set it.
if (!string.IsNullOrEmpty(Target.Title))
{
psp.dwFlags |= PSP.USETITLE;
psp.pszTitle = Target.Title;
}
// If we have an icon, set it.
if (Target.Icon != null && Target.Icon.Handle != IntPtr.Zero)
{
psp.dwFlags |= PSP.USEHICON;
psp.hIcon = Target.Icon.Handle;
}
// Create a the property sheet page.
HostWindowHandle = Comctl32.CreatePropertySheetPage(ref psp);
// Log the host window handle.
Logging.Log("Created Proxy Host: " + HostWindowHandle.ToString("X8"));
}
/// <summary>
/// The dialog proc.
/// </summary>
private readonly DialogProc dialogProc;
/// <summary>
/// The callback proc.
/// </summary>
private readonly PropSheetCallback callbackProc;
public SharpPropertySheet Parent { get; set; }
/// <summary>
/// Gets the property page.
/// </summary>
/// <value>
/// The property page.
/// </value>
public ISharpPropertyPage Target { get; private set; }
/// <summary>
/// Gets the host window handle.
/// </summary>
/// <value>
/// The host window handle.
/// </value>
public IntPtr HostWindowHandle { get; private set; }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.