Progress Bar Control Example Example

To create a progress bar control specify PROGRESS_CLASS as the window class and register the class by specifying the ICC_PROGRESS_CLASS bit flag in the accompanying INITCOMMONCONTROLSEX structure.

To design the dialog box , remove the dialog code and add it to the the dialog resource

///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 228, 97 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,237,24,50,14 PUSHBUTTON "Cancel",IDCANCEL,237,24,50,14 END PAGE1 DIALOG DISCARDABLE 0, 0, 100, 47 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Tab 1" FONT 10, "MS Sans Serif" BEGIN CONTROL "Radio1",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,4,13,58,8 CONTROL "Radio2",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,4,27,60,8 GROUPBOX "Page 1",IDC_STATIC,1,3,71,36 END PAGE2 DIALOG DISCARDABLE 0, 0, 100, 24 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Tab 2" FONT 16, "MS Sans Serif" BEGIN LTEXT "Page 2",-1,0,1,100,10 END ///////////////////////////////////////////////////////////////////////////// // //property sheet example #pragma comment( lib, "user32.lib" ) #pragma comment( lib, "comctl32.lib" ) #include <windows.h> #include <commctrl.h> #define IDC_RADIO1 1 #define IDC_RADIO2 2 //the first property sheet page function BOOL CALLBACK PageProc1(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { LPNMHDR lpnmhdr; switch (msg) { case WM_COMMAND: switch (LOWORD(wp)) //respond to button click { case IDC_RADIO1: MessageBox(hwnd,TEXT("Radio 1 Clicked"),TEXT("Tab1"),MB_OK); break; case IDC_RADIO2: MessageBox(hwnd,TEXT("Radio 2 Clicked"),TEXT("Tab1"),MB_OK); break; } break; case WM_NOTIFY: lpnmhdr = (NMHDR FAR *)lp; switch (lpnmhdr->code) { case PSN_APPLY: //sent when OK or Apply button pressed break; case PSN_RESET: //sent when Cancel button pressed break; case PSN_SETACTIVE://Notifies a page that it is about to be activated. PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_NEXT); break; default: break; } break; default: break; } return FALSE; } //the second property sheet page function BOOL CALLBACK PageProc2(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { return FALSE; } LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { PROPSHEETPAGE psp;//stores information about each property page PROPSHEETHEADER psh;//stores information about the propety sheet HPROPSHEETPAGE hPsp[2];//used to individual create page for property sheet ZeroMemory(&psp, sizeof(psp)); ZeroMemory(&psh, sizeof(psh)); switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CREATE: INITCOMMONCONTROLSEX icc; icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&icc); return 0; //responds to right mouse button click by creating and displaying the property sheet case WM_RBUTTONUP: psp.dwSize = sizeof (PROPSHEETPAGE); psp.dwFlags = PSP_DEFAULT | PSP_USEICONID; psp.pszIcon = TEXT("PAGEICON"); psp.hInstance = (HINSTANCE)GetWindowLong(hWnd , GWL_HINSTANCE); psp.pszTemplate = TEXT("PAGE1"); psp.pfnDlgProc = (DLGPROC)PageProc1; hPsp[0] = CreatePropertySheetPage(&psp); psp.pszTemplate = TEXT("PAGE2"); psp.pfnDlgProc = (DLGPROC)PageProc2; hPsp[1] = CreatePropertySheetPage(&psp); psh.dwSize = sizeof (PROPSHEETHEADER); psh.dwFlags = PSH_DEFAULT | PSH_USEHICON; psh.hwndParent = hWnd; psh.hIcon = LoadIcon(NULL , IDI_ASTERISK); psh.pszCaption =TEXT( "property Sheet"); psh.nPages = 2; psh.phpage = hPsp; PropertySheet(&psh); return 0; } return DefWindowProc(hWnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance ,PSTR lpCmdLine , int nCmdShow ) { HWND hWnd; MSG msg; WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL , IDI_APPLICATION); wc.hCursor = LoadCursor(NULL , IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = TEXT("myWindowClass"); if (!RegisterClass(&wc)) return -1; hWnd = CreateWindow(TEXT("myWindowClass") , TEXT("Property Sheet Demo") ,WS_OVERLAPPEDWINDOW | WS_VISIBLE ,CW_USEDEFAULT , CW_USEDEFAULT ,500, 200,NULL , NULL , hInstance , NULL ); if (hWnd == NULL) return -1; while(GetMessage(&msg , NULL , 0 , 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }