鱼C论坛

 找回密码
 立即注册
查看: 1576|回复: 6

[已解决]VS2010+C++写的炒股软件如何添加参数

[复制链接]
发表于 2019-7-4 17:56:58 | 显示全部楼层 |阅读模式
50鱼币
本帖最后由 stone1005 于 2019-7-4 18:00 编辑

原来的炒股软件需要根据顶背离和底背离的运算计算出确认值,并显示到软件界面中,请高手帮忙看下,具体如下:
原界面:
03.png
需要达到的效果:
04.png
鼠标移动到波形曲线上点击后也要显示确认值:
06.png
代码如下:
// ViewGraph.cpp : 实现文件
// 显示股指分析图

#include "stdafx.h"
#include "WisdomClient.h"
#include "ViewGraph.h"
#include "afxdialogex.h"
#pragma comment(lib, "gdiplus.lib")

// CViewGraph 对话框;

IMPLEMENT_DYNAMIC(CViewGraph, CDialog)

CViewGraph::CViewGraph(CWnd* pParent /*=NULL*/)
        : CDialog(CViewGraph::IDD, pParent), mTextOffset(0), mDown(false), mUpMoveing(false), mDownMoveing(false), mDirtyData(false), mBmpW(-1000), mBmpH(0), mBmp(NULL), mBmp2(NULL), mShowMouseLine(false)
{
        AddHandlerWnd(this);
        GdiplusStartup(&mGdiplusToken, &mGdiplusStartupInput, NULL);
}

CViewGraph::~CViewGraph()
{
        DelHandlerWnd(this);
        GdiplusShutdown(mGdiplusToken);
}

void CViewGraph::DoDataExchange(CDataExchange* pDX)
{
        CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CViewGraph, CDialog)
        ON_WM_PAINT()
        ON_WM_SIZE()
END_MESSAGE_MAP()


// CViewGraph 消息处理程序;

BOOL CViewGraph::OnInitDialog()
{
        CDialog::OnInitDialog();

        ping_time_ = 0;
        msg_height_ = 436;

        Gdiplus::Color curveColor[CHART_COUNT] = {
                Color(255, 255, 255),//白色
                Color(255, 255, 0), //黄色
                Color(62, 72, 205),//白色
                Color(255, 0, 255) //紫红色
        };

        lastPlaySoundTime = 0;
        for (int32 i = 0; i < CHART_COUNT; ++i)
        {
                mCurveChart[i].SetCurveStyle(curveColor[i], Color(255, 255, 255));
        }

        mCurveChart[0].SetDrawLine(true, false);

        RECT rec;
        GetParent()->GetClientRect(&rec);
        MoveWindow(&rec);

        ::SetTimer(m_hWnd, 10, 1000 / 30, NULL);

        ::SetTimer(m_hWnd, 11, 1000, NULL);

        return TRUE;  // return TRUE unless you set the focus to a control
}

void CViewGraph::OnPaint()
{
        CPaintDC dc(this);

        //onPaint();
}

