📄 static.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_STATIC1 100#define IDC_STATIC2 150#define IDC_BUTTON1 110#define IDC_BUTTON2 120#define IDC_EDIT1 130#define IDC_EDIT2 140static HWND hMainWnd = HWND_INVALID;static int ControlTestWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ static HWND hStaticWnd1, hStaticWnd2, hButton1, hButton2, hEdit1, hEdit2; switch (message) { case MSG_CREATE: { hStaticWnd1 = CreateWindow (CTRL_STATIC, "This is a static control", WS_CHILD | SS_NOTIFY | SS_SIMPLE | WS_VISIBLE | WS_BORDER, IDC_STATIC1, 10, 10, 180, 300, hWnd, 0); hButton1 = CreateWindow (CTRL_BUTTON, "Button1", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, IDC_BUTTON1, 20, 20, 80, 20, hStaticWnd1, 0); hButton2 = CreateWindow (CTRL_BUTTON, "Button2", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, IDC_BUTTON2, 20, 50, 80, 20, hStaticWnd1, 0); hEdit1 = CreateWindow (CTRL_EDIT, "Edit Box 1", WS_CHILD | WS_VISIBLE | WS_BORDER, IDC_EDIT1, 20, 80, 100, 24, hStaticWnd1, 0); hStaticWnd2 = CreateWindow (CTRL_STATIC, "This is child static control", WS_CHILD | SS_NOTIFY | SS_SIMPLE | WS_VISIBLE | WS_BORDER, IDC_STATIC1, 20, 110, 100, 50, hStaticWnd1, 0); hEdit2 = CreateWindow (CTRL_EDIT, "Edit Box 2", WS_CHILD | WS_VISIBLE | WS_BORDER, IDC_EDIT2, 0, 20, 100, 24, hStaticWnd2, 0);#ifdef _DEBUG DumpWindow (stdout, hWnd); DumpWindow (stdout, hStaticWnd1); DumpWindow (stdout, hStaticWnd2); DumpWindow (stdout, hEdit2); DumpWindow (stdout, hButton1); DumpWindow (stdout, hButton2); DumpWindow (stdout, hEdit1);#endif } 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); ReleaseDC (hdc); } break; case MSG_CLOSE: DestroyWindow (hEdit1); DestroyWindow (hEdit2); DestroyWindow (hButton2); DestroyWindow (hButton1); DestroyWindow (hStaticWnd2); DestroyWindow (hStaticWnd1); 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_NONE; pCreateInfo->spCaption = "Static control"; pCreateInfo->hMenu = 0; pCreateInfo->hCursor = GetSystemCursor(1); 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 static_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 + -