實驗1
- MFC項目中的單個文檔和多個文檔的區別?
- 繪製代碼——https://www.cnblogs.com/amtop/p/10960704.html
- 視圖-其他-資源視圖
- 如果已經打開過視圖, 下面就由選項:解決方案,團隊資源管理器,類視圖,資源視圖等,不需要進入“視圖”裏面選擇
- 修改FRAME裏面的ID,右鍵->"編輯ID” 這樣可以修改
- 寫在OnDiamond
- 刪除類-https://blog.csdn.net/form88/article/details/51152859
- 註釋-https://www.cnblogs.com/puzi0315/p/8144526.html
- 總體參考-https://wenku.baidu.com/view/7ce5c84a87c24028915fc3d5.html
debug
- 無法打開test.exe進行寫入——未關閉結果窗口
- 輸出中間結果debug——使用trace:不會用
- classwizard類嚮導——在類視圖中右擊某一個類-選擇類嚮導
- https://jingyan.baidu.com/article/6079ad0edb744428fe86db68.html6.https://blog.csdn.net/eastmount/article/details/9052735
實驗2-繪製任意直線的直線段
- moveto和lineto()——https://blog.csdn.net/laptoper/article/details/47207829
- 期間點擊資源視圖沒反應(即看不了顯示窗口)——重啓vs 重新打開該項目就好了
- 總體參考——https://www.cnblogs.com/jdemarryme/p/8806752.html
缺陷:未與窗口結合 - Test1View.h和Test1View.cpp中加入
實驗3-繪製多邊形
- 來源於網絡,繪製了一個菱形
寫在OnPolygon()函數
//網絡
CRect rect;
GetClientRect(rect);
// draw with a thick blue pen
CPen penBlue(PS_SOLID, 5, RGB(0, 0, 255));
CPen* pOldPen = pDC->SelectObject(&penBlue);
// and a solid red brush
CBrush brushRed(RGB(255, 0, 0));
CBrush* pOldBrush = pDC->SelectObject(&brushRed);
// Find the midpoints of the top, right, left, and bottom
// of the client area. They will be the vertices of our polygon.
CPoint pts[4];
pts[0].x = rect.left + rect.Width() / 2;
pts[0].y = rect.top;
pts[1].x = rect.right;
pts[1].y = rect.top + rect.Height() / 2;
pts[2].x = pts[0].x;
pts[2].y = rect.bottom;
pts[3].x = rect.left;
pts[3].y = pts[1].y;
// Calling Polygon() on that array will draw three lines
// between the points, as well as an additional line to
// close the shape--from the last point to the first point
// we specified.
pDC->Polygon(pts, 4);
// Put back the old objects.
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
//網絡
實驗4-二維幾何變換
- 窗口分割-https://blog.csdn.net/u012943043/article/details/50316333
靜態分割是指窗口在創建時,分割窗格窗口的窗格已經創建好了,且窗格的數量和順序不會改變了,窗格爲一個分隔條所分割,用戶可以拖動分割條調整相應的窗格的大小。靜態分割窗口最多可以有16行16列的窗格,但是各個窗格可以使用不同的視圖類。
滑動條——http://www.jizhuomi.com/software/191.html
https://blog.csdn.net/godqiao/article/details/78554586
幾何變換——https://blog.csdn.net/Eastmount/article/details/46345299
橡皮筋——https://www.cnblogs.com/zjutlitao/p/3735409.html
Bezier——https://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
實驗3-補充
mfc中使用vector——https://blog.csdn.net/songlei217/article/details/39718411
寫完3個實驗,又發現第一個實驗 繪製金剛石出現了問題:點擊“金剛石”的時候,對話窗不彈出,程序直接卡住了且debug也顯示不出問題
找了半天(包括是否和繪製多邊形中有內容衝突。。)
最後通過return自己debug找到出問題的語句:
“IDOK == dlg.Domodall()”
這一句出問題說明什麼呢?
首先-https://blog.csdn.net/shuilan0066/article/details/5775383
對話框返回值==IDOK說明點了“確認”,而對話窗並沒有彈出來,顯然我無法點擊確認,因此程序一直等待我獲取DoModal()的返回值而死機。所以出現所有問題的源頭就是——對話窗口不彈出!
直接找到該對話窗口的屬性,果然:
Visible = false !!!
窗口不可見了!
所以平常操作的時候真的要非常小心啊,這個右邊的選項是滑動的,也就是一不小心就有可能改變某些屬性的值。。
思考:
- 找問題要找源頭
- 不要盲目焦慮,大範圍進行不必要的debug,其實有些bug真的很簡單,令人哭笑不得,若是真正的bug是可以調試出來的,只有這種人爲的“錯誤”的操作才debug不出來
- 不要隨便重來,重寫一遍,尤其是複雜的代碼,真的非常噁心~debug其實也很有樂趣