void CViewGraph::onPaint()
{
        RectF rectf;
        CString strTmp;

        RECT rec = {0};
        GetClientRect(&rec);

        CDC dcMemory;
        CDC* pDc = GetWindowDC();

        dcMemory.CreateCompatibleDC(pDc);

        FontFamily fontFamily(L"Arial");
        {
                if ( mBmp == NULL || mBmpW != rec.right || mBmpH != rec.bottom)
                {
                        delete mBmp;
                        delete mBmp2;

                        mBmp = new CBitmap();
                        mBmp2 = new CBitmap();

                        mBmp->CreateCompatibleBitmap(pDc, rec.right, rec.bottom);
                        mBmp2->CreateCompatibleBitmap(pDc, rec.right, rec.bottom);

                        mBmpW = rec.right;
                        mBmpH = rec.bottom;
                }

                dcMemory.SelectObject(mBmp);

                if ( mDirtyData == true || mShowMouseLine == true )
                {
                        mDirtyData = false;

                        Graphics g(dcMemory.m_hDC);

                        SolidBrush backBrush(Color(0, 0, 0));

                        //清除背景;
                        g.FillRectangle(&backBrush, 0, 0, rec.right, rec.bottom);

                        tm t;
                        time_t tt = time(NULL);
                        localtime_s(&t, &tt);

                        //画时间刻度;
                        RectF rectf;
                        SolidBrush brush_255_255_255(Color(255, 255, 255));
                        double cellWidth = mCurveChart[0].GetCellWidth();
                        Gdiplus::Font font_12(&fontFamily, 12, FontStyleRegular, UnitPixel);
                        //strTmp.Format(_T("%02d/%02d %02d:%02d"), t.tm_mon + 1, t.tm_mday, 9, 30);
                        //g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(-1, rec.bottom - GRAPH_BOTTOM + 4), &brush_255_255_255);

                        //计算时间点字符串的宽度和高度;
                        //strTmp.Format(_T("00:00"));
                        //g.MeasureString(strTmp.GetBuffer(), -1, &font_12, PointF(0, 0), &rectf);

                        double timeSpace = (rec.right - LEFT_DISTANCE - MESSAGE_WIDTH) / 2 / 4;

                        ////上午;
                        //for (int i = 0; i < 4; i++)
                        //{
                        //        strTmp.Format(_T("%02d:%02d"), 10 + (i / 2 ), i % 2 == 0 ? 0 : 30);
                        //        g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(LEFT_DISTANCE + timeSpace * (i + 1) - rectf.Width / 2, rec.bottom - GRAPH_BOTTOM + 4), &brush_255_255_255);
                        //}
                        ////下午;
                        //for (int i = 1; i < 5; i++)
                        //{
                        //        strTmp.Format(_T("%02d:%02d"), 13 + (i / 2 ), i % 2 == 0 ? 0 : 30);
                        //        g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(LEFT_DISTANCE + timeSpace * (3 + i + 1) - rectf.Width / 2, rec.bottom - GRAPH_BOTTOM + 4), &brush_255_255_255);
                        //}

                        //画出曲线;
                        for (int32 i = 0; i < CHART_COUNT; ++i)
                        {
                                mCurveChart[i].Paint(g, mCurveChart[0]);
                        }

                        ////画出中线;
                        //{
                        //        Pen splitPen(Color(255, 50, 50), 1);

                        //        int32 splitPosX = LEFT_DISTANCE + timeSpace * 4;// + 4;

                        //        g.DrawLine(&splitPen, splitPosX, 0, splitPosX, rec.bottom - GRAPH_BOTTOM + 2);
                        //}

                        //显示指标文字;
                        {
                                POINT pos;
                                GetCursorPos(&pos);
                                ScreenToClient(&pos);

                                int32 index = mCurveChart[0].GetLastIndex1();

                        
                                
                                if ( index != -1 )
                                {
                                        //SolidBrush brush2(Color(255, 253, 79));
                                        if (mShowMouseLine)
                                        {
                                                int32 nIndex = mCurveChart[0].GetIndex((int32)pos.x);
                                                int32 nLastIndex = mCurveChart[0].GetLastIndex1();

                                                if (nIndex > -1 && nIndex <= nLastIndex)
                                                {
                                                        index = nIndex;
                                                }
                                        }

                                        strTmp.Format(_T("股指期货:%.1f"), mCurveChart[0].GetRecordData1(index));

                                        g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[0].GetX() + LEFT_DISTANCE, mCurveChart[0].GetY()+ 2), mCurveChart[0].GetLineBrush1());

                                        

                                        if (index != 0)
                                        {
                                                strTmp.Format(_T("力度:%.3f%s"), mCurveChart[0].GetRecordData2(index), index <= 0 ? _T("↑") : (mCurveChart[1].GetRecordData2(index) > mCurveChart[1].GetRecordData2(index - 1) ? _T("↑") : _T("↓")));
                                                g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[0].GetX() + LEFT_DISTANCE + 180, mCurveChart[0].GetY()+ 2), mCurveChart[0].GetLineBrush2());
                                                //xiugai
                                           //g.DrawString("-300", -1, &font_12, PointF(mCurveChart[0].GetX() + LEFT_DISTANCE + 220, mCurveChart[0].GetY()+ 2),mCurveChart[0].GetLineBrush2());
                                        }
                                }

                                index = mCurveChart[1].GetLastIndex1();
                                if ( index != -1 )
                                {
                                        //SolidBrush brush2(Color(255, 255, 255));
                                        if (mShowMouseLine)
                                        {
                                                int32 nIndex = mCurveChart[0].GetIndex((int32)pos.x);
                                                int32 nLastIndex = mCurveChart[0].GetLastIndex1();

                                                if (nIndex > -1 && nIndex <= nLastIndex)
                                                {
                                                        index = nIndex;
                                                }
                                        }

                                        strTmp.Format(_T("指标一:%.0f"), mCurveChart[1].GetRecordData1(index));
                                        
                                        g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[1].GetX() + LEFT_DISTANCE, mCurveChart[1].GetY()+ 2), mCurveChart[1].GetLineBrush1());

                                        //index = mCurveChart[1].GetLastIndex2();
                                        if ( index != 0 )
                                        {
                                                //SolidBrush brush3(Color(200, 37, 200));
                                                strTmp.Format(_T("力度:%.3f%s"), mCurveChart[1].GetRecordData2(index), index <= 0 ? _T("↑") : (mCurveChart[1].GetRecordData2(index) > mCurveChart[1].GetRecordData2(index - 1) ? _T("↑") : _T("↓")));
                                                g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[1].GetX() + LEFT_DISTANCE + 180, mCurveChart[1].GetY()+ 2), mCurveChart[1].GetLineBrush2());
                                        }
                                }

                                index = mCurveChart[2].GetLastIndex1();
                                if ( index != -1 )
                                {
                                        //SolidBrush brush2(Color(255, 255, 255));
                                        if (mShowMouseLine)
                                        {
                                                int32 nIndex = mCurveChart[0].GetIndex((int32)pos.x);
                                                int32 nLastIndex = mCurveChart[0].GetLastIndex1();

                                                if (nIndex > -1 && nIndex <= nLastIndex)
                                                {
                                                        index = nIndex;
                                                }
                                        }

                                        strTmp.Format(_T("指标二:%.0f"), mCurveChart[2].GetRecordData1(index));
                                        g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[2].GetX() + LEFT_DISTANCE, mCurveChart[2].GetY()+ 2), mCurveChart[2].GetLineBrush1());

                                        //index = mCurveChart[2].GetLastIndex2();
                                        if ( index != -1 )
                                        {
                                                //SolidBrush brush3(Color(200, 37, 200));
                                                strTmp.Format(_T("力度:%.3f%s"), mCurveChart[2].GetRecordData2(index), index <= 0 ? _T("↑") : (mCurveChart[2].GetRecordData2(index) > mCurveChart[2].GetRecordData2(index - 1) ? _T("↑") : _T("↓")));
                                                g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[2].GetX() + LEFT_DISTANCE + 180, mCurveChart[2].GetY()+ 2), mCurveChart[2].GetLineBrush2());
                                        }
                                }

                                index = mCurveChart[3].GetLastIndex1();
                                if ( index != -1 )
                                {
                                        //SolidBrush brush2(Color(255, 255, 255));
                                        if (mShowMouseLine)
                                        {
                                                int32 nIndex = mCurveChart[0].GetIndex((int32)pos.x);
                                                int32 nLastIndex = mCurveChart[0].GetLastIndex1();

                                                if (nIndex > -1 && nIndex <= nLastIndex)
                                                {
                                                        index = nIndex;
                                                }
                                        }

                                        strTmp.Format(_T("指标三:%.0f"), mCurveChart[3].GetRecordData1(index));
                                        g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[3].GetX() + LEFT_DISTANCE, mCurveChart[3].GetY()+ 2), mCurveChart[3].GetLineBrush1());

                                        //index = mCurveChart[3].GetLastIndex2();
                                        if ( index != -1 )
                                        {
                                                //SolidBrush brush3(Color(200, 37, 200));
                                                strTmp.Format(_T("力度:%.3f%s"), mCurveChart[3].GetRecordData2(index), index <= 0 ? _T("↑") : (mCurveChart[3].GetRecordData2(index) > mCurveChart[3].GetRecordData2(index - 1) ? _T("↑") : _T("↓")));
                                                g.DrawString(strTmp.GetBuffer(), -1, &font_12, PointF(mCurveChart[3].GetX() + LEFT_DISTANCE + 180, mCurveChart[3].GetY()+ 2), mCurveChart[3].GetLineBrush2());
                                        }
                                }
                        }



                        //专家点评;
                        {
                                SolidBrush brush255_255_255(Color(255, 255, 255));
                                SolidBrush brush255_50_50(Color(255, 25, 25));
                                SolidBrush brush255_0_255(Color(255, 0, 255));
                                Gdiplus::Font font(&fontFamily, 24, FontStyleBold, UnitPixel);
                                Gdiplus::Font font2(&fontFamily, 12, FontStyleRegular, UnitPixel);
                                
                                RectF rectf;
                                strTmp.Format(_T("专家点评"));
                                g.MeasureString(strTmp.GetBuffer(), -1, &font, PointF(0, 0), &rectf);//计算时间点字符串的宽度和高度;
                                g.DrawString(L"专家点评", -1, &font, PointF(rec.right - MESSAGE_WIDTH + (MESSAGE_WIDTH - rectf.Width) / 2, 15 ), &brush255_255_255);

                                Pen pen255_0_0(Color(255, 0, 0), 3);
                                strTmp.Format(_T("专家意见,仅供参考"));
                                g.MeasureString(strTmp.GetBuffer(), -1, &font2, PointF(0, 0), &rectf);//计算时间点字符串的宽度和高度;
                                g.DrawString(L"专家意见,仅供参考", -1, &font2, PointF(rec.right - MESSAGE_WIDTH + (MESSAGE_WIDTH - rectf.Width) / 2, 42), &brush255_0_255);

                                g.DrawLine(&pen255_0_0, rec.right - MESSAGE_WIDTH, 60, rec.right, 60);

                                mUpMoveing = mDownMoveing = false;

                                //150,437;
                                int n = 0;
                                int nCount = 0;
                                
                                //FOR_LIST_CONST(wstring, it, mBroadcastMsg)
                                for (list<wstring>::reverse_iterator it = mBroadcastMsg.rbegin(); it != mBroadcastMsg.rend(); ++it)
                                {
                                        n++;

                                        RectF rectf;

                                        const wstring& msg = *it;

                                        list<wstring> strlist;

                                        wchar_t buff[1024] = {0};

                                        int nOffset = 0;

                                        int nLen = 1;

                                        for (int i = 0; i < msg.length(); i++)
                                        {
                                                g.MeasureString(msg.c_str() + nOffset, nLen, &font2, PointF(0, 0), &rectf);

                                                if ( rectf.Width > (MESSAGE_WIDTH - 15) )
                                                {
                                                        memset(buff, 0, sizeof(buff));

                                                        memcpy_s(buff, sizeof(buff), msg.c_str() + nOffset, nLen * sizeof(wchar_t));

                                                        strlist.push_back(buff);

                                                        nOffset += nLen;

                                                        nLen = 1;
                                                }
                                                else
                                                {
                                                        nLen++;
                                                }
                                        }

                                        if ( nLen != 0 )
                                        {
                                                memset(buff, 0, sizeof(buff));

                                                memcpy_s(buff, sizeof(buff), msg.c_str() + nOffset, (msg.length() - nOffset) * sizeof(wchar_t));

                                                strlist.push_back(buff);

                                                nLen = 0;
                                        }


                                        CString str;

                                        //画文字;
                                        int idx = 0;
                                        FOR_LIST_CONST(wstring, it2, strlist)
                                        {
                                                wstring text = *it2;

                                                if (idx == 0)
                                                {//画消息开头后的日期;
                                                        int index = text.find_first_of('\n');
                                                        wstring wtemp = text.substr(0, index);
                                                        text = text.substr(text.find_first_of('\n') + 1);
                                                        if ( (MESSAGE_TOP + nCount - mTextOffset) >= MESSAGE_TOP && (MESSAGE_TOP + nCount - mTextOffset) <= MESSAGE_TOP + msg_height_ )
                                                        {
                                                                g.MeasureString(wtemp.c_str(), wtemp.length(), &font2, PointF(0, 0), &rectf);
                                                                g.DrawString(wtemp.c_str(), wtemp.length(), &font2, PointF(  rec.right - MESSAGE_WIDTH + 5, MESSAGE_TOP + nCount - mTextOffset ), &brush255_255_255);
                                                        }
                                                        else
                                                        {
                                                                if ( (MESSAGE_TOP + nCount - mTextOffset) < MESSAGE_TOP && n == 1 )
                                                                {
                                                                        mDownMoveing = true;
                                                                }

                                                                if ( (MESSAGE_TOP + nCount - mTextOffset) > MESSAGE_TOP + msg_height_ )
                                                                {
                                                                        mUpMoveing = true;
                                                                }
                                                        }
                                                        nCount += rectf.Height;
                                                }

                                                if ( (MESSAGE_TOP + nCount - mTextOffset) >= MESSAGE_TOP && (MESSAGE_TOP + nCount - mTextOffset) <= MESSAGE_TOP + msg_height_ )
                                                {
                                                        g.DrawString(text.c_str(), text.length(), &font2, PointF(  rec.right - MESSAGE_WIDTH + 5, MESSAGE_TOP + nCount - mTextOffset ), &brush255_50_50);
                                                }
                                                else
                                                {
                                                        if ( (MESSAGE_TOP + nCount - mTextOffset) < MESSAGE_TOP && n == 1 )
                                                        {
                                                                mDownMoveing = true;
                                                        }

                                                        if ( (MESSAGE_TOP + nCount - mTextOffset) > MESSAGE_TOP + msg_height_ )
                                                        {
                                                                mUpMoveing = true;
                                                        }
                                                }
                                                g.MeasureString(text.c_str(), text.length(), &font2, PointF(0, 0), &rectf);
                                                nCount += rectf.Height;

                                                idx++;
                                        }

                                        nCount += 12;
                                }
                        }
                }
        }

        //画十字交叉线;
        if (mShowMouseLine == true)
        {
                POINT pos;
                GetCursorPos(&pos);
                ScreenToClient(&pos);

                if ( pos.x >= LEFT_DISTANCE && pos.x <= (mCurveChart[0].GetX() + mCurveChart[0].GetWidth()))
                {
                        CDC dcMemory2;
                        dcMemory2.CreateCompatibleDC(pDc);
                        CBitmap Bmp2;
                        Bmp2.CreateCompatibleBitmap(pDc, rec.right, rec.bottom);
                        dcMemory2.SelectObject(&Bmp2);
                        dcMemory2.BitBlt(0, 0, rec.right, rec.bottom, &dcMemory, 0, 0, SRCCOPY);
                        Graphics g(dcMemory2.m_hDC);
                        SolidBrush brush(Color(255, 255, 255));
                        SolidBrush brush2(Color(255, 20, 20));
                        Gdiplus::Font font(&fontFamily, 24, FontStyleBold, UnitPixel);
                        Gdiplus::Font font2(&fontFamily, 12, FontStyleRegular, UnitPixel);
                        Pen pen1(Color(0x50, 0x50, 0x50), 1);
                        Pen penpos(Color(255, 255, 255), 5);

                        //画鼠标跟随线;
                        g.DrawLine(&pen1, LEFT_DISTANCE + 1, pos.y, mCurveChart[0].GetX() + mCurveChart[0].GetWidth() - 1, pos.y);//横向;
                        g.DrawLine(&pen1, pos.x, 1, pos.x, rec.bottom - GRAPH_BOTTOM + 2);//纵向;

                        int32 nIndex = mCurveChart[0].GetIndex((int32)pos.x);
                        int32 nLastIndex = mCurveChart[0].GetLastIndex1();

                        if (nIndex > -1 && nIndex <= nLastIndex)
                        {
                                for (int32 i = 0; i < CHART_COUNT; ++i)
                                {
                                        int32 offsetPos = FLOAT_POINT_RADIUS / 2;
                                        //画出鼠标位置对应曲线上的点;
                                        g.FillEllipse(mCurveChart[i].GetLineBrush1(), mCurveChart[i].GetPosX1(nIndex) - offsetPos + 1, mCurveChart[i].GetPosY1(nIndex) - offsetPos, FLOAT_POINT_RADIUS, FLOAT_POINT_RADIUS);
                                        //画出曲线点上的数据;
//                                         strTmp.Format(_T("%.0f"), mCurveChart[i].GetRecordData1(nIndex));
//                                         g.DrawString(strTmp.GetBuffer(), -1, &font2, PointF(mCurveChart[i].GetPosX1(nIndex) + offsetPos + 1, mCurveChart[i].GetPosY1(nIndex) + offsetPos), mCurveChart[i].GetLineBrush1());

                                        if (i != 0)
                                        {
                                                //画出鼠标位置对应曲线上的点;
                                                g.FillEllipse(mCurveChart[i].GetLineBrush2(), mCurveChart[i].GetPosX2(nIndex) - offsetPos + 1, mCurveChart[i].GetPosY2(nIndex) - offsetPos, FLOAT_POINT_RADIUS, FLOAT_POINT_RADIUS);
                                                //画出曲线点上的数据;
//                                                 strTmp.Format(_T("%.0f"), mCurveChart[i].GetRecordData2(nIndex));
//                                                 g.MeasureString(strTmp.GetBuffer(), -1, &font2, PointF(0, 0), &rectf);
//                                                 g.DrawString(strTmp.GetBuffer(), -1, &font2, PointF(mCurveChart[i].GetPosX2(nIndex) + offsetPos - 1 - rectf.Width, mCurveChart[i].GetPosY2(nIndex) + offsetPos), mCurveChart[i].GetLineBrush2());
                                        }
                                }

                                GetCursorPos(&pos);
                                ScreenToClient(&pos);
                                SolidBrush brushRectangle(Color(128, 230, 50, 50));
                                Pen penRectangle(Color(150, 20, 20), 1);
                                g.FillRectangle(&brushRectangle, pos.x + 11, pos.y + 11, 37, 14);
                                g.DrawRectangle(&penRectangle, pos.x + 11, pos.y + 11, 36, 14);
                                strTmp.Format(_T("%02d:%02d"), mCurveChart[0].GetRecordHour1(nIndex), mCurveChart[0].GetRecordMinute1(nIndex));
                                g.DrawString(strTmp.GetBuffer(), -1, &font2, PointF(pos.x + 10 + 1, pos.y + 10 + 1), &brush);
                        }

                        pDc->BitBlt(0, 0, rec.right, rec.bottom, &dcMemory2, 0, 0, SRCCOPY);
                }
                else
                {
                        pDc->BitBlt(0, 0, rec.right, rec.bottom, &dcMemory, 0, 0, SRCCOPY);
                }
        }
        else
        {
                pDc->BitBlt(0, 0, rec.right, rec.bottom, &dcMemory, 0, 0, SRCCOPY);
        }

        ReleaseDC(pDc);
}

