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();
}
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() };
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();}
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();
}
{
// 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()
};
{ 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();}
现在我改了一下在CPropertyPage里的picture控件画不出,但在外面是能画出的不知道我能不能解释清楚这个问题
有哪位肯帮忙来QQ聊一下
QQ:12665590