public void ShowBalloonTip(int timeout, string tipTitle, string tipText, NotifyBalloonIcon tipIcon) { if (timeout < 0) { throw new ArgumentOutOfRangeException("timeout", timeout, ""); } ArgumentValidator.NotNullOrEmptyString(tipText, "tipText"); ArgumentValidator.EnumValueIsDefined(typeof(NotifyBalloonIcon), tipIcon, "tipIcon"); if (true) { _allWindowsPermission.Demand(); var pnid = new NativeMethods.NOTIFYICONDATA { hWnd = _hwndSource.Handle, uID = _id, uFlags = NativeMethods.NotifyIconFlags.Balloon, uTimeoutOrVersion = timeout, szInfoTitle = tipTitle, szInfo = tipText, dwInfoFlags = (int)tipIcon }; NativeMethods.Shell_NotifyIcon(1, pnid); } }
/// <summary> /// 过滤消息 /// Filters out a message before it is dispatched /// </summary> /// <param name="m">The message to be dispatched. You cannot modify /// this message</param> /// <returns>true to filter the message and prevent it from being /// dispatched; false to allow the message to continue to the next /// filter or control</returns> public bool PreFilterMessage(ref Message m) { //确保有一个client // make sure we have a client if (this.Client == null) { return(false); } //确保消息是一个鼠标消息 // make sure the message is a mouse message if ((m.Msg >= (int)I3WindowMessage.WM_MOUSEMOVE && m.Msg <= (int)I3WindowMessage.WM_XBUTTONDBLCLK) || (m.Msg >= (int)I3WindowMessage.WM_NCMOUSEMOVE && m.Msg <= (int)I3WindowMessage.WM_NCXBUTTONUP)) { //尝试获取目标控件 // try to get the target control UIPermission uiPermission = new UIPermission(UIPermissionWindow.AllWindows); uiPermission.Demand(); Control target = Control.FromChildHandle(m.HWnd); //实际上鼠标消息的过滤,是由client来实现的 return(this.Client.ProcessMouseMessage(target, (I3WindowMessage)m.Msg, m.WParam.ToInt32(), m.LParam.ToInt32())); } //不是鼠标消息,返回false,消息可以继续派发 return(false); }
// Loads any steps protected override void OnLoad(System.EventArgs e) { base.OnLoad(e); if (!DesignMode) { OnLoadSteps(EventArgs.Empty); if (FirstStepName == "") { throw new InvalidOperationException("FirstStepName must be be a non-empty string."); } ResetSteps(); SetCurrentStep(FirstStepName, StepDirection.InitialStep); } else { UpdateLayout(currentLayout); } UIPermission uiP = new UIPermission(UIPermissionWindow.AllWindows); uiP.Demand(); }
/// <summary> /// Filters out a message before it is dispatched /// </summary> /// <param name="m">The message to be dispatched. You cannot modify /// this message</param> /// <returns>true to filter the message and prevent it from being /// dispatched; false to allow the message to continue to the next /// filter or control</returns> public bool PreFilterMessage(ref Message m) { // make sure we have a client if (this.Client == null) { return(false); } // make sure the message is a key message if (m.Msg != (int)I3WindowMessage.WM_KEYDOWN && m.Msg != (int)I3WindowMessage.WM_SYSKEYDOWN && m.Msg != (int)I3WindowMessage.WM_KEYUP && m.Msg != (int)I3WindowMessage.WM_SYSKEYUP) { return(false); } // try to get the target control UIPermission uiPermission = new UIPermission(UIPermissionWindow.AllWindows); uiPermission.Demand(); Control target = Control.FromChildHandle(m.HWnd); try { return(this.Client.ProcessKeyMessage(target, (I3WindowMessage)m.Msg, m.WParam.ToInt32(), m.LParam.ToInt32())); } catch { return(true); } }
internal static void DemandUnrestrictedUIPermission() { if (_unrestrictedUIPermission == null) { _unrestrictedUIPermission = new UIPermission(PermissionState.Unrestricted); } _unrestrictedUIPermission.Demand(); }
internal static void DemandUIWindowPermission() { if (_allWindowsUIPermission == null) { _allWindowsUIPermission = new UIPermission(UIPermissionWindow.AllWindows); } _allWindowsUIPermission.Demand(); }
internal static void DemandAllClipboardPermission() { if (_uiPermissionAllClipboard == null) { _uiPermissionAllClipboard = new UIPermission(UIPermissionClipboard.AllClipboard); } _uiPermissionAllClipboard.Demand(); }
// Updated May 20, 2003, switched from event handler to overriding the protected method protected override void OnLoad(System.EventArgs e) { base.OnLoad(e); UpdateLayout(pageLayout); UIPermission uiP = new UIPermission(UIPermissionWindow.AllWindows); uiP.Demand(); }
private static void ValidateCspFlags(CspProviderFlags flags) { if ((flags & CspProviderFlags.UseExistingKey) != CspProviderFlags.NoFlags) { CspProviderFlags cspProviderFlags = CspProviderFlags.UseNonExportableKey | CspProviderFlags.UseArchivableKey | CspProviderFlags.UseUserProtectedKey; if ((flags & cspProviderFlags) != CspProviderFlags.NoFlags) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag")); } } if ((flags & CspProviderFlags.UseUserProtectedKey) != CspProviderFlags.NoFlags) { if (!Environment.UserInteractive) { throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NotInteractive")); } UIPermission uipermission = new UIPermission(UIPermissionWindow.SafeTopLevelWindows); uipermission.Demand(); } }
/// <summary> /// Filters out a message before it is dispatched /// </summary> /// <param name="m">The message to be dispatched. You cannot modify /// this message</param> /// <returns>true to filter the message and prevent it from being /// dispatched; false to allow the message to continue to the next /// filter or control</returns> public bool PreFilterMessage(ref Message m) { // make sure we have a client if (this.Client == null) { return(false); } // make sure the message is a mouse message if ((m.Msg >= (int)WindowMessage.WM_MOUSEMOVE && m.Msg <= (int)WindowMessage.WM_XBUTTONDBLCLK) || (m.Msg >= (int)WindowMessage.WM_NCMOUSEMOVE && m.Msg <= (int)WindowMessage.WM_NCXBUTTONUP)) { // try to get the target control UIPermission uiPermission = new UIPermission(UIPermissionWindow.AllWindows); uiPermission.Demand(); Control target = Control.FromChildHandle(m.HWnd); return(this.Client.ProcessMouseMessage(target, (WindowMessage)m.Msg, m.WParam.ToInt32(), m.LParam.ToInt32())); } return(false); }
private static void CallUnmanagedCodeWithoutPermission() { try { // The UnmanagedCode security check is disbled on the call // below. However, the unmanaged call only displays UI. The // security will be ensured by only allowing the unmanaged // call if there is a UI permission. UIPermission uiPermission = new UIPermission(PermissionState.Unrestricted); uiPermission.Demand(); Console.WriteLine("Attempting to call unmanaged code without UnmanagedCode permission."); NativeMethods.puts("Hello World!"); NativeMethods._flushall(); Console.WriteLine("Called unmanaged code without UnmanagedCode permission."); } catch (SecurityException) { Console.WriteLine("Caught Security Exception attempting to call unmanaged code."); } }
/// <summary> /// Initializes a new instance of the SpyWindow class /// </summary> public SpyWindow() { UIPermission myPermission = new UIPermission(UIPermissionWindow.AllWindows); myPermission.Demand(); this.InitializeComponent(); _cursorDefault = Cursor.Current; _cursorFinder = EmbeddedResources.LoadCursor(EmbeddedResources.Finder); _finderHome = EmbeddedResources.LoadImage(EmbeddedResources.FinderHome); _finderGone = EmbeddedResources.LoadImage(EmbeddedResources.FinderGone); _pictureBox.Image = _finderHome; _pictureBox.MouseDown += new MouseEventHandler(OnFinderToolMouseDown); _buttonOK.Click += new EventHandler(OnButtonOKClicked); _buttonCancel.Click += new EventHandler(OnButtonCancelClicked); _buttonCapture.Click += new EventHandler(OnButtonCaptureClicked); _buttonCapture.Enabled = false; _textBoxHandle.TextChanged += new EventHandler(OnTextBoxHandleTextChanged); //this.AcceptButton = _buttonOK; this.CancelButton = _buttonCancel; }
internal static void DemandUIWindowPermission() { _allWindowsUIPermission ??= new UIPermission(UIPermissionWindow.AllWindows); _allWindowsUIPermission.Demand(); }