1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| #include<Windows.h> #include<CommCtrl.h> #include"resource.h" INT_PTR CALLBACK Dlgproc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch (uMsg) { case WM_INITDIALOG: { SendDlgItemMessageW(hwnd, IDC_PROGRESS1,PBM_SETRANGE,0,MAKELPARAM(0,100)); SendDlgItemMessageW(hwnd, IDC_SLIDER1, TBM_SETRANGE, TRUE, MAKELPARAM(0, 100)); SendDlgItemMessageW(hwnd, IDC_PROGRESS1, PBM_SETPOS, 50, 0); SendDlgItemMessageW(hwnd, IDC_SLIDER1, TBM_SETPOS, TRUE, 80); break; } case WM_CLOSE: { EndDialog(hwnd, 0); } case WM_HSCROLL: { if (GetDlgItem(hwnd, IDC_SLIDER1)==(HWND)lParam) { int pos = SendMessageW((HWND)lParam,TBM_GETPOS,0,0); SendDlgItemMessageW(hwnd, IDC_PROGRESS1,PBM_SETPOS,pos,0); } break; } default: return false; break; } return TRUE; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) { DialogBoxW(hInstance, MAKEINTRESOURCEW(IDD_DIALOG1),NULL, Dlgproc); return 0; }
|