public void Execute(object sender, EventArgs e) { var dte = (EnvDTE.DTE)_visualStudioPackageProvider.Package.DTE; //GetService(typeof(EnvDTE.DTE)); var uiShell = _visualStudioPackageProvider.Package.VsUIShell; var parentHwnd = IntPtr.Zero; uiShell.GetDialogOwnerHwnd(out parentHwnd); var parentShim = new NativeWindow(); parentShim.AssignHandle(parentHwnd); var dialog = new AttachDialog(); var result = dialog.ShowDialog(parentShim); if (result == DialogResult.OK) { HashSet<Process> processes = new HashSet<Process>(); foreach (int pid in dialog.SelectedItems) { Process p = Process.GetProcessById(pid); if (!p.IsBeingDebugged()) processes.Add(p); if (dialog.AutoAttachToCurrentChildren) { foreach (Process child in p.GetChildren()) { if (!child.IsBeingDebugged()) processes.Add(child); } } } List<Process> processList = new List<Process>(processes); ChildDebuggingMode mode = (dialog.AutoAttachToFutureChildren) ? ChildDebuggingMode.AlwaysAttach : ChildDebuggingMode.UseDefault; DebugAttach.AttachToProcess(processList.ToArray(), mode); } }
private void btnBrowseClear_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var nativeWindow = new WinForms.NativeWindow(); nativeWindow.AssignHandle(new WindowInteropHelper(this).Handle); var oldSaveLoc = Properties.Settings.Default.exportPath; var dlg = new WinForms.FolderBrowserDialog(); if (!string.IsNullOrEmpty(oldSaveLoc)) { dlg.SelectedPath = oldSaveLoc; } else { dlg.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } var result = dlg.ShowDialog(nativeWindow); if (result == WinForms.DialogResult.OK) { string newSavePath = dlg.SelectedPath; if (!string.IsNullOrEmpty(newSavePath)) { txtExportPath.Text = newSavePath; Properties.Settings.Default.exportPath = newSavePath; Properties.Settings.Default.Save(); } } }
public static void ShowError(this Exception e, IntPtr windowHandle) { IWin32Window parentWin32 = null; if (windowHandle != IntPtr.Zero) { try { var nw = new NativeWindow(); nw.AssignHandle(windowHandle); parentWin32 = nw; } catch { parentWin32 = null; } } if (parentWin32 != null) { MessageBox.Show(parentWin32, FormatError(e), "innoGlue internal error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { MessageBox.Show(FormatError(e), "innoGlue internal error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
void InitialShow() { NativeWindow owner = new NativeWindow(); owner.AssignHandle(((HwndSource)HwndSource.FromVisual(_owner)).Handle); _form.Show(owner); owner.ReleaseHandle(); }
public IntPtr Callback(IntPtr hWnd, User32.WM msg, IntPtr wparam, IntPtr lparam) { Debug.Assert(hWnd != IntPtr.Zero, "Windows called us with an HWND of 0"); // Set the window procedure to the default window procedure User32.SetWindowLong(hWnd, User32.GWL.WNDPROC, _defaultWindProc); _targetWindow.AssignHandle(hWnd); return(_targetWindow.Callback(hWnd, msg, wparam, lparam)); }
public PlayerWindow() { InitializeComponent(); PlaylistWindow = new PlaylistWindow(); NativeWindow natRef = new NativeWindow(); natRef.AssignHandle(this.Handle); PlaylistWindow.Show(natRef); PlaylistWindow.Visible = false; Rectangle ScreenBounds = Screen.FromHandle(this.Handle).Bounds; Program.snappingManager.bounds[IntPtr.Zero] = ScreenBounds; trackBar1_ValueChanged(trackBar1, null); }
private static NativeWindow EnsureCreated(NativeWindow window, IntPtr hWnd) { // we need to do this AssignHandle here instead of relying on // Control.WndProc to do it, because subclasses can override // WndProc, install their own WM_CREATE block, and look at // this.Handle, and it needs to be set. Otherwise, we end up // recursively creating windows and emitting WM_CREATE. if (window == null && WindowCreating != null) { window = WindowCreating; WindowCreating = null; if (window.Handle == IntPtr.Zero) { window.AssignHandle(hWnd); } } return(window); }
public void ShowView() { if (this.Parent == null) { IntPtr hdl = Process.GetCurrentProcess().MainWindowHandle; var window = new NativeWindow(); window.AssignHandle(hdl); this.Parent = window; } this.UISynchronizationContext.Post(new SendOrPostCallback(new Action<object>((x) => { if (this.Form.Visible) { this.Form.Focus(); } else { this.Form.Text = this.Name; this.wizardSettingIterator = this.BuildWizardPages(); this.Form.WizardSettings = this.wizardSettingIterator; var result = this.Form.ShowDialog(this.Parent); this.OnWizardClosed(result); } })), null); }
protected override void InnerRun() { Succeeded = false; PendingUserActivation = true; ShouldRetry = true; DoxApi api = new DoxApi(_serviceUrl); IDoxSession session = null; if (!string.IsNullOrEmpty(DeviceToken)) { session = api.CreateSessionFromDeviceToken(_loginName, DeviceToken, ApiHelper); if (session == null && api.Error.IsConnectionError()) { PendingUserActivation = false; ErrorMessage = Properties.Resources.ConnectionErrorDuringUpload; return; } } if (session == null) { // show login dialog var nativeWindow = new NativeWindow(); nativeWindow.AssignHandle(IntPtr.Zero); _loginUi.NativeWindow = nativeWindow; _loginUi.RegisterTabVisible = false; _loginUi.LoginFieldEnabled = false; var authenticator = new Authenticator(_loginUi); authenticator.Api = api; authenticator.ApiHelper = ApiHelper; bool cancelSend; session = authenticator.Authenticate(_loginName, null, out cancelSend); if (cancelSend) { ShouldRetry = false; PendingUserActivation = false; Logger.LogInfo("User cancelled send"); ErrorMessage = "Unable to log in."; return; } } if (session == null) { return; // something weird is happening, try again later } DeviceToken = session.Credentials.DeviceToken; OptionApi.SetEncrypted("SendLinkDeviceToken", DeviceToken, _entropy); OptionApi.SetEncrypted("SendLinkAccountId", session.CurrentUser.AccountId, _entropy); OptionApi.SetEncrypted("SendLinkUserId", session.CurrentUser.Id, _entropy); if (session.CurrentUser.IsValidated) { PendingUserActivation = false; Succeeded = true; ErrorMessage = string.Empty; } }
/// <summary> /// Initialize MSHTML by creating a new MSHTML instance, running it, and /// in-place activating it. The call to IOleObject.DoVerb will result in /// a call to our IOleDocumentSite.ActivateMe method where we will conclude /// the initialization sequence. /// /// This method is based on the CFramerDocument::CreateNewDocObject method /// from the FramerEx sample (referenced above in the class comment). /// Differences in our implementation include the fact that we don't use /// IPersistStorage or IPersistFile to load the contents of the document, /// we don't call IOleObject.SetHostNames, and we don't call IOleObject.Advise /// to set up an IAdviseSink (not necessary since we don't need notifications /// of changes to the data or view). /// </summary> private void InitializeMSHTML() { // Create the html document htmlDocument = (IHTMLDocument2)new HTMLDocumentClass(); // Query for its IOleObject interface (core OLE embedded object interface) oleObject = (IOleObject)htmlDocument; // Put the compound document object into the running state int result = Ole32.OleRun(oleObject); if (result != HRESULT.S_OK) Marshal.ThrowExceptionForHR(result); // Inform the embedded object of its "client-site" (i.e. container) oleObject.SetClientSite((IOleClientSite)(this)); // Lock the OleObject into it's running state (we will unlock it during Dispose) result = Ole32.OleLockRunning(oleObject, true, false); if (result != HRESULT.S_OK) Marshal.ThrowExceptionForHR(result); // Get the boundaries of the container RECT containerRect; GetContainerRect(out containerRect); // In-Place Activate the MSHTML ActiveDocument (will result in a call to // IOleDocumentSite.ActivateMe where initialization will continue) result = oleObject.DoVerb( OLEIVERB.INPLACEACTIVATE, // request in-place activation IntPtr.Zero, // MSG for event that invoked the verb (none) (IOleClientSite)(this), // client site for activation 0, // reserved (must be 0) this.Handle, // parent-window for active object ref containerRect); // bounding rectangle in parent window // check for DoVerb error if (result != HRESULT.S_OK) Marshal.ThrowExceptionForHR(result); // hookup to document events documentEventRepeater = new HtmlDocumentEventRepeater(htmlDocument); // If FindForm() is null, this editor is not hosted in a // managed window, thus, we must subclass the window to wait for // control key press to push through to PreProcessMessage // that would normally come through the managed message pump if (FindForm() == null) { NativeWindow nw = new NativeWindow(); nw.AssignHandle(MshtmlWindowHandle); windowSubClasser = new WindowSubClasser(nw, new WndProcDelegate(WndProcDelegate)); windowSubClasser.Install(); } }
/// <summary> /// This method displays the selection helper window where user can make selection on excel using mouse. /// </summary> /// <param name="selectionDialog">InputSelectionDialog instance which fired this call</param> private void ShowSelectionHelper(ISelectionDialog selectionDialog) { callerDialog = selectionDialog; SelectionHelper selectionHelperWindow = new SelectionHelper(OnSelectionComplete); selectionHelperWindow.SelectedAddress = selectionDialog.SelectedItem.FocusedTextBox.Text; // hook helper window as excel window's child nativeExcelWindow = new NativeWindow(); IntPtr excelWindow = new IntPtr(Globals.ThisAddIn.Application.Hwnd); nativeExcelWindow.AssignHandle(excelWindow); selectionHelperWindow.Show(nativeExcelWindow); selectionHelperWindow.Focus(); }
public IDoxSession CreateAuthenticatedSession(string defaultUserEmail) { var outlookWindow = new NativeWindow(); try { outlookWindow.AssignHandle(FindWindowEx(IntPtr.Zero, IntPtr.Zero, "rctrl_renwnd32", null)); _loginUi.NativeWindow = outlookWindow; _loginUi.LoginFieldEnabled = true; _loginUi.RegisterTabVisible = true; IAuthenticator authenticator = new Authenticator(_loginUi); authenticator.Api = new DoxApi(OptionApi.GetString("SendLinkServiceUrl")); string username = OptionApi.GetString("SendLinkCloudStorageLoginName"); username = string.IsNullOrEmpty(username) ? defaultUserEmail : username; string deviceToken = OptionApi.GetEncrypted("SendLinkDeviceToken", _entropy); bool cancelled; var session = authenticator.Authenticate(username, deviceToken, out cancelled); if (cancelled) { throw new AbortSendLinkException("User cancelled Sendlink", false); } return session; } finally { if (outlookWindow != null) { // TFS 6777: Outlook 2010 + Interwoven EMM: On cancel, Mail Inspector "Send" button inoperable, outlook remains in memory. outlookWindow.ReleaseHandle(); } } }
void InitialShow() { //create new NativeWindow var nativeWindow = new NativeWindow(); //extract HwndSource from WPF Window var hwndSource = (HwndSource)PresentationSource.FromVisual(_WpfWindow); if (hwndSource != null) { //assign handle to NativeWindow nativeWindow.AssignHandle(hwndSource.Handle); } _WinForm.Opacity = 0; //show WinForm settin newly created NativeWindow as owner _WinForm.Show(nativeWindow); //release NativeWindow handle nativeWindow.ReleaseHandle(); }
public string ShowOptionsDialog(IntPtr hParentWnd, string parameters) { ISettingsOriginator originator = RestoreFromParameters(parameters); //Show the options dialog FormOptions frm = _kernel.Get<FormOptions>(new ConstructorArgument("originator", originator)); NativeWindow nativeWindow = new NativeWindow(); try { nativeWindow.AssignHandle(hParentWnd); } catch { nativeWindow = null; } if (nativeWindow != null) frm.ShowDialog(nativeWindow); else frm.ShowDialog(); //Save our memento return originator.GetMemento().ToString(); }
private void CreateSwapChain() { if (this.swapChain == null && this.RenderContext != null) { NativeWindow nativeWindow = new NativeWindow(); nativeWindow.AssignHandle(this.node.Window.Handle); this.form.Show(nativeWindow);// IWin32Window ^ w = Control::FromHandle(myWindowHandle); this.form.FormBorderStyle = FormBorderStyle.None; this.form.Left = 1920; this.form.Top = 0; this.form.Width = 1920; this.form.Height = 1080; this.swapChain = new DX11SwapChain(this.RenderContext, this.form.Handle, SlimDX.DXGI.Format.R8G8B8A8_UNorm, new SlimDX.DXGI.SampleDescription(1, 0), 60, 2); this.RenderContext.Factory.SetWindowAssociation(this.form.Handle, SlimDX.DXGI.WindowAssociationFlags.IgnoreAll); } }
/// <summary> /// Initials the show. /// </summary> private void InitialShow() { var owner = new NativeWindow(); owner.AssignHandle(((HwndSource)HwndSource.FromVisual(this.owner)).Handle); BrowserOverlayContainer.Show(owner); owner.ReleaseHandle(); }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void MenuItemCallback(object sender, EventArgs e) { // Show a Message Box to prove we were here EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; IntPtr parentHwnd = IntPtr.Zero; uiShell.GetDialogOwnerHwnd(out parentHwnd); NativeWindow parentShim = new NativeWindow(); parentShim.AssignHandle(parentHwnd); AttachDialog dialog = new AttachDialog(); DialogResult result = dialog.ShowDialog(parentShim); if (result == DialogResult.OK) { foreach (int selected_id in dialog.SelectedItems) { foreach (EnvDTE90a.Process4 p in dte.Debugger.LocalProcesses) { System.Diagnostics.Debug.WriteLine("Found process {0}", p.ProcessID); if (p.ProcessID != selected_id) continue; p.Attach(); System.Diagnostics.Debug.WriteLine("Attaching to process successful."); break; } } } }
private void Application_WindowActivate(Word.Document Doc, Word.Window Wn) { // for User Testing endSwitchTime = DateTime.Now; appendSwitchWindowString(); // Track the handle ID for the text editor (Microsoft Word) int tempHandle = (int)GetActiveWindow(); if (handle != tempHandle) { handle = (int)GetActiveWindow(); currentSelection = Application.Selection; // Retrieve handle of the Microsoft Word window. wordMain = new NativeWindow(); wordMain.AssignHandle(new IntPtr(handle)); // Hide the form off the screen autoCompleteForm.Location = new Point(-1000, -1000); notificationForm.Location = new Point(-1000, -1000); extendSuggestionForm.Location = new Point(-1000, -1000); // Reassign forms' parent autoCompleteForm.Visible = false; autoCompleteForm.showForm(wordMain); // Assign the form parent to the current active window autoCompleteForm.Focus(); // In order to make the child form appear infront of the parent form autoCompleteForm.Hide(); notificationForm.Visible = false; notificationForm.Show(wordMain); // Assign the form parent to the current active window notificationForm.Focus(); // In order to make the child form appear infront of the parent form notificationForm.Hide(); extendSuggestionForm.Visible = false; extendSuggestionForm.Show(wordMain); extendSuggestionForm.Focus(); extendSuggestionForm.Hide(); wordMain.ReleaseHandle(); } if (!isEnabled && isDisablePopUp) { Globals.ThisAddIn.Dispatcher.Invoke(new displayMessageDelegate(displayMessage), new Object[] { ERROR_CONNECTION }); // Disable the pop-up isDisablePopUp = false; } BackgroundWorker b = new BackgroundWorker(); b.DoWork += delegate(object sender2, DoWorkEventArgs e2) { try { if (isEnabled) { // Inform ACP to change destination document logic.setDestinationDocument(handle); } } catch (SocketException e) { Globals.ThisAddIn.Dispatcher.Invoke(new displayMessageDelegate(displayMessage), new Object[] { ERROR_CONNECTION }); markServerDown(); } }; b.RunWorkerAsync(); updateApplicationSizeDetail(); SetActiveWindow(new IntPtr(tempHandle)); }
private static void UIThread() { var window = new Form(); window.Text = "CitizenFX Platform Server"; window.Size = new Size(800 + 16, 600 + 39); window.FormClosed += window_FormClosed; NativeWindow listBox = new NativeWindow(); listBox.AssignHandle(CreateWindowEx( WindowStylesEx.WS_EX_RIGHTSCROLLBAR, "listbox", "", WindowStyles.WS_VISIBLE | WindowStyles.WS_CHILD | WindowStyles.WS_VSCROLL |(WindowStyles)0x1000 /* LBS_DISABLENOSCROLL */, 0, 0, 800, 533, window.Handle, IntPtr.Zero, System.Diagnostics.Process.GetCurrentProcess().Handle, IntPtr.Zero )); IntPtr font = CreateFontW(8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "MS Sans Serif"); SendMessage(listBox.Handle, 0x30, font, IntPtr.Zero); ms_outputBox = listBox; ms_waitEvent.Set(); window.Resize += (sender, args) => { MoveWindow(listBox.Handle, 0, 0, window.Width - 16, 533, true); }; Application.Run(window); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { string[] recentFilePaths = RecentFilesRegistryHelper.GetRecentFiles(m_application); if (recentFilePaths.Length > 0) { //Populate the form with the files FormRecentFiles recentFileForm = new FormRecentFiles(); recentFileForm.PopulateFileList(recentFilePaths); //Set up parent window for modal dialog using Application's hWnd NativeWindow parentWindow = new NativeWindow(); parentWindow.AssignHandle(new IntPtr(m_application.hWnd)); //Show dialog and open file if necessary if (recentFileForm.ShowDialog(parentWindow) == DialogResult.OK) { string path = recentFileForm.lstFiles.SelectedItem.ToString(); if (System.IO.File.Exists(path)) { m_application.OpenDocument(path); } else { MessageBox.Show(string.Format("'{0}' cannot be found", path), "File doesn't exist"); } } } }
private static NativeWindow EnsureCreated (NativeWindow window, IntPtr hWnd) { // we need to do this AssignHandle here instead of relying on // Control.WndProc to do it, because subclasses can override // WndProc, install their own WM_CREATE block, and look at // this.Handle, and it needs to be set. Otherwise, we end up // recursively creating windows and emitting WM_CREATE. if (window == null && WindowCreating != null) { window = WindowCreating; WindowCreating = null; if (window.Handle == IntPtr.Zero) window.AssignHandle (hWnd); } return window; }
private void Window_Loaded(object sender, RoutedEventArgs e) { win32Window = new Win32Forms.NativeWindow(); win32Window.AssignHandle((new WindowInteropHelper(this)).Handle); }