コード例 #1
0
ファイル: MgRichTextBox.cs プロジェクト: rinavin/RCJS
        /// <summary>
        /// Update the control parameter's styles.
        /// </summary>
        private void UpdateControlStyles()
        {
            int fStyle = NativeHeader.GetWindowLong(Handle, NativeHeader.GWL_EXSTYLE);

            if (BorderStyle == BorderStyle.FixedSingle)
            {
                // remove the Fixed3D border style
                fStyle &= ~NativeWindowCommon.WS_EX_CLIENTEDGE;
                InvalidateNC();
            }

            if (isTransparent)
            {
                fStyle |= NativeHeader.WS_EX_TRANSPARENT;
            }
            else
            {
                fStyle &= ~NativeHeader.WS_EX_TRANSPARENT;
            }

            NativeWindowCommon.SetWindowLong(Handle, NativeHeader.GWL_EXSTYLE, fStyle);

            fStyle = NativeHeader.GetWindowLong(Handle, NativeHeader.GWL_STYLE);
            if (base.RightToLeft == RightToLeft.Yes)
            {
                fStyle |= NativeHeader.WS_EX_LTRREADING;
                fStyle |= NativeHeader.WS_EX_RIGHT;
                fStyle |= NativeHeader.WS_EX_LEFTSCROLLBAR;
            }
            else if (base.RightToLeft == RightToLeft.No)
            {
                fStyle |= NativeHeader.WS_EX_RTLREADING;
                fStyle |= NativeHeader.WS_EX_LEFT;
                fStyle |= NativeHeader.WS_EX_RIGHTSCROLLBAR;
            }

            NativeWindowCommon.SetWindowLong(Handle, NativeHeader.GWL_STYLE, fStyle);
        }
コード例 #2
0
ファイル: MgComboBox.cs プロジェクト: rinavin/RCJS
 /// <summary> subclass the combobox - replace it's window proce
 /// </summary>
 void subclassCombobox()
 {
     proc        = new MobileWndProc(WindowProc);
     OrigWndProc = (IntPtr)NativeWindowCommon.SetWindowLong(Handle, NativeWindowCommon.GWL_WNDPROC,
                                                            Marshal.GetFunctionPointerForDelegate(proc).ToInt32());
 }
コード例 #3
0
ファイル: MgComboBox.cs プロジェクト: rinavin/RCJS
        protected int WndProc(ref Message m)
#endif
        {
            MouseEventArgs mouseEvents;

            switch (m.Msg)
            {
#if !PocketPC
            case NativeWindowCommon.CBN_DROPDOWN:
            {
                if (OriginalDropDownWindowProc == IntPtr.Zero)
                {
                    NativeWindowCommon.COMBOBOXINFO comboBoxInfo = new NativeWindowCommon.COMBOBOXINFO();
                    // alloc ptrComboBoxInfo
                    IntPtr ptrComboBoxInfo = Marshal.AllocHGlobal(Marshal.SizeOf(comboBoxInfo));

                    try
                    {
                        //get combo Box Info
                        comboBoxInfo.cbSize = (IntPtr)Marshal.SizeOf(comboBoxInfo);
                        Marshal.StructureToPtr(comboBoxInfo, ptrComboBoxInfo, true);
                        IntPtr intptr = NativeHeader.SendMessage(this.Handle, NativeWindowCommon.CB_GETCOMBOBOXINFO, 0, ptrComboBoxInfo);

                        //CB_GETCOMBOBOXINFO : If the send message succeeds, the return value is nonzero.
                        int returnValue = intptr.ToInt32();
                        if (returnValue > 0)
                        {
                            // get the info from ptrComboBoxInfo to comboBoxInfo
                            comboBoxInfo = (NativeWindowCommon.COMBOBOXINFO)Marshal.PtrToStructure(ptrComboBoxInfo, typeof(NativeWindowCommon.COMBOBOXINFO));

                            // save hwnd drop down list
                            HwndDropDownList = comboBoxInfo.hwndList;

                            //replace the window proc of the drop down list
                            CustomDropDownWindowProc = new ControlWndProc(DropDownWindowProc);

                            // save the original drop down list (most be member in the class so the garbig collection will not free it)
                            OriginalDropDownWindowProc = (IntPtr)NativeWindowCommon.SetWindowLong(HwndDropDownList,
                                                                                                  NativeWindowCommon.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(CustomDropDownWindowProc).ToInt32());
                        }
                        else
                        {
                            Debug.Assert(false);
                        }
                    }
                    finally
                    {
                        // free the ptrComboBoxInfo
                        Marshal.FreeHGlobal(ptrComboBoxInfo);
                    }
                }
            }
            break;
#endif
            case NativeWindowCommon.WM_LBUTTONDOWN:
            case NativeWindowCommon.WM_LBUTTONDBLCLK:
                if (!this.DroppedDown)
                {
                    // prevent drop down on combo - to prevent combo openning on non parkable controls
                    // - it must be handled manually
                    mouseEvents = new MouseEventArgs(MouseButtons.Left, 0,
                                                     NativeWindowCommon.LoWord((int)m.LParam), NativeWindowCommon.HiWord((int)m.LParam), 0);
                    this.OnMouseDown(mouseEvents);

                    // provide doubleclick event
#if !PocketPC
                    if (m.Msg == NativeWindowCommon.WM_LBUTTONDBLCLK)
                    {
                        this.OnMouseDoubleClick(mouseEvents);
                    }
                    return;
#else
                    return(0);
#endif
                }
                break;
            }

#if !PocketPC
            base.WndProc(ref m);
#else
            return(NativeWindowCommon.CallWindowProc(OrigWndProc, m.HWnd, (uint)m.Msg, (uint)m.WParam.ToInt32(), m.LParam.ToInt32()));
#endif
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: rinavin/RCJS
        private MobileWndProc _formProc; // object's delegate

        /// <summary>
        ///  subclass the window
        /// </summary>
        void subclassThisForm(IntPtr hwnd)
        {
            _formProc        = new MobileWndProc(formWindowProc);
            _origFormWndProc = (IntPtr)NativeWindowCommon.SetWindowLong(hwnd, NativeWindowCommon.GWL_WNDPROC,
                                                                        Marshal.GetFunctionPointerForDelegate(_formProc).ToInt32());
        }
コード例 #5
0
 //This is usually where the control handle is created - subclass
 void TableControl_HandleCreated(object sender, EventArgs e)
 {
     proc        = new MobileWndProc(WindowProc);
     OrigWndProc = (IntPtr)NativeWindowCommon.SetWindowLong(Handle, NativeWindowCommon.GWL_WNDPROC,
                                                            Marshal.GetFunctionPointerForDelegate(proc).ToInt32());
 }