?? progbar.c
字號:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#define IDC_CTRL1 100#define IDC_CTRL2 110#define IDC_CTRL3 120#define IDC_CTRL4 130static HWND hMainWnd = HWND_INVALID;static int ControlTestWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ static HWND hChildWnd1, hChildWnd2, hChildWnd3, hChildWnd4; static int pos; switch (message) { case MSG_CREATE: hChildWnd1 = CreateWindow ("progressbar", "", WS_VISIBLE, IDC_CTRL1, 10, 20, 80, 24, hWnd, 0); hChildWnd4 = CreateWindow ("progressbar", "", WS_VISIBLE, IDC_CTRL4, 100, 20, 60, 24, hWnd, 0); hChildWnd2 = CreateWindow ("progressbar", NULL, WS_VISIBLE, IDC_CTRL2, 10, 45, 250, 24, hWnd, 0); hChildWnd3 = CreateWindow ("progressbar", NULL, WS_VISIBLE | PBS_VERTICAL | PBS_NOTIFY, IDC_CTRL3, 10, 70, 20, 120, hWnd, 0); SendMessage (hChildWnd4, PBM_SETRANGE, 0, 1000); SendMessage (hChildWnd4, PBM_SETSTEP, 10, 0); pos = 0; SetTimer (hWnd, 100, 10); break; case MSG_TIMER: pos += 4; SendMessage (hChildWnd1, PBM_SETPOS, pos, 0); SendMessage (hChildWnd2, PBM_DELTAPOS, 10, 0); SendMessage (hChildWnd3, PBM_DELTAPOS, 2, 0); SendMessage (hChildWnd4, PBM_STEPIT, 0, 0); break; case MSG_COMMAND: { int id = LOWORD(wParam); int code = HIWORD(wParam); char buffer [256]; HDC hdc; sprintf (buffer, "ID: %d, Code: %x", id, code); hdc = GetClientDC (hWnd); TextOut (hdc, 0, 0, buffer); switch (id) { case IDC_CTRL1: break; case IDC_CTRL2: break; case IDC_CTRL3: break; default: break; } ReleaseDC (hdc); } break; case MSG_CLOSE: KillTimer (hWnd, 100); DestroyWindow (hChildWnd1); DestroyWindow (hChildWnd2); DestroyWindow (hChildWnd3); DestroyWindow (hChildWnd4); DestroyMainWindow (hWnd); MainWindowCleanup (hWnd); hMainWnd = HWND_INVALID; return 0; } return DefaultMainWinProc(hWnd, message, wParam, lParam);}static void InitCreateInfo(PMAINWINCREATE pCreateInfo){ pCreateInfo->dwStyle = WS_CAPTION | WS_BORDER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE; pCreateInfo->dwExStyle = WS_EX_IMECOMPOSE; pCreateInfo->spCaption = "ProgressBar control" ; pCreateInfo->hMenu = 0; pCreateInfo->hCursor = GetSystemCursor(IDC_ARROW); pCreateInfo->hIcon = 0; pCreateInfo->MainWindowProc = ControlTestWinProc; pCreateInfo->lx = 0; pCreateInfo->ty = 0; pCreateInfo->rx = 400; pCreateInfo->by = 300; pCreateInfo->iBkColor = GetWindowElementColor (BKC_CONTROL_DEF); pCreateInfo->dwAddData = 0; pCreateInfo->hHosting = HWND_DESKTOP;}void progressbar_demo (HWND hwnd){ MAINWINCREATE CreateInfo; if (hMainWnd != HWND_INVALID) { ShowWindow (hMainWnd, SW_SHOWNORMAL); return; } InitCreateInfo (&CreateInfo); CreateInfo.hHosting = hwnd; hMainWnd = CreateMainWindow (&CreateInfo);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -