32-bit assembler in Windows C code-Chapter 5 (III)

Source: Internet
Author: User

(3) window sub-Controls

 

# Include <windows. h> <br/> # include "resource. h "</p> <p> HINSTANCE hInst; <br/> TCHARszBuffer [1, 128]; <br/> HBITMAPhBmp1 = 0, hBmp2 = 0, hTemp = 0; <br/> static intiScrPos = 2; <br/> bool callback DlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) <br/>{< br/> switch (uMsg) <br/>{< br/> case WM_INITDIALOG: <br/> SendMessage (hDlg, WM_SETICON, ICON_BIG, (LPARAM) loadIcon (hInst, MAKEINTRESOURCE (IDI_MAIN); <Br/> SendDlgItemMessage (hDlg, IDC_TITLETEXT, CB_ADDSTRING, 0, (LPARAM) TEXT ("Hello World! "); <Br/> SendDlgItemMessage (hDlg, IDC_TITLETEXT, CB_ADDSTRING, 0, (LPARAM) TEXT (" Have you seen the title bar changed? "); <Br/> SendDlgItemMessage (hDlg, IDC_TITLETEXT, CB_ADDSTRING, 0, (LPARAM) TEXT (" Custom "); <br/> SendDlgItemMessage (hDlg, IDC_TITLETEXT, CB_SETCURSEL, 0, (LPARAM) 0); <br/> EnableWindow (GetDlgItem (hDlg, IDC_CUSTOMTEXT), FALSE); <br/> hBmp1 = LoadBitmap (hInst, MAKEINTRESOURCE (IDB_1); <br/> hBmp2 = LoadBitmap (hInst, MAKEINTRESOURCE (IDB_2); <br/> CheckDlgButton (hDlg, IDC_SHOWBMP, BST_CHECKED); <br/> CheckDlg Button (hDlg, IDC_ALOW, BST_CHECKED); <br/> CheckDlgButton (hDlg, IDC_MODALFRAME, BST_CHECKED); <br/> SendDlgItemMessage (hDlg, IDC_SCROLL, SBM_SETRANGE, 0,100 ); <br/> return TRUE; <br/> case WM_CLOSE: <br/> DeleteObject (hBmp1); <br/> DeleteObject (hBmp2); <br/> EndDialog (hDlg, 0); <br/> return TRUE; <br/> case WM_COMMAND: <br/> switch (LOWORD (wParam) <br/>{< br/> case IDCANCEL: <br/> DeleteObject (hBmp1); <br/> D EleteObject (hBmp2); <br/> EndDialog (hDlg, 0); <br/> return TRUE; <br/> case IDOK: <br/> hTemp = hBmp1; <br/> hBmp1 = hBmp2; <br/> hBmp2 = hTemp; <br/>/* hBmp1 = (HBITMAP) SendDlgItemMessage (hDlg, IDC_BMP, __getimage, IMAGE_BITMAP, (LPARAM) 0 )? <Br/> SendDlgItemMessage (hDlg, IDC_BMP, success, IMAGE_BITMAP, (LPARAM) hBmp2): <br/> SendDlgItemMessage (hDlg, IDC_BMP, success, IMAGE_BITMAP, (LPARAM) hBmp1 ); */<br/> SendDlgItemMessage (hDlg, IDC_BMP, pai_setimage, IMAGE_BITMAP, (LPARAM) hBmp1); <br/> return TRUE; <br/> case IDC_ONTOP: <br/> if (BST_CHECKED = IsDlgButtonChecked (hDlg, IDC_ONTOP) <br/> SetWindowPos (hDlg, HWND_TOPMOST, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); <br/> else <br/> SetWindowPos (hDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); <br/> return TRUE; <br/> case IDC_SHOWBMP: <br/> if (IsWindowVisible (GetDlgItem (hDlg, IDC_BMP) <br/> ShowWindow (GetDlgItem (hDlg, IDC_BMP), SW_HIDE ); <br/> else <br/> ShowWindow (GetDlgItem (hDlg, IDC_BMP), SW_SHOW); <br/> return TRUE; <br/> case IDC_ALOW: <br/> if (BST_CHECKED = IsDlgButtonCheck Ed (hDlg, IDC_ALOW) <br/> EnableWindow (GetDlgItem (hDlg, IDOK), TRUE); <br/> else <br/> EnableWindow (GetDlgItem (hDlg, IDOK), FALSE); <br/> return TRUE; <br/> case IDC_MODALFRAME: <br/> SetWindowLong (hDlg, GWL_STYLE ,~ WS_THICKFRAME & GetWindowLong (hDlg, GWL_STYLE); <br/> return TRUE; <br/> case IDC_THICKFRAME: <br/> SetWindowLong (hDlg, GWL_STYLE, WS_THICKFRAME | GetWindowLong (hDlg, GWL_STYLE); <br/> return TRUE; <br/> case IDC_TITLETEXT: <br/> if (CBN_SELENDOK = HIWORD (wParam )) <br/> if (2 = SendDlgItemMessage (hDlg, IDC_TITLETEXT, CB_GETCURSEL, 0, 0) <br/>{< br/> EnableWindow (GetDlgItem (hDlg, IDC_CUSTOMTEXT ), TRUE); <br/>}< br/> else <br/> {<br/> SendDlgItemMessage (hDlg, IDC_TITLETEXT, CB_GETLBTEXT, <br/> SendDlgItemMessage (hDlg, IDC_TITLETEXT, CB_GETCURSEL, 0, 0), (LPARAM) szBuffer); <br/> SetWindowText (hDlg, szBuffer); <br/> EnableWindow (GetDlgItem (hDlg, IDC_CUSTOMTEXT), FALSE ); <br/>}< br/> return TRUE; <br/> case IDC_CUSTOMTEXT: <br/> GetDlgItemText (hDlg, IDC_CUSTOMTEXT, szBuffer, sizeof (szBuffer) /sizeof (TCHAR); <br/> SetWindowText (hDlg, szBuffer); <br/> return TRUE; <br/>}< br/> break; <br/> case WM_HSCROLL: <br/> switch (LOWORD (wParam) <br/>{< br/> case SB_LINELEFT: <br/> iScrPos = -- iScrPos; <br/> break; <br/> case SB_LINERIGHT: <br/> iScrPos = ++ iScrPos; <br/> break; <br/> case SB_PAGELEFT: <br/> iScrPos = iScrPos-10; <br/> break; <br/> case SB_PAGERIGHT: <br/> iScrPos = iScrPos + 10; <br/> break; <br/> case SB_THUMBPOSITION: <br/> case SB_THUMBTRACK: <br/> iScrPos = (int) HIWORD (wParam); <br/> break; <br/>}< br/> if (iScrPos <0) <br/> iScrPos = 0; <br/> else if (iScrPos> 100) <br/> iScrPos = 100; <br/> SetDlgItemInt (hDlg, IDC_VALUE, iScrPos, FALSE); <br/> SendDlgItemMessage (hDlg, IDC_SCROLL, SBM_SETPOS, (WPARAM) iScrPos, (LPARAM) TRUE); <br/> return TRUE; <br/>}< br/> return FALSE; <br/>}</p> <p> int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) <br/>{< br/> hInst = hInstance; <br/> DialogBoxParam (hInstance, MAKEINTRESOURCE (IDD_DIALOG), NULL, DlgProc, 0); <br/> return 0; <br/>}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.