public static BOOL ShowWindow(IHandle hWnd, ShowWindowCommand nCmdShow) { BOOL result = ShowWindow(hWnd.Handle, nCmdShow); GC.KeepAlive(hWnd); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="SHELLEXECUTEINFO"/> struct. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="parameters">The parameters.</param> public SHELLEXECUTEINFO(string fileName, string parameters = null) : this() { cbSize = Marshal.SizeOf(this); lpFile = fileName; lpParameters = parameters; nShellExecuteShow = ShowWindowCommand.SW_NORMAL; }
public void SetEditorPlacement(WindowPlacement placement) { WindowNormalPosition = placement.NormalPosition.ToRectangle(); WindowMaxPosition = placement.MaxPosition.ToPoint(); WindowMinPosition = placement.MinPosition.ToPoint(); ShowWindowCommand = placement.ShowCmd; WindowPlacementFlags = placement.Flags; }
public NotifyIconVM(Window target) { _host = target; ShowWindow = new ShowWindowCommand(_host); ChangeDischargingScheme = new LambdaCommand(ChangeDischarge); ChangeChargingScheme = new LambdaCommand(ChangeCharge); SetActiveScheme = new LambdaCommand(ChangeActive); PowerCommand = new PowerActionCommand(); InitiallizeCollections(); }
private static void EditAllOpenWindows(ShowWindowCommand action) { foreach (KeyValuePair <IntPtr, string> lWindow in GetOpenWindows()) { var handle = lWindow.Key; if (!handle.IsAllowed()) { EditWindowByHandle(handle, action); } } }
/// <summary>Invokes the specified verb on the shell item(s).</summary> /// <param name="verb">The verb to invoke.</param> /// <param name="show">Flags that specify how to display any opened window.</param> public void InvokeVerb(string verb, ShowWindowCommand show = ShowWindowCommand.SW_NORMAL) { var invoke = new CMINVOKECOMMANDINFOEX { cbSize = (uint)Marshal.SizeOf(typeof(CMINVOKECOMMANDINFOEX)), lpVerb = new SafeResourceId(verb, CharSet.Ansi), nShow = show }; ComInterface.InvokeCommand(invoke); }
public NotifyIcon( AppActivatedCommand appActivatedCommand, BeginSliceRegionsCommand beginSliceRegionsCommand, ShowWindowCommand <Windows.SettingsWindow> showSettingsWindowCommand, ExitCommand exitCommand ) { AppActivatedCommand = appActivatedCommand; BeginSliceRegionsCommand = beginSliceRegionsCommand; ShowSettingsWindowCommand = showSettingsWindowCommand; ExitCommand = exitCommand; InitializeComponent(); }
/// <summary>Invokes the command.</summary> /// <param name="verb"> /// The address of a null-terminated string that specifies the language-independent name of the command to carry out. This member is /// typically a string when a command is being activated by an application. The system provides predefined constant values for the /// following command strings. /// <para> /// If a canonical verb exists and a menu handler does not implement the canonical verb, it must return a failure code to enable the /// next handler to be able to handle this verb.Failing to do this will break functionality in the system including ShellExecute. /// </para> /// <para> /// Alternatively, rather than a pointer, this parameter can be MAKEINTRESOURCE(offset) where offset is the menu-identifier offset /// of the command to carry out. Implementations can use the IS_INTRESOURCE macro to detect that this alternative is being employed. /// The Shell uses this alternative when the user chooses a menu command. /// </para> /// </param> /// <param name="show">A set of values to pass to the ShowWindow function if the command displays a window or starts an application.</param> /// <param name="parent"> /// A handle to the window that is the owner of the shortcut menu. An extension can also use this handle as the owner of any message /// boxes or dialog boxes it displays. Callers must specify a legitimate HWND that can be used as the owner window for any UI that /// may be displayed. Failing to specify an HWND when calling from a UI thread (one with windows already created) will result in /// reentrancy and possible bugs in the implementation of this call. /// </param> /// <param name="location">If supplied, the point where the command is invoked.</param> /// <param name="allowAsync"> /// The implementation can spin off a new thread or process to handle the call and does not need to block on completion of the /// function being invoked. For example, if the verb is "delete" the call may return before all of the items have been deleted. /// Since this is advisory, calling applications that specify this flag cannot guarantee that this request will be honored if they /// are not familiar with the implementation of the verb that they are invoking. /// </param> /// <param name="shiftDown"> /// If <see langword="true"/>, the SHIFT key is pressed. Use this instead of polling the current state of the keyboard that may have /// changed since the verb was invoked. /// </param> /// <param name="ctrlDown"> /// If <see langword="true"/>, the CTRL key is pressed. Use this instead of polling the current state of the keyboard that may have /// changed since the verb was invoked.. /// </param> /// <param name="hotkey">An optional keyboard shortcut to assign to any application activated by the command.</param> /// <param name="logUsage"> /// If <see langword="true"/>, indicates that the method might want to keep track of the item being invoked for features like the /// "Recent documents" menu. /// </param> /// <param name="noZoneChecks"> /// Do not perform a zone check. This flag allows ShellExecuteEx to bypass zone checking put into place by IAttachmentExecute. /// </param> public void InvokeCommand(ResourceId verb, ShowWindowCommand show = ShowWindowCommand.SW_SHOWNORMAL, HWND parent = default, Point?location = default, bool allowAsync = false, bool shiftDown = false, bool ctrlDown = false, uint hotkey = 0, bool logUsage = false, bool noZoneChecks = false) { var invoke = new CMINVOKECOMMANDINFOEX { cbSize = (uint)Marshal.SizeOf(typeof(CMINVOKECOMMANDINFOEX)), hwnd = parent, fMask = (parent.IsNull ? CMIC.CMIC_MASK_FLAG_NO_UI : 0) | (hotkey != 0 ? CMIC.CMIC_MASK_HOTKEY : 0), lpVerb = verb, nShow = show, dwHotKey = hotkey, }; if (allowAsync) { invoke.fMask |= CMIC.CMIC_MASK_ASYNCOK; } if (shiftDown) { invoke.fMask |= CMIC.CMIC_MASK_SHIFT_DOWN; } if (ctrlDown) { invoke.fMask |= CMIC.CMIC_MASK_CONTROL_DOWN; } if (logUsage) { invoke.fMask |= CMIC.CMIC_MASK_FLAG_LOG_USAGE; } if (noZoneChecks) { invoke.fMask |= CMIC.CMIC_MASK_NOZONECHECKS; } if (location.HasValue) { invoke.ptInvoke = location.Value; invoke.fMask |= CMIC.CMIC_MASK_PTINVOKE; } if (!verb.IsIntResource) { invoke.lpVerbW = (string)verb; invoke.fMask |= CMIC.CMIC_MASK_UNICODE; } ComInterface.InvokeCommand(invoke); }
internal bool SetSourceShowWindowCommand(ShowWindowCommand showWindowCommand) { if (_shellLink == null) { throw new ObjectDisposedException(nameof(ShellLink), $"Cannot access a closed {nameof(IShellLinkW)}."); } var error = _shellLink.SetShowCmd(showWindowCommand); if (error == HResult.SOk) { return(true); } Logger.GetInstance(typeof(ShellLink)).Error($"Cannot set source show window command. error: {error}"); return(false); }
public MainViewModel(Settings settings) { this.settings = settings; if (!settings.Installed) { InitializeDefaults(); } CharacterManager = new CharacterManagerViewModel(settings); BrowseDataPath = new BrowseCommand(); BrowseInstallPath = new BrowseCommand(); ExitCommand = new ActionCommand(x => Application.Current.Shutdown(), x => true); ShowAboutWindowCommand = new ShowWindowCommand<AboutWindow>(owner: Application.Current.MainWindow, properties: new {ShowInTaskBar = false}); BrowseDataPath.BrowseCompletedEvent += selectedPath => GameDataPath = selectedPath; BrowseInstallPath.BrowseCompletedEvent += selectedPath => InstallPath = selectedPath; }
public static extern bool ShowWindowAsync(IntPtr hWnd, [MarshalAs(UnmanagedType.I4)] ShowWindowCommand nCmdShow);
internal static extern IntPtr ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
public static extern bool ShowWindow(IntPtr windowHandle, ShowWindowCommand command);
internal static extern BOOL ShowWindow(HWND hWnd, ShowWindowCommand nCmdShow);
internal static bool PostShowWindowCommand(IntPtr hWnd, ShowWindowCommand command) => ShowWindowAsync(hWnd, (int)command);
public static extern bool ShowWindow(IntPtr hwnd, ShowWindowCommand nCmdShow );
private static void EditWindowByHandle(IntPtr windowHandle, ShowWindowCommand action, bool waitForShowingUp = false) { if (action == ShowWindowCommand.SW_HIDE) { _hiddenWindowHandles.Add(windowHandle); } //Do this in a sepparate Thread because in case of minimizing windows the thread needs to wait for the window to show up ThreadPool.QueueUserWorkItem( delegate { try { //If you want to minimize the window you have to wait for it to show up if (action == ShowWindowCommand.SW_SHOWMINIMIZED && waitForShowingUp) { Thread.Sleep(500); } //ShowWindow is the standard way of editing the window status if (!ShowWindowAsync(windowHandle, (int)action)) { //If ShowWindowAsync failes (attention: it returns a value != zero if the state has been changed, if the state has remained unchained it returns false) //Do it the hard way if (action == ShowWindowCommand.SW_SHOWMINIMIZED) { SendMessage(windowHandle, 274, (IntPtr)SC_MINIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} minimized", windowHandle.GetWindowTitle())); } else if (action == ShowWindowCommand.SW_HIDE) { //This is a drastic action! If an application cannot be handled by the previous actions, for example if it has administrator privileges, then it gets closed! SendMessage(windowHandle, 274, (IntPtr)SC_CLOSE, IntPtr.Zero); Logger.AddInformation(String.Format( "Window {0} closed, because i was unable to hide it", windowHandle.GetWindowTitle())); } else if (action == ShowWindowCommand.SW_SHOWMAXIMIZED) { SendMessage(windowHandle, 274, (IntPtr)SC_MAXIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} Maximized", windowHandle.GetWindowTitle())); } } else { Logger.AddInformation(String.Format("Window {0} {1}", windowHandle.GetWindowTitle(), action.ToString())); } } catch { try { //If ShowWindowAsync failes (attention: it returns a value != zero if the state has been changed, if the state has remained unchained it returns false) //Do it the hard way string windowTitle = windowHandle.GetWindowTitle(); if (action == ShowWindowCommand.SW_SHOWMINIMIZED) { SendMessage(windowHandle, 274, (IntPtr)SC_MINIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} minimized", windowTitle)); } else if (action == ShowWindowCommand.SW_HIDE) { //This is a drastic action! If an application cannot be handled by the previous actions, for example if it has administrator privileges, then it gets closed! SendMessage(windowHandle, 274, (IntPtr)SC_CLOSE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} closed, because i was unable to hide it", windowTitle)); } else if (action == ShowWindowCommand.SW_SHOWMAXIMIZED) { SendMessage(windowHandle, 274, (IntPtr)SC_MAXIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} Maximized", windowTitle)); } } catch (Exception ex) { Logger.AddError("Couldn't close Window with exception", null, ex); } } }); }
public static void Show(IntPtr handle, ShowWindowCommand showWindowCommand) { User32.ShowWindow(handle, (int)showWindowCommand); }
private void InitializeFilterCommands() { SearchCommand = new ActionCommand(async() => { await Task.Run(() => { Busy(); RangeObservableCollection <PatientModel> patients = null; if (String.IsNullOrWhiteSpace(SearchText)) { patients = new RangeObservableCollection <PatientModel>( Context.Patients.Local.Select(PatientSelector)); } else if (StepNameFilter != null) { patients = new RangeObservableCollection <PatientModel>( Context.Patients.Local.Where( e => (e.FirstName.ToLower() + " " + e.LastName.ToLower()) .Contains(SearchText.ToLower()) && e.CurrentStep.StepName == StepNameFilter) .Select(PatientSelector)); } else { patients = new RangeObservableCollection <PatientModel>( Context.Patients.Local.Where( e => (e.FirstName.ToLower() + " " + e.LastName.ToLower()) .Contains(SearchText.ToLower())) .Select(PatientSelector)); } ShowCanceled = true; ShowCompleted = true; ShowOngoing = true; ShowOverDue = true; Patients = patients; Free(); }); }); ReverseSortCommand = new ActionCommand(async() => { await Task.Run(() => { Busy(); Patients = new RangeObservableCollection <PatientModel>(Patients.Reverse()); Free(); }); }); FilterStepCommand = new ActionCommand(async() => { await Task.Run(() => { RangeObservableCollection <PatientModel> patients = null; Busy(); if (StepNameFilter != null) { patients = new RangeObservableCollection <PatientModel>( Context.Patients.OrderByDescending(e => e.Id) .Where(e => e.CurrentStep.StepName == StepNameFilter).Select(PatientSelector)); } else { patients = new RangeObservableCollection <PatientModel>( Context.Patients.OrderByDescending(e => e.Id).Select(PatientSelector)); } Patients = patients; ShowCanceled = true; ShowCompleted = true; ShowOngoing = true; ShowOverDue = true; Free(); }); }); FilterPatientsCommand = new ActionCommand(async obj => { ShowWindowCommand.Execute(null); await Task.Run(() => { var patients = new RangeObservableCollection <PatientModel>(); Busy(); if (obj is int) { BusyMessage = "Loading Patient"; Locator.SinglePatientViewModel.Patient = Patients.First(e => e.Id == (int)obj); } else { BusyMessage = "Loading Patients"; ShowOngoing = false; ShowCanceled = false; ShowCompleted = false; patients.AddRange(OverDuePatients.OrderBy(e => e.Id)); Patients = patients; } Free(); }); }); FilterCnacled = new ActionCommand(async() => { var patients = new RangeObservableCollection <PatientModel>(); await Task.Run(() => { Busy(); BusyMessage = "Applying Filter"; if (ShowCanceled) { patients.AddRange(Patients); patients.AddRange( Context.Patients.Local.Where(e => e.CurrentStep.IsCancled).Select(PatientSelector)); patients = new RangeObservableCollection <PatientModel>( patients.OrderByDescending(e => e.Id)); } else { for (int i = 0; i < Patients.Count; i++) { PatientModel patient = Patients[i]; if (!patient.CurrentStep.IsCancled) { patients.Add(patient); } } } Patients = patients; Free(); }); }); FilterCompleted = new ActionCommand(async() => { var patients = new RangeObservableCollection <PatientModel>(); await Task.Run(() => { Busy(); BusyMessage = "Applying Filter"; if (ShowCompleted) { patients.AddRange(Patients); patients.AddRange( Context.Patients.Local.Where(e => e.CurrentStep.IsCompleted).Select(PatientSelector)); patients = new RangeObservableCollection <PatientModel>( patients.OrderByDescending(e => e.Id)); } else { for (int i = 0; i < Patients.Count; i++) { PatientModel patient = Patients[i]; if (!patient.CurrentStep.IsCompleted) { patients.Add(patient); } } } Patients = patients; Free(); }); }); FilterOngoing = new ActionCommand(async() => { var patients = new RangeObservableCollection <PatientModel>(); await Task.Run(() => { Busy(); BusyMessage = "Applying Filter"; if (ShowOngoing) { patients.AddRange(Patients); patients.AddRange( Context.Patients.Local.Where(e => e.CurrentStep.Status == Status.Ongoing) .Select(PatientSelector)); patients = new RangeObservableCollection <PatientModel>( patients.OrderByDescending(e => e.Id)); } else { for (int i = 0; i < Patients.Count; i++) { PatientModel patient = Patients[i]; if (patient.CurrentStep.Status != Status.Ongoing) { patients.Add(patient); } } } Patients = patients; Free(); }); }); FilterOverdue = new ActionCommand(async() => { var patients = new RangeObservableCollection <PatientModel>(); await Task.Run(() => { Busy(); BusyMessage = "Applying Filter"; if (ShowOverDue) { patients.AddRange(Patients); patients.AddRange( Context.Patients.Local.Where(e => e.CurrentStep.Status == Status.Overdue) .Select(PatientSelector)); patients = new RangeObservableCollection <PatientModel>( patients.OrderByDescending(e => e.Id)); } else { for (int i = 0; i < Patients.Count; i++) { PatientModel patient = Patients[i]; if (patient.CurrentStep.Status != Status.Overdue) { patients.Add(patient); } } } Patients = patients; Free(); }); }); }
internal static bool ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
public static extern int ShowWindow(IntPtr hwnd, ShowWindowCommand cmdShow);
public static extern int ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
private static void EditWindowByHandle(IntPtr windowHandle, ShowWindowCommand action, bool waitForShowingUp = false) { if (action == ShowWindowCommand.SW_HIDE) _hiddenWindowHandles.Add(windowHandle); //Do this in a sepparate Thread because in case of minimizing windows the thread needs to wait for the window to show up ThreadPool.QueueUserWorkItem( delegate { try { //If you want to minimize the window you have to wait for it to show up if (action == ShowWindowCommand.SW_SHOWMINIMIZED && waitForShowingUp) Thread.Sleep(500); //ShowWindow is the standard way of editing the window status if (!ShowWindowAsync(windowHandle, (int) action)) { //If ShowWindowAsync failes (attention: it returns a value != zero if the state has been changed, if the state has remained unchained it returns false) //Do it the hard way if (action == ShowWindowCommand.SW_SHOWMINIMIZED) { SendMessage(windowHandle, 274, (IntPtr) SC_MINIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} minimized", windowHandle.GetWindowTitle())); } else if (action == ShowWindowCommand.SW_HIDE) { //This is a drastic action! If an application cannot be handled by the previous actions, for example if it has administrator privileges, then it gets closed! SendMessage(windowHandle, 274, (IntPtr) SC_CLOSE, IntPtr.Zero); Logger.AddInformation(String.Format( "Window {0} closed, because i was unable to hide it", windowHandle.GetWindowTitle())); } else if (action == ShowWindowCommand.SW_SHOWMAXIMIZED) { SendMessage(windowHandle, 274, (IntPtr) SC_MAXIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} Maximized", windowHandle.GetWindowTitle())); } } else { Logger.AddInformation(String.Format("Window {0} {1}", windowHandle.GetWindowTitle(), action.ToString())); } } catch { try { //If ShowWindowAsync failes (attention: it returns a value != zero if the state has been changed, if the state has remained unchained it returns false) //Do it the hard way if (action == ShowWindowCommand.SW_SHOWMINIMIZED) { SendMessage(windowHandle, 274, (IntPtr)SC_MINIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} minimized", windowHandle.GetWindowTitle())); } else if (action == ShowWindowCommand.SW_HIDE) { //This is a drastic action! If an application cannot be handled by the previous actions, for example if it has administrator privileges, then it gets closed! SendMessage(windowHandle, 274, (IntPtr)SC_CLOSE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} closed, because i was unable to hide it", windowHandle.GetWindowTitle())); } else if (action == ShowWindowCommand.SW_SHOWMAXIMIZED) { SendMessage(windowHandle, 274, (IntPtr)SC_MAXIMIZE, IntPtr.Zero); Logger.AddInformation(String.Format("Window {0} Maximized", windowHandle.GetWindowTitle())); } } catch (Exception) { } } }); }
private static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
internal static extern bool ShowWindow(IntPtr hwnd, ShowWindowCommand show);
public void Show(ShowWindowCommand cmd) { User32.ShowWindow(this.Handle, cmd); }
private void RefreshButtons() { ShowWindowCommand.RaiseCanExecuteChanged(); HideWindowCommand.RaiseCanExecuteChanged(); CloseWindowCommand.RaiseCanExecuteChanged(); }
public static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommand command);
/// <summary> /// メッセージウィンドウを表示する /// </summary> /// <param name="command"></param> public void ShowWindow(ShowWindowCommand command) { _view.ChangeMessageViewPosition(command.Position); _view.MessagePresenter.ShowWindow(command.ViewType, command.MarginX, command.MarginY); }
public static extern bool ShowWindow(HandleRef hWnd, ShowWindowCommand nCmdShow);
public static extern int ShowWindow(IntPtr hWnd, ShowWindowCommand command);
/// <summary> /// Sets the show state of a window without waiting for the operation to complete by /// posting a ShowWindow command to the message queue of the given window. /// </summary> /// <param name="hWnd">The handle of the window to post to.</param> /// <param name="command">The command to post.</param> /// <returns>True if the command was posted; false otherwise.</returns> public static bool PostShowWindowCommand(IntPtr hWnd, ShowWindowCommand command) => NativeMethods.PostShowWindowCommand(hWnd, command);
private static void EditAllOpenWindows(ShowWindowCommand action) { foreach (KeyValuePair<IntPtr, string> lWindow in GetOpenWindows()) { var handle = lWindow.Key; if (!handle.IsAllowed()) EditWindowByHandle(handle, action); } }
/// <summary>Invokes the specified verb on the shell item(s).</summary> /// <param name="verb">The verb to invoke.</param> /// <param name="show">Flags that specify how to display any opened window.</param> /// <param name="parent"> /// A handle to the window that is the owner of the shortcut menu. An extension can also use this handle as the owner of any message /// boxes or dialog boxes it displays. Callers must specify a legitimate HWND that can be used as the owner window for any UI that /// may be displayed. Failing to specify an HWND when calling from a UI thread (one with windows already created) will result in /// reentrancy and possible bugs in the implementation of this call. /// </param> public void InvokeVerb(string verb, [Optional] ShowWindowCommand show, [Optional] HWND parent) => InvokeCommand(new SafeResourceId(verb), show, parent);
public static extern uint WinExec([In][MarshalAs(UnmanagedType.LPStr)] string lpCmdLine, ShowWindowCommand uCmdShow);
static extern bool ShowWindow(IntPtr handle, ShowWindowCommand command);
internal static extern Boolean ShowWindow([In] IntPtr windowHandle, [In] ShowWindowCommand command);
internal static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
public static void ShowWindowAsync(IntPtr hWnd, ShowWindowCommand nCmdShow) => ShowWindowAsync(hWnd, (int) nCmdShow);