private bool ShowDialogInternal(ref BrowseInfo bi) { bi.title = title; bi.displayname = new string('\0', 260); bi.callback = new BrowseCallBackProc(this.CallBack); bi.flags = (int)flags; //Free any old pidls if (pidlReturned != IntPtr.Zero) { UnManagedMethods.SHMemFree(pidlReturned); } bool ret = (pidlReturned = UnManagedMethods.SHBrowseForFolder(ref bi)) != IntPtr.Zero; if (ret) { displayName = bi.displayname; } //Reset the handle handle = IntPtr.Zero; return(ret); }
protected override void Dispose(bool disposing) { if (pidlReturned != IntPtr.Zero) { UnManagedMethods.SHMemFree(pidlReturned); pidlReturned = IntPtr.Zero; } }
/// <summary> /// Expand a path in the folder /// </summary> /// <param name="path">The path to expand</param> public void SetExpanded(string path) { IntPtr strptr = Marshal.StringToHGlobalUni(path); UnManagedMethods.SendMessage(handle, BFFM_SETEXPANDED, new IntPtr(1), strptr); Marshal.FreeHGlobal(strptr); }
/// <summary> /// Enables or disables the ok button /// </summary> /// <param name="bEnable">true to enable false to diasble the OK button</param> public void EnableOkButton(bool bEnable) { if (handle == IntPtr.Zero) { throw new InvalidOperationException(); } IntPtr lp = bEnable ? new IntPtr(1) : IntPtr.Zero; UnManagedMethods.SendMessage(handle, BFFM_ENABLEOK, IntPtr.Zero, lp); }
/// <summary> /// Sets the text of the OK button in the dialog /// </summary> /// <param name="text">New text of the OK button</param> public void SetOkButtonText(string text) { if (handle == IntPtr.Zero) { throw new InvalidOperationException(); } IntPtr strptr = Marshal.StringToHGlobalUni(text); UnManagedMethods.SendMessage(handle, BFFM_SETOKTEXT, new IntPtr(1), strptr); Marshal.FreeHGlobal(strptr); }
/// <summary> /// Sets the text of the staus area of the folder dialog /// </summary> /// <param name="text">Text to set</param> public void SetStatusText(string text) { if (handle == IntPtr.Zero) { throw new InvalidOperationException(); } int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSTATUSTEXTW : BFFM_SETSTATUSTEXTA; IntPtr strptr = Marshal.StringToHGlobalAuto(text); UnManagedMethods.SendMessage(handle, msg, IntPtr.Zero, strptr); Marshal.FreeHGlobal(strptr); }
/// <summary> /// Sets the selection the text specified /// </summary> /// <param name="newsel">The path of the folder which is to be selected</param> public void SetSelection(string newsel) { if (handle == IntPtr.Zero) { throw new InvalidOperationException(); } int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSELECTIONA : BFFM_SETSELECTIONW; IntPtr strptr = Marshal.StringToHGlobalAuto(newsel); UnManagedMethods.SendMessage(handle, msg, new IntPtr(1), strptr); Marshal.FreeHGlobal(strptr); }
public void Dispose() { UnManagedMethods.SHMemFree(pidlNewSelect); }