protected override void WndProc(ref Message m)
        {
            TradeLinkMessage tlm = WMUtil.ToTradeLinkMessage(ref m);

            if (tlm == null)
            {
                base.WndProc(ref m);
                return;
            }
            string msg = tlm.body;

            long result = (long)TL2.OK;

            switch (tlm.type)
            {
            case TL2.ACCOUNTOPENPL:
                if (gotSrvAcctOpenPLRequest == null)
                {
                    break;
                }
                result = WMUtil.pack(gotSrvAcctOpenPLRequest(msg));
                break;

            case TL2.ACCOUNTCLOSEDPL:
                if (gotSrvAcctClosedPLRequest == null)
                {
                    break;
                }
                result = WMUtil.pack(gotSrvAcctClosedPLRequest(msg));
                break;

            case TL2.ACCOUNTREQUEST:
                if (gotSrvAcctRequest == null)
                {
                    break;
                }
                WMUtil.SendMsg(gotSrvAcctRequest(), TL2.ACCOUNTRESPONSE, Handle, msg);
                break;

            case TL2.ORDERCANCELREQUEST:
                if (OrderCancelRequest != null)
                {
                    OrderCancelRequest(Convert.ToUInt32(msg));
                }
                break;

            case TL2.GETSIZE:
                if (PositionSizeRequest != null)
                {
                    result = PositionSizeRequest(msg);
                }
                break;

            case TL2.AVGPRICE:
                if (PositionPriceRequest != null)
                {
                    result = WMUtil.pack(PositionPriceRequest(msg));
                }
                break;

            case TL2.NDAYHIGH:
                if (DayHighRequest != null)
                {
                    result = WMUtil.pack(DayHighRequest(msg));
                }
                break;

            case TL2.NDAYLOW:
                if (DayLowRequest != null)
                {
                    result = WMUtil.pack(DayLowRequest(msg));
                }
                break;

            case TL2.SENDORDER:
                SrvDoExecute(msg);
                break;

            case TL2.REGISTERCLIENT:
                SrvRegClient(msg);
                break;

            case TL2.REGISTERSTOCK:
                string[] m2 = msg.Split('+');
                SrvRegStocks(m2[0], m2[1]);
                break;

            case TL2.REGISTERINDEX:
                string[] ib = msg.Split('+');
                SrvRegIndex(ib[0], ib[1]);
                break;

            case TL2.CLEARCLIENT:
                SrvClearClient(msg);
                break;

            case TL2.CLEARSTOCKS:
                SrvClearStocks(msg);
                break;

            case TL2.HEARTBEAT:
                SrvBeatHeart(msg);
                break;

            case TL2.BROKERNAME:
                result = (long)Brokers.TradeLinkSimulation;
                break;

            case TL2.FEATUREREQUEST:
                TL2[]         f  = GetFeatures();
                List <string> mf = new List <string>();
                foreach (TL2 t in f)
                {
                    int ti = (int)t;
                    mf.Add(ti.ToString());
                }
                string msf = string.Join(",", mf.ToArray());
                WMUtil.SendMsg(msf, TL2.FEATURERESPONSE, Handle, msg);
                break;

            default:
                result = (long)TL2.FEATURE_NOT_IMPLEMENTED;
                break;
            }
            m.Result = (IntPtr)result;
        }