LRESULT CViewGraph::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
        if ( message == RECEIVE_PACKET_MSG )
        {
                switch(wParam)
                {
                case RES_UPDATE_RECORD:
                        {
                                mDirtyData = true;

                                ResUpdateRecord* pResUpdateRecord = (ResUpdateRecord*)lParam;

                                RecordData data;
                                data.index        =        pResUpdateRecord->ridx;
                                data.hour        =        pResUpdateRecord->hour;
                                data.minute        =        pResUpdateRecord->minute;
                                data.data        =        pResUpdateRecord->data;

                                switch(pResUpdateRecord->index)
                                {
                                case 0:
                                        mCurveChart[0].UpdateRecord1(data);
                                        break;
                                case 1:
                                        mCurveChart[1].UpdateRecord1(data);
                                        break;
                                case 2:
                                        mCurveChart[1].UpdateRecord2(data);
                                        break;
                                case 3:
                                        mCurveChart[2].UpdateRecord1(data);
                                        break;
                                case 4:
                                        mCurveChart[2].UpdateRecord2(data);
                                        break;
                                case 5:
                                        mCurveChart[3].UpdateRecord1(data);
                                        break;
                                case 6:
                                        mCurveChart[3].UpdateRecord2(data);
                                        break;
                                case 7:
                                        mCurveChart[0].UpdateRecord2(data);
                                        break;
                                default:
                                        break;
                                }
                        }
                        break;
                case RES_CLEAR_YESTODAY:
                        {
                                mDirtyData = true;

                                mBroadcastMsg.clear();

                                for (int32 i = 0; i < CHART_COUNT; ++i)
                                {
                                        mCurveChart[i].ClearRecord();
                                }
                        }
                        break;
                case RES_BROADCAST_MSG:
                        {
                                mDirtyData = true;

                                ResBroadcastMsg* pResBroadcastMsg = (ResBroadcastMsg*)lParam;
                                mBroadcastMsg.push_back( Encoding::ToWstring(pResBroadcastMsg->msg) );

                                time_t currenttime = time(NULL);
                                if (lastPlaySoundTime != currenttime)
                                {
                                        lastPlaySoundTime = currenttime;
                                        PlaySound(MAKEINTRESOURCE(IDR_WAVE1),AfxGetResourceHandle(), SND_ASYNC|SND_RESOURCE|SND_NODEFAULT);
                                }
                        }
                        break;
                case RES_PING:
                        {
                                ping_time_ = 0;
                        }
                        break;
                }
        }

        return CDialog::WindowProc(message, wParam, lParam);
}

