Beispiel #1
0
        public bool onMessageHandle(int uMsg, ref object wParam, ref object lParam, ref int lRes)
        {
            if (uMsg == (int)WindowMessage.WM_CREATE)
            {
                Form frm = this;
                mManager.init(ref frm);
                // 给下拉列表子控件树重新设置父容器以及资源管理器,在组合框窗口关闭后需要还原该子树控件的父容器以及资源管理器
                mVerticalLayout = new VerticalLayoutUI();
                mManager.useParentResource(mOwner.getManager());
                mVerticalLayout.setManager(mManager, null);
                string pDefaultAttributes = mOwner.getManager().getDefaultAttributeList("VerticalLayout");
                if (pDefaultAttributes != "")
                {
                    mVerticalLayout.applyAttributeList(pDefaultAttributes);
                }
                mVerticalLayout.setInset(new Rectangle(2, 2, 0, 0));
                mVerticalLayout.setBackColor(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
                mVerticalLayout.setBorderColor(Color.FromArgb(0xFF, 0x85, 0xE4, 0xFF));
                mVerticalLayout.setBorderSize(2);
                mVerticalLayout.setAutoDestroy(false);
                mVerticalLayout.enableScrollBar();
                mVerticalLayout.applyAttributeList(mOwner.getDropBoxAttributeList());
                for (int i = 0; i < mOwner.getCount(); i++)
                {
                    mVerticalLayout.add((ControlUI)mOwner.getItemAt(i));
                }
                ControlUI rootNode = (ControlUI)mVerticalLayout;
                mManager.attachDialog(ref rootNode);

                this.ClientSize = new Size(mRectClient.Width, mRectClient.Height);

                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_SIZE)
            {
                this.ClientSize = new Size(mRectClient.Width, mRectClient.Height);

                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_ERASEBKGND)
            {
                lRes = 1;

                return(true);
            }

            else if (uMsg == (int)WindowMessage.WM_CLOSE)
            {
                mOwner.setManager(mOwner.getManager(), mOwner.getParent());
                mOwner.setPos(mOwner.getPos());
                mOwner.setFocus();
            }
            else if (uMsg == (int)WindowMessage.WM_LBUTTONUP)
            {
                Point pt = Control.MousePosition;
                pt = mManager.getPaintWindow().PointToClient(pt);
                ControlUI pControl = mManager.findControl(ref pt);
                if (pControl != null && pControl.getClass() != "ScrollbarUI")
                {
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);
                }
            }

            else if (uMsg == (int)WindowMessage.WM_KEYDOWN)
            {
                IntPtr ptr = (IntPtr)wParam;
                int    c   = (int)ptr;
                char   cc  = (char)int.Parse(c.ToString());
                switch ((Keys)cc)
                {
                case Keys.Escape:
                    mOwner.selectItem(mOldSel);
                    ensureVisible(mOldSel);
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);

                    break;

                case Keys.Return:
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);
                    break;

                default:
                    TEventUI newEvent = new TEventUI();
                    newEvent.mType = (int)EVENTTYPE_UI.UIEVENT_KEYDOWN;
                    newEvent.mKey  = cc;
                    mOwner.eventProc(ref newEvent);
                    ensureVisible(mOwner.getCurSel());
                    return(true);
                }
            }
            else if (uMsg == (int)WindowMessage.WM_MOUSEWHEEL)
            {
                IntPtr ptr = (IntPtr)wParam;
                int    c   = (int)ptr;

                int      zDelta   = (int)(short)HIWORD(c);
                TEventUI newEvent = new TEventUI();
                newEvent.mType      = (int)EVENTTYPE_UI.UIEVENT_SCROLLWHEEL;
                newEvent.mWParam    = makeLong(zDelta < 0 ? (int)ScrollBarCommands.SB_LINEDOWN : (int)ScrollBarCommands.SB_LINEUP, 0);
                newEvent.mLParam    = lParam;
                newEvent.mTimestamp = PaintManagerUI.GetTickCount();
                mOwner.eventProc(ref newEvent);
                ensureVisible(mOwner.getCurSel());
                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_KILLFOCUS)
            {
                close();
            }

            if (mManager != null && mManager.messageHandler((uint)uMsg, ref wParam, ref lParam, ref lRes))
            {
                return(true);
            }

            return(false);
        }