본문 바로가기

[VC소스]VIEW에 낙서하기

파이팅건맨 1999.11.12 01:05 조회 수 : 952

VC의 VIEW에 대한 기초 다지기에 도움이 될 소스입니다. 리포트라 임시로 올려둡니돠.
많은 이용바람...^.^;


//* Document Class - CDrawDoc class CDrawDoc : public CDocument { protected: // create from serialization only CDrawDoc(); DECLARE_DYNCREATE(CDrawDoc) // Attributes public: int iMousePosX[5000], iMousePosY[5000]; bool bFlag; int count; // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDrawDoc) public: virtual BOOL OnNewDocument(); virtual void Serialize(CArchive& ar); //}}AFX_VIRTUAL // Implementation public: virtual ~CDrawDoc(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CDrawDoc) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; * CDrawView Class – Member Functions void CDrawView::OnDraw(CDC* pDC) { CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here if(pDoc->bFlag) OnDrawPixel(); } void CDrawView::OnDrawPixel() { // TODO: Add your command handler code here CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CClientDC dc(this); pDoc->bFlag = true; for(int i=0;i<=pDoc->count;i++) dc.SetPixel(pDoc->iMousePosX[i],pDoc->iMousePosY[i],RGB(255,0,0)); } void CDrawView::OnDrawAll() { // TODO: Add your command handler code here CPen pen, pen2, pen3; int iPosX, iPosY; CRect rect; CBrush Brush1; CPoint point[7]; CClientDC dc(this); pen.CreatePen(PS_SOLID,1,RGB(55,55,55)); pen2.CreatePen(PS_SOLID,30,RGB(255,0,0)); pen3.CreatePen(PS_SOLID,10,RGB(0,0,150)); Brush1.CreateStockObject(LTGRAY_BRUSH); GetClientRect(&rect); CPen *pOldPen = (CPen *)dc.SelectObject(&pen); for(iPosY=0;iPosY<=rect.bottom;iPosY+=10){ dc.MoveTo(0,0); dc.LineTo(rect.right,iPosY); } for(iPosX=rect.right;iPosX>=0;iPosX-=10){ dc.MoveTo(0,0); dc.LineTo(iPosX,rect.bottom); } dc.SelectObject(&pen2); Rectangle(dc,10,10,100,100); rect.top = 200; rect.left = 200; rect.right = 300; rect.bottom = 300; FillRect(dc,&rect,Brush1); rect.top = 300; rect.left = 300; rect.right = 400; rect.bottom = 400; FrameRect(dc,rect,Brush1); rect.top = 350; rect.left = 350; rect.right = 500; rect.bottom = 500; dc.Draw3dRect(rect,RGB(200,200,0),RGB(50,100,100)); dc.SelectObject(&pen3); Ellipse(dc,400,400,500,20); Pie(dc,10,10,20,20,30,30,40,40); dc.SelectObject(&pen); Arc(dc,100,100,150,150,200,200,250,250); AngleArc(dc,70,80,2000,110.5,20.5); dc.SelectObject(&pen3); Chord(dc,80,80,90,95,100,100,120,220); point[0] = CPoint(200,10); point[1] = CPoint(250,20); point[2] = CPoint(250,100); point[3] = CPoint(220,150); point[4] = CPoint(150,100); point[5] = CPoint(150,20); point[6] = CPoint(180,10); Polygon(dc,point,7); dc.SelectObject(pOldPen); } void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(pDoc->bFlag){ pDoc->iMousePosX[pDoc->count] = point.x; pDoc->iMousePosY[pDoc->count] = point.y; (pDoc->count)++; Invalidate(); } CView::OnLButtonDown(nFlags, point); } void CDrawView::OnNop() { // TODO: Add your command handler code here CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pDoc->bFlag = false; }




번호 제목 날짜 조회 수
HOT [TIP] PYTHON 에서 "UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 6987: illegal multibyte sequence" 오류 날때... [52] 2016.02.20 266446
HOT [펌] ARM GCC Inline Assembler Cookbook 2006.08.18 57977
HOT [TIP] R에서 페이스북 페이지 정보 크롤링 하기 [6] 2017.02.11 39898
50 [VC소스]이미지 파일 저장 루틴(기초) 1999.11.18 712
» [VC소스]VIEW에 낙서하기 1999.11.12 952
48 [C++소스]가중치구하기? 1999.10.28 1768
47 [VC소스]윈도우 모양을 마음데로... 1999.10.26 732
46 알고리즘 구현...(1) 1999.06.05 523
45 가상키보드 후킹 포커스 문제... [1] 2010.12.10 13009
44 소스코드에 대한 추가질문입니다^^ [1] 2009.05.26 518
43 마무리 질문일듯합니다^^^^^^ [1] 2009.05.14 1614
42 밑에 소스에 대한 추가질문입니다 ^^ [1] 2009.05.13 719
41 홈페이지 주인님 소스에 대한 질문입니다 [1] 2009.05.12 871
40 Gunshadow가 관련된 질문 입니다. [1] 2007.12.17 467
39 Gunshadow.sys 파일의 바이러스 진단 여부에 대한 문의입니다. [5] 2007.12.11 489
38 Gunshadow.sys,dll파일 삭제에 관해서, [1] 2007.12.01 868
37 레지스트리후킹 [1] 2006.11.17 704
36 그래도 신호강도를 못 받고 있습니다.ㅠ0ㅠ [1] 2006.06.27 596
35 무선랜카드에서 연결속도 및 신호강도 받아오는 방법이 궁금합니다. [1] 2006.06.26 1120
34 CRC - 16 소스 수정할려고 하는데 어떻게 해야할지.. 질문드립니다. [1] 2006.06.23 1120
33 Extern을 이용하여 모듈화 할때 문제점 질문드립니다!!! [1] 2006.06.23 673
32 visual C를 이용해서 미디어 플레이어 짜는법좀 [1] 2006.04.27 569
31 시리얼통신관련 질문..(응답속도에 관해..) [1] 2006.04.03 1133