写了一个在对话框上picture控件位置画图的程序是可以用的
但现在定义了一个类是CPropertyPage,同样程序就画不出来了
请问是啥原因?

解决方案 »

  1.   


    void CEx3Dlg::OnTest() 
    { int i, j, k, x, y; for ( i = 0; i < MAXCOL; i++ )
    for ( j = 0; j< MAXROW; j++ )
    {
    for ( k = 0; k < graph.nOneWellHeight; k++ )
    {
    x = graph.nX_Offset + i*graph.nOneWellWidth + k;
    y = graph.nY_Offset + (j+1)*graph.nOneWellHeight - k;
    graph.DrawDot( x, y, RED );
    }
    }
    }void CEx3Dlg::DisplayBase() 
    { int i, j, x, y; for ( i = 0; i < MAXCOL; i++ )
    for ( j = 0; j< MAXROW; j++ )
    {
    x = graph.nX_Offset + i*graph.nOneWellWidth;
    y = graph.nY_Offset + j*graph.nOneWellHeight;
    graph.DrawRectangle( x, 4 + j*graph.nOneWellHeight, graph.nOneWellWidth, graph.nOneWellHeight, GREEN );
    x = x + 2;
    y = y + 2;
    }
    }void CEx3Dlg::OnClear() 
    { DisplayBase();
    // PostMessage( (BYTE)this, WM_PAINT );
    // UpdateWindow();

    }
      

  2.   

    class CWellGraph : public CDialog
    {
    // Construction
    public:
    CWellGraph(CWnd* pParent = NULL);   // standard constructor
    int nOneWellWidth;  // one well' width
    int nOneWellHeight; // one well' height
    int nX_Offset, nY_Offset; // x, y' offset void DrawRectangle( int x1, int y1, int width, int height, int color );
    void DrawDot( int x, int y, int color );// Dialog Data
    //{{AFX_DATA(CWellGraph)
    enum { IDD = IDD_EX3_DIALOG };
    // NOTE: the ClassWizard will add data members here
    //}}AFX_DATA
    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CWellGraph)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected: // Generated message map functions
    //{{AFX_MSG(CWellGraph)
    // NOTE: the ClassWizard will add member functions here
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
      

  3.   

    void CWellGraph::DrawRectangle( int x1, int y1, int width, int height, int color )
    { CDC* pDC = AfxGetMainWnd()->GetDC(); CPen newPen (PS_SOLID, 1, color ); 
    CPen *pOldPen=pDC->SelectObject(&newPen); pDC->Rectangle( x1, y1, x1+ width, y1+height );
    pDC->SelectObject(pOldPen);
    pDC->DeleteDC();}
      

  4.   

    你的代码里面哪儿和CPropertyPage类有关?
      

  5.   

    CWellGraph类是从CPropertyPage类继承的,当程序运行时需要装载不同的对象,所以这样定义了
    现在我改了一下在CPropertyPage里的picture控件画不出,但在外面是能画出的不知道我能不能解释清楚这个问题
    有哪位肯帮忙来QQ聊一下
    QQ:12665590