Пример #1
0
        /// <summary>
        /// Update UIState of the control with NativeWindowCommon.UISF_HIDEFOCUS
        /// </summary>
        /// <param name="ctrl"></param>
        /// <param name="set"></param>
        private static void UpdateUIstate(Control ctrl, bool set)
        {
            int UIS_l  = set ? NativeWindowCommon.UIS_SET : NativeWindowCommon.UIS_CLEAR;
            int wParam = NativeWindowCommon.MakeLong(UIS_l, NativeWindowCommon.UISF_HIDEFOCUS);

            NativeWindowCommon.SendMessage(ctrl.Handle, NativeWindowCommon.WM_UPDATEUISTATE, wParam, 0);
            ctrl.Invalidate(ctrl.ClientRectangle);
        }
Пример #2
0
        /// <include file="doc\FormDocumentDesigner.uex" path='docs/doc[@for="FormDocumentDesigner.OnDesignerDeactivate"]/*'>

        /// <devdoc>

        ///     Called by the host when we become inactive.  Here we update the

        ///     title bar of our form so it's the inactive color.

        /// </devdoc>

        private void OnDesignerDeactivate(object sender, EventArgs e)
        {
            Control control = Control;

            if (control != null && control.IsHandleCreated)
            {
                NativeWindowCommon.SendMessage(control.Handle, NativeWindowCommon.WM_NCACTIVATE, 0, 0);

                NativeWindowCommon.RedrawWindow(control.Handle, IntPtr.Zero, IntPtr.Zero, NativeWindowCommon.RedrawWindowFlags.RDW_FRAME);
            }
        }
Пример #3
0
        /// <summary>
        /// Callback method for the handling of messages to be sent to/from the folder browser dialog.
        /// </summary>
        /// <param name="hwnd"></param>
        /// <param name="msg"></param>
        /// <param name="lParam"></param>
        /// <param name="lpData"></param>
        /// <returns></returns>
        private int FolderBrowserDialog_BrowseCallbackProc(IntPtr hwnd, int msg, IntPtr lParam, IntPtr lpData)
        {
            switch (msg)
            {
            case NativeWindowCommon.BFFM_INITIALIZED:
                // We get in here when the dialog is first displayed. If an initial directory
                // has been specified we will make this the selection now, and also make sure
                // that directory is expanded.
                if (this.selectedPath.Length != 0)
                {
                    NativeWindowCommon.SendMessage(hwnd, NativeWindowCommon.BFFM_SETSELECTIONW, 1, this.selectedPath);
                }
                break;

            case NativeWindowCommon.BFFM_SELCHANGED:
            {
                IntPtr pidl = lParam;
                if (pidl != IntPtr.Zero)
                {
                    StringBuilder sb   = new StringBuilder(MAX_PATH * Marshal.SystemDefaultCharSize);
                    bool          flag = NativeWindowCommon.SHGetPathFromIDList(pidl, sb);
                    NativeWindowCommon.SendMessage(hwnd, NativeWindowCommon.BFFM_ENABLEOK, 0, flag ? 1 : 0);
                }

                if (!doneScrolling)
                {
                    IntPtr hbrowse = NativeWindowCommon.FindWindowEx(hwnd, IntPtr.Zero, "SHBrowseForFolder ShellNameSpace Control", null);
                    IntPtr htree   = NativeWindowCommon.FindWindowEx(hbrowse, IntPtr.Zero, "SysTreeView32", null);
                    IntPtr htis    = NativeHeader.SendMessage(htree, NativeWindowCommon.TVM_GETNEXTITEM, NativeWindowCommon.TVGN_CARET, IntPtr.Zero);

                    IntPtr htir = NativeHeader.SendMessage(htree, NativeWindowCommon.TVM_GETNEXTITEM, NativeWindowCommon.TVGN_ROOT, IntPtr.Zero);
                    IntPtr htic = NativeHeader.SendMessage(htree, NativeWindowCommon.TVM_GETNEXTITEM, NativeWindowCommon.TVGN_CHILD, htir);

                    //we actually go into the BFFM_SELCHANGED case three times when the dialog is first shown, and it's only on the third one that we actually scroll,
                    //since before this htic is always zero, so you need to cope with this
                    //- i.e. don't set 'doneScrolling' flag until htic has been non - zero(or until you've gone into the BFFM_SELCHANGED three times).
                    if ((int)htic != 0)
                    {
                        doneScrolling = true;
                        //The only solution I've found that works consistently is to send a TVM_ENSUREVISIBLE to the tree, using TVM_GETNEXTITEM/TVGN_CARET, from BFFM_SELCHANGED.
                        //That works. Every time.
                        NativeHeader.SendMessage(htree, NativeWindowCommon.TVM_ENSUREVISIBLE, 0, htis);

                        //Active the tree view control window inside the folder browser dialog to set the focus on it.
                        NativeWindowCommon.SendMessage(htree, NativeWindowCommon.WM_ACTIVATE, 1, 0);
                    }
                }
            }
            break;
            }
            return(0);
        }
