1. Trang chủ
  2. » Giáo án - Bài giảng

Bài Giảng Lập Trình Windows ( Combo Full Slides 4 Chương )

312 3 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 312
Dung lượng 3,19 MB

Nội dung

9/13/2011 ክኧ 0ኈ  ኞ   ኤ  ኛW  ኛ W  ኘ W ϯ@ WINDOWS 9/13/2011 Н’ trình Windows ‡ Šዕ‹ Žዛዘ‰: (2-1-0-4) ± Lý –Š—›ዅ–: 30 –‹ዅ– ± Bài –ኼ’: 15 –‹ዅ– ‡ ዌ… ’Šኹ tiên “—›ዅ–: ± Ngôn ‰ዟ Žኼ’ trình C, C++ ± ኼ’–”¿ŠŠዛዔ‰¯ዎ‹–ዛዘ‰ ኼ’–”¿Š‹†‘™• 2 9/13/2011 г‹ dung ‡ Šዛዓ‰ ዐ‰ quan Žኼ’ trình Windows (4LT + 1BT) ‡ Šዛዓ‰ ኼ’ trình Windows VC++/MFC (15LT + 6BT) ‡ Šዛዓ‰͵Ǥዒ– •ዎ …Šዚ ¯዆ nâng cao ± ኶‘ –Šዛ ˜‹ዉ liên ዅ– ¯ዒ‰ (DLL) (3LT + 2BT) ± —ዏ‰ (Thread) (3LT + 2BT) ± Windows Socket (2LT + 2BT) ‡ Šዛዓ‰4 Ÿ›†ዠ‰ዜ‰†ዙ‰‹†‘™• ‘”ȋ͵ + 2BT) ‡ Bài –ኼ’ Žዔ ኼ’–”¿Š‹†‘™• 3 9/13/2011 Tài Ž‹Ъ— tham ŠИ‘ ‡ ‡ ‡ ‡ ‡ ‡ Ivor ‘”–‘ǯ•ǡ‡‰‹‹‰‹•—ƒŽΪΪʹͲͳͲ Programming Windows with MFC 2nd VC++ and MFC Programming 2nd Sams teach yourself VC++ in 21 days MSDN http://www.functionx.com/visualc/ ኼ’–”¿Š‹†‘™• 4 9/13/2011 Šмд‰ б‰ quan ŽН’ trình Windows ‡ 1.1 ዓ „኷ ˜዆ Žኼ’ trình Windows (1T) ‡ 1.2 ኸ— trúc …ዚƒ …Šዛዓ‰ trình Windows (2T) ‡ 1.3 Microsoft Foundation Classes (MFC) ‡ 1.4 ኼ’ trình Windows ˜ዔ‹ VC++ 2008 (1LT + 1BT) ኼ’–”¿Š‹†‘™• 5 9/13/2011 1.1 д „И ˜Ч ŽН’ trình Windows ‡ Windows: ¯ዏ Šዌƒ –”ዠ… quan, tài nguyên ¯ƒ †኶‰ ‡ ኮ‰ †ዙ‰ thân –Š‹ዉ ˜ዔ‹ ‰ዛዕ‹ •ዞ †ዙ‰ thông qua giao †‹ዉ ¯ዏ Šዌƒ Windows ‡ Các ዜ‰ †ዙ‰ có giao †‹ዉ –ዛዓ‰ tác ‰‹ዎ‰ nhau: ± Windows, title bar, toolbar, menu bar, status bar ± Thanh –Šዠ… ¯ዓ: File, Edit, Tool, Helpǥ ± ዒ’ –Š‘኶‹: –Šዛዕ‰ …Šዜƒ ¯‹዆— Š‹዇ chung: Edit Control, Button Control, CheckboxǥǤ ኼ’–”¿Š‹†‘™• 6 ̴ ȌǢȀȀ ¯ዋŠ‰ŠÂƒ–”‘‰”‡•‘—”…‡ǤŠ m_listbox- >AddString( "Ong A" ); m_listbox- >AddString( "Ba B" ); m_listbox- >AddString( "Co C" ); ȀȀ኶‘ዒ–‡†‹–„‘šȋ†ỵ‰¯዇Š‹ዉ’Šኹ–ዞ¯ዛዘ……Šዌ–ዝŽ‹•–„‘š m_edit->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(200, 100, 280, 120), this, 1010); return 0; } ኼ’–”¿Š‹†‘™• 215 215 9/13/2011 е’‹•–‘šȂ À†кȋ–‹Ц’Ȍ void CControlDemoDlg::OnLbnSelchangeListBox() { CString info; int iSel = m_listbox->GetCurSel(); ‹ˆȋ‹‡Žαα̴ȌȀȀŠØ‰…׎ዠƒ…Šዌ L6HO 7KuFKӑQPөFÿҫXWLrQ m_listbox->GetText(iSel, info ); m_edit->SetWindowText( info); } ኼ’–”¿Š‹†‘™• 216 216 9/13/2011 ʹǤ͹ǤͶǤͶǤе’‘„‘‘šȋͳȌ ‡ ዔ’“—኷Žý…‘„‘„‘šȋŠዒ’Šኼ’˜’ŠኹŠዑ–”ዘŠኼ’˜ዔ‹ †ƒŠ•ž…Š…ž…’Šኹ–ዞ…Š‘–”ዛዔ…Ȍ ‡ –኶‘‘„‘‘šȋȌ ‡ Hàm Create() BOOL Create ( †™–›Ž‡ǡȀȀ‹዇—…‘„‘‘š const RECT& rect, CWnd* pParentWnd, UINT nID ); ‡ †™–›Ž‡ǣž…†኶‰‘„‘‘šŠž…Šƒ—ǣ ± ̴ ǣ ‹ž–”ዋŠኼ’…Šዊ¯ዛዘ……Šዌ–ዝ†ƒŠ•ž…ŠǤ ± ̴ ǣŠዛ”‘’Ž‹•–†ƒŠ•ž…ŠŠ‹዇–Šዋ–Šዛዕ‰–”ዠ… ± ̴ǣŠዛ†”‘’Ž‹•–˜…×–Š዇Šኼ’ዒ‹†—‰ዔ‹ ኼ’–”¿Š‹†‘™• 217 217 9/13/2011 е’‘„‘‘šȋʹȌȂ Hàm thành viên ‡ Š‹዆—Š–ዛዓ‰–ዠ‹•–‘š ‡ nhóm: ± General Operations: ‡ int GetCountȋȌ–”኷˜዆•ዎዙ……Šዌ ‡ ‡–—”‡Žǡ‡–—”‡Žǡǥ ‡ GetLBText() ኸ›–‡š–…ዚƒ’Šኹ–ዞ ± String Operations: AddString, DeleteString, InsertString, ResetContentǡǥ ‡ Xem MSDN ኼ’–”¿Š‹†‘™• 218 218 9/13/2011 е’‘„‘‘šȋ͵ȌȂ пŽý•с‹Ъ ‡ ዠ‹ዉ–”²‘„‘‘š˜ŠšዞŽý ON_CBN_SELCHANGE(IDC_COMBO1, &CControlDemoDlg::OnCbnSelchangeCombo1) ኼ’–”¿Š‹†‘™• 219 219 9/13/2011 е’‘„‘‘šȋͶȌȂ À†к m_pComboBox->Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|CBS_DROPDOWNLIST, CRect(10,10,200,100), pParentWnd, IDC_COMBO1); void CControlDemoDlg::OnCbnSelchangeCombo1() { CString info; int iSel = m_Combobox.GetCurSel( ); if (iSel == LB_ERR) // no selection iSel = 0; m_pComboBox- >GetLBText( iSel, info ); m_edit->SetWindowText( info ); } ኼ’–”¿Š‹†‘™• 220 220 9/13/2011 ʹǤ͹ǤͶǤͷǤе’’‹—––‘–”ŽȋͳȌ ‡ ዔ’“—኷Žý¯‹዆—Š‹዇…Š‘’Š±’Žዠƒ…Šዌ‰‹ž –”ዋȋ–£‰Ȁ‰‹኷Ȍ–”‘‰ዒ–Š‘኷‰¯ …‹¯዁–Ǥ ‡ Šዛዕ‰¯‹°˜ዔ‹ዒ–‡†‹–„‘šȋ¯዇Š‹ዉ‰‹ž –”ዋ—ዎ…ŠዌȌ ‡ Hàm Create() virtual BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID ); ኼ’–”¿Š‹†‘™• 221 221 9/13/2011 CSpinButtonCtrl (2) Ȃ Hàm thành viên ‡ CWnd* SetBuddy (CWnd* pWndBuddy); ȀȀኊ¯ዋŠ¯ዎ‹–ዛዘ‰Šዒ’Šኼ’ȋ‡†‹–„‘šȌ¯‹዆— Š‹዇›Šዑ–”ዘ ‡ CWnd* GetBuddy( ); ‡ ‹–‡–ƒ•‡ȋ‹–ƒ•‡ȌǢȀȀ–Š‹ዅ–Žኼ’„ዛዔ…–£‰‰‹኷ ‡ void SetRange ( int nLower, int nUpper); ȀȀኊ¯ዋŠ’Š኶˜‹‰‹ž–”ዋ„‹ዅ–Š‹²…ዚƒï––£‰ ‰‹኷Ǥ ‡ void GetRange ( int &nLower, int &nUpper); ‡ ‹–‡–‘•ȋ‹–‘•ȌǢȀȀ0዁–‰‹ž–”ዋï––£‰‰‹኷ ‡ int GetPos( int &nPos); ኼ’–”¿Š‹†‘™• 222 222 9/13/2011 CSpinButtonCtrl (4) Ȃ À†к int CControlDemoDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; m_editAge.Create ( WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER, CRect( 135, 45, 190, 65 ), this, IDC_EDIT); static CSpinButtonCtrl m_spinAge; m_spinAge.Create ( WS_CHILD | WS_VISIBLE | UDS_ARROWKEYS | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, CRect(0,0,1,1), this, IDC_SPIN); ̴•’‹‰‡Ǥ‡–ƒ•‡ȋͳȌǢȀȀዛዔ…–£‰‰‹኷ m_spinAge.SetRange( 15, 80 ); m_spinAge.SetBuddy ( &m_editAge ); return 0; } ኼ’–”¿Š‹†‘™• 223 223 9/13/2011 ʹǤ͹ǤͶǤ͸Ǥе’Ž‹†‡”–”ŽȋͳȌ ‡ ዔ’“—኷Žý–ŠƒŠ–”ዛዘ– ‡ ዛዓ‰–ዠ’‹ ‡ Š—ዒ…–ÀŠǣ ± Tick Marks ± ‘‹–ǣ‹዇—…‘…Š኶› ± Orientation: Horizontal & vertical ‡ Hàm Create() virtual BOOL Create( †™–›Ž‡ǡȀȀ̴ ǡ̴ǡǥ const RECT& rect, CWnd* pParentWnd, UINT nID ); ኼ’–”¿Š‹†‘™• 224 224 9/13/2011 е’Ž‹†‡”–”ŽȋʹȌȂ Hàm thành viên ‡ void SetRange(int nMin, int nMax, BOOL bRedraw = FALSE); ‡ void SetPos(int nPos); int GetPosȋȌǡǥǤ ‡ CWnd* SetBuddy (CWnd* pWndBuddy); ‡ CWnd* GetBuddy( ); ‡ ‹– ‡–‹…ȋȌǢȀȀኸ›‰‹ž–”ዋ„ዛዔ……‘…Š኶› ‡ ‹–‡–‹…ȋ‹–‹…ȌǢȀȀŠ‹ዅ–Žኼ’„ዛዔ……‘…Š኶› ‡ void SetRangeMin(int nMin, BOOL bRedraw = FALSE); GetRangeMin(); ‡ void SetTicFreq(int nFreq); ‡ Xem MSDN ኼ’–”¿Š‹†‘™• 225 225

Ngày đăng: 05/11/2023, 15:57