BOOL CViewGraph::PreTranslateMessage(MSG* pMsg)
{
        switch(pMsg->message)
        {
        case WM_LBUTTONDOWN:
                {
                        mDown = true;
                        mDownPos.x = GET_X_LPARAM(pMsg->lParam);
                        mDownPos.y = GET_Y_LPARAM(pMsg->lParam);
                }
                break;
        case WM_LBUTTONUP:
                {
                        if ( mDown == true )
                        {
                                mDirtyData = true;
                                mShowMouseLine = !mShowMouseLine;
                        }

                        mDown = false;
                }
                break;
        case WM_MOUSEMOVE:
                {
                        if ( mDown == true )
                        {
                                POINT pos;
                                pos.x = GET_X_LPARAM(pMsg->lParam);
                                pos.y = GET_Y_LPARAM(pMsg->lParam);

                                if ( mDownMoveing && mDownPos.y < pos.y )
                                        mTextOffset += mDownPos.y - pos.y;
                                else if ( mUpMoveing  && mDownPos.y > pos.y )
                                        mTextOffset += mDownPos.y - pos.y;

                                mDownPos = pos;

                                mDirtyData = true;
                        }
                }
                break;
        case WM_TIMER:
                {
                        if ( pMsg->wParam == 10 )
                        {
                                onPaint();
                        }
                        else if (pMsg->wParam == 11 && IsConnected())
                        {
                                uint64 ms = util::GetTickMillionSeconds();
                                if (ping_time_ > 0)
                                {
                                        if ((ms - ping_time_) > 9500)
                                        {
                                                KillTimer(11);
                                                SocketMgr::get_singleton().CloseListenOrConnect(CONNECT_TYPE_SERVER);
                                                return CDialog::PreTranslateMessage(pMsg);
                                        }
                                }
                                else
                                {
                                        ping_time_ = ms;
                                }

                                ReqPing* pReqPing = (ReqPing*)ReqPing::CreatePacket();
                                ToServer(pReqPing);
                        }
                }
                break;
        }

        return CDialog::PreTranslateMessage(pMsg);
}