Пример #4
0
        /// <summary>
        /// expand all panels
        /// </summary>
        public void ExpandAll()
        {
            // Suspend painting until all panels are visible
            NativeWindowCommon.SendMessage(Handle, NativeWindowCommon.WM_SETREDRAW, false, 0);

            foreach (Panel panel in Panels)
            {
                EnsureExpanded(panel);
            }

            // Resume painting
            NativeWindowCommon.SendMessage(Handle, NativeWindowCommon.WM_SETREDRAW, true, 0);

            Refresh(); // refresh
        }
Пример #5
0
        // <doc>

        // <desc>

        //      Called when our document becomes active.  We paint our form's

        //      border the appropriate color here.

        // </desc>

        // </doc>

        //

        private void OnDesignerActivate(object source, EventArgs evevent)
        {
            // Paint the form's title bar UI-active

            //

            Control control = Control;



            if (control != null && control.IsHandleCreated)
            {
                NativeWindowCommon.SendMessage(control.Handle, NativeWindowCommon.WM_NCACTIVATE, 1, 0);

                NativeWindowCommon.RedrawWindow(control.Handle, IntPtr.Zero, IntPtr.Zero, NativeWindowCommon.RedrawWindowFlags.RDW_FRAME);
            }
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        protected override void SetMargin(Control control)
        {
            base.SetMargin(control);
            // fixed defect #:135398  & 136561
            // same as old defect(fix in edt_edit.cpp)  QCR#793923: Caret for hebrew edit control is not seen fully when there is no text.
            // Exact reason for this problem is not known. However, setting right margin to 1, seems to
            // fix this problem. Other solution discussed was, removing WS_CLIPSIBLINGS style from
            // edit control. But this looked to be risky, as impact on the behavior for existing problems
            // cannot be predicted.

            // fixed 136561: this code must be execute after set right to left property
            if (Manager.Environment.Language == 'H')
            {
                NativeWindowCommon.SendMessage(control.Handle, NativeWindowCommon.EM_SETMARGINS,
                                               NativeWindowCommon.EC_LEFTMARGIN | NativeWindowCommon.EC_RIGHTMARGIN,
                                               NativeWindowCommon.MakeLong(0, 1));
            }
        }
Пример #7
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == NativeWindowCommon.WM_IME_COMPOSITION)
            {
                switch (CultureInfo.CurrentCulture.LCID)
                {
                case 1041: // Japanese (JPN: ZIMERead function)
                    if (((int)m.LParam & NativeWindowCommon.GCS_RESULTREADSTR) > 0)
                    {
                        int hIMC = NativeWindowCommon.ImmGetContext(this.Handle);

                        try
                        {
                            int size = NativeWindowCommon.ImmGetCompositionString(hIMC, NativeWindowCommon.GCS_RESULTREADSTR, null, 0);

                            StringBuilder buffer = new StringBuilder(size);
                            NativeWindowCommon.ImmGetCompositionString(hIMC, NativeWindowCommon.GCS_RESULTREADSTR, buffer, (uint)size);
                            string str = buffer.ToString().Substring(0, size / 2);
                            ImeReadStrBuilder.Append(str);
                        }
                        finally
                        {
                            NativeWindowCommon.ImmReleaseContext(this.Handle, hIMC);
                        }
                    }
                    break;

                case 1042: // Korean
                    if (KoreanInterimSel < 0)
                    {
                        KoreanInterimSel = NativeWindowCommon.SendMessage(this.Handle, NativeWindowCommon.EM_GETSEL, 0, 0);
                    }
                    break;
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_IME_ENDCOMPOSITION)
            {
                if (CultureInfo.CurrentCulture.LCID == 1042)
                {
                    KoreanInterimSel = -1;
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_PAINT)
            {
                if (isTransparent)
                {
                    NativeWindowCommon.SendMessage(this.Handle, NativeWindowCommon.WM_NCPAINT, 0, 0);
                }

                if (ControlStyle == ControlStyle.ThreeD)
                {
                    base.WndProc(ref m);
                    using (Graphics g = Graphics.FromHwnd(this.Handle))
                    {
                        BorderRenderer.PaintBorder(g, ClientRectangle, ForeColor, ControlStyle.ThreeD, false);
                        return;
                    }
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_NCCALCSIZE)
            {
                if (BorderStyle == BorderStyle.FixedSingle)
                {
                    RecalcNonClientArea(ref m);
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_NCPAINT)
            {
                if (BorderStyle == BorderStyle.FixedSingle)
                {
                    WMNCPaint(ref m);
                }
            }
            base.WndProc(ref m);
        }
Пример #8
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
#if !PocketPC
            case NativeWindowCommon.WM_COPYDATA:
                CopyData(this, new CopyDataEventArgs(m.LParam));
                break;

            case NativeWindowCommon.WM_WINDOWPOSCHANGING:
                WindowReposition(m);
                break;
#endif

            case NativeWindowCommon.WM_SIZING:
                if (Sizing != null)
                {
                    SizingEventArgs sizingEventArgs = new SizingEventArgs(
                        (NativeWindowCommon.SizingEdges)m.WParam,
                        (NativeWindowCommon.RECT)Marshal.PtrToStructure(m.LParam, typeof(NativeWindowCommon.RECT))
                        );
                    Sizing(this, sizingEventArgs);
                    Marshal.StructureToPtr(sizingEventArgs.DragRect, m.LParam, true);
                }
                break;

            case NativeWindowCommon.WM_SYSCOMMAND:
                if (!AllowMove && m.WParam.ToInt32() == NativeWindowCommon.SC_MOVE)
                {
                    return;
                }
                else
                {
                    //Defect #125874. It is .Net behavior (or bug?) that if MaximizeBox = false and the form is being maximized, it covers
                    //the whole screen --- even expanding below the task bar.
                    //So, temporarily set MaximizeBox = true.
                    bool isRestoring = (m.WParam.ToInt32().Equals(NativeWindowCommon.SC_RESTORE));
                    bool orgMaxBox   = this.MaximizeBox;
                    if (isRestoring)
                    {
                        this.MaximizeBox = true;
                    }

                    //Defect 81609: simulating behavior in unipass 1.9:
                    //the ACT_HIT message added to the queue by WM_NCLBUTTONDOWN, was not extracted untill whole WM_SYSCOMMAND was not exectuted.
                    //WM_SYSCOMMAND exits only after mouse is up and all needed windows are activated
                    //if we will handle ACT_HIT before it, WM_SYSCOMMAND will override our handling and activate clicked window disregarding magic logic.
                    base.WndProc(ref m);

                    if (isRestoring)
                    {
                        this.MaximizeBox = orgMaxBox;
                    }

                    RaiseMouseDownIfNeeded();
                    return;
                }

            case NativeWindowCommon.WM_NCLBUTTONDOWN:
            case NativeWindowCommon.WM_NCRBUTTONDOWN:
            case NativeWindowCommon.WM_NCLBUTTONDBLCLK:
                if (!AllowMove && m.WParam.ToInt32() == NativeWindowCommon.HTCAPTION && m.Msg == NativeWindowCommon.WM_NCLBUTTONDOWN)
                {
                    OnNCMouseDown(m);
                    return;
                }
                else
                {
                    int param = m.WParam.ToInt32();
                    Debug.Write("WM_NCLBUTTONDOWN Param=" + param);
                    Debug.Flush();
                    postponedMessage = m;
                    // Activate();
                }
                break;

            case NativeWindowCommon.WM_CHILDACTIVATE:
                NativeWindowCommon.SendMessage(this.Handle, NativeWindowCommon.WM_NCACTIVATE, 1, 0);
                break;

            case NativeWindowCommon.WM_NCACTIVATE:
                if (NCActivate != null && m.WParam.ToInt32() == 1)
                {
                    NCActivate(this, new EventArgs());
                }
                break;

            case NativeWindowCommon.WM_ACTIVATE:
                if (WMActivate != null)
                {
                    ActivateArgs args = new ActivateArgs();
                    args.WmParam = (int)m.WParam;
                    WMActivate(this, args);
                    if (args.StopActivation)      //restore focus to last form
                    {
                        return;
                    }
                }
                break;

            case NativeWindowCommon.WM_ACTIVATEAPP:
                if (m.WParam.ToInt32() == 1)     // application is activated
                {
                    activateAppTime = DateTime.Now;
                }

                break;

            case NativeWindowCommon.WM_MOUSEACTIVATE:
                mouseActivateAppTime = DateTime.Now;;
                break;
            }

            base.WndProc(ref m);
        }