Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <commctrl.h>
- #include <time.h>
- #include "resource.h"
- unsigned int i=0;
- unsigned int timer=30;
- HANDLE hThread;
- HWND hMainDlg, hDlgButton;
- void thread()
- {
- for(UINT timer = 30; timer >= 0; timer--)
- {
- SetDlgItemInt(hMainDlg, ID_TTIMER, timer, FALSE);
- Sleep(1000);
- }
- EnableWindow(hDlgButton, FALSE);
- }
- BOOL CALLBACK DlgProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam)
- {
- switch(Message)
- {
- case WM_INITDIALOG:
- hMainDlg = hwnd;
- hDlgButton = GetDlgItem(hMainDlg, ID_BTCLICK);
- hThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)thread, NULL, NULL, NULL);
- break;
- case WM_CLOSE:
- if( hThread )
- CloseHandle(hThread);
- EndDialog(hwnd,0);
- break;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case ID_BTABOUT:
- DialogBox(NULL,MAKEINTRESOURCE(IDD_ABOUT),NULL,DlgProc);
- break;
- case ID_ABOUTEXIT:
- EndDialog(hwnd,0);
- break;
- case ID_BTRESET:
- {
- timer=30;
- i=0;
- SetDlgItemInt(hwnd,ID_TTIMER,timer,FALSE);
- SetDlgItemInt(hwnd,ID_TCOUNT,i,FALSE);
- if( hThread )
- CloseHandle(hThread);
- hThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)thread, NULL, NULL, NULL);
- }
- break;
- case ID_BTCLICK:
- i++;
- SetDlgItemInt(hwnd,ID_TCOUNT,i,FALSE);
- break;
- }
- break;
- case WM_DESTROY:
- EndDialog(hwnd,0);
- break;
- default:
- return FALSE;
- }
- return TRUE;
- }
- int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
- {
- InitCommonControls();
- return DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL,DlgProc);
- }
Add Comment
Please, Sign In to add comment