void CViewGraph::OnSize(UINT nType, int cx, int cy)
{
        CDialog::OnSize(nType, cx, cy);
        RECT rec;
        GetParent()->GetClientRect(&rec);
        int32 chartWidth = rec.right - MESSAGE_WIDTH;
        int32 chartHeight = (rec.bottom - GRAPH_BOTTOM) / CHART_COUNT;
        msg_height_ = rec.bottom - MESSAGE_TOP - MESSAGE_BOTTOM;
        for (int32 i = 0; i < CHART_COUNT; ++i)
        {
                if (i == 0)
                {
                        mCurveChart[i].MoveChart(0, chartHeight * i, chartWidth, chartHeight);
                }
                else
                {
                        mCurveChart[i].MoveChart(0, chartHeight * i + CHART_SPACE * i, chartWidth, chartHeight);
                }
        }
        mDirtyData = true;
        onPaint();
}

void CViewGraph::OnOK()
{

}

void CViewGraph::OnCancel()
{

}
最佳答案
2019-7-4 17:56:59
修改过了。请查收。

最佳答案

查看完整内容

修改过了。请查收。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-7-4 17:56:59 | 显示全部楼层    本楼为最佳答案   
修改过了。请查收。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-7-4 19:26:14 | 显示全部楼层
大哥,这个真不会。看都没看懂。。。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-7-5 11:32:48 | 显示全部楼层
去些VC论坛问吧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-7-6 15:44:20 | 显示全部楼层
高手,,,
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-7-11 15:09:55 | 显示全部楼层
你把完整的一套代码文件发过来我看。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2019-7-11 15:12:43 | 显示全部楼层
maofei0602 发表于 2019-7-11 15:09
你把完整的一套代码文件发过来我看。

OK
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-3 23:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表