📄 miniguidemo.c
字号:
} break; case MSG_CHAR: printf("Press %d\n",wParam); } return DefaultMainWinProc(hWnd, message, wParam, lParam);}//font procstatic PLOGFONT logfontgb12, logfontgb16, logfontgb24;void Font_Demo (HDC hdc){ RECT rc1; const char* szBuff1 = "This is a good day. \n" "这是利用 DrawText 输出, 使用字体 GB2312 Song 24. " "垂直靠上, 居中"; rc1.left = 0; rc1.top = 160; rc1.right = 320; rc1.bottom = 220; SetBkColor (hdc, COLOR_lightwhite); SelectFont (hdc, logfontgb12); TextOut (hdc, 0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); TextOut (hdc, 0, 15, "abcdefghijklmnopqrstuvwxyz!@#$%^&*()"); TextOut (hdc, 0, 30, "大家好,正在使用MiniGUI"); TextOut (hdc, 0, 45, "这是利用TextOut输出:GB2312 Song 12"); SelectFont (hdc, logfontgb16); TextOut (hdc, 0, 70, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); TextOut (hdc, 0, 85, "abcdefghijklmnopqrstuvwxyz!@#$%^&*()"); TextOut (hdc, 0, 100, "大家好,正在使用MiniGUI"); TextOut (hdc, 0, 115, "这是利用TextOut输出:GB2312 Song 16"); SelectFont (hdc, logfontgb24); DrawText (hdc, szBuff1, -1, &rc1, DT_NOCLIP | DT_CENTER | DT_WORDBREAK);}static int FontDemoProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ switch (message) { case MSG_CREATE: logfontgb12 = CreateLogFont (NULL, "song", "GB2312", FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL, FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE, 12, 0); printf ("sbc_defont: %s\n", logfontgb12->sbc_devfont->name); logfontgb16 = CreateLogFont (NULL, "song", "GB2312", FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL, FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE, 16, 0); printf ("sbc_defont: %s\n", logfontgb16->sbc_devfont->name); logfontgb24 = CreateLogFont (NULL, "song", "GB2312", FONT_WEIGHT_BOLD, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL, FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE, 24, 0); break; case MSG_PAINT: { HDC hdc; hdc = BeginPaint (hWnd); Font_Demo (hdc); break; EndPaint (hWnd, hdc); return 0; } break; case MSG_CLOSE: DestroyLogFont (logfontgb12); DestroyLogFont (logfontgb16); DestroyLogFont (logfontgb24); DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc (hWnd, message, wParam, lParam);}//iconBYTE ANDmaskIcon1[] = { 0xff, 0x9f, 0x00, 0x00, 0xff, 0x1f, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00};BYTE XORmaskIcon1[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0xff, 0xf8, 0xff, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x8f, 0xff, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xf0, 0x0f, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xf8, 0x00, 0x08, 0xff, 0xf0, 0x00, 0x00, 0x8f, 0xff, 0x80, 0x8f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x8f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x9f, 0x00, 0x00, 0xff, 0x1f, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0xf4, 0xd9, 0x04, 0x08, 0xa8, 0xf8, 0xff, 0xbf, 0xc0, 0xf7, 0xff, 0xbf, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x0e, 0x03, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xf0, 0x10, 0x04, 0x00, 0x70, 0xe1, 0x04, 0x08, 0xd8, 0xf8, 0xff, 0xbf, 0x41, 0x90, 0x04, 0x08};//////////////////////////////////////////////////////////static int IconProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam){ static HICON new_icon; HDC hdc; switch (message) { case MSG_CREATE: new_icon = CreateIcon(HDC_SCREEN, 16, 16, ANDmaskIcon1, XORmaskIcon1, 4); break; case MSG_PAINT: hdc = BeginPaint(hDlg); if (new_icon != 0) { DrawIcon(hdc, 0, 0, 0, 0, new_icon); DrawIcon(hdc, 50, 50, 64, 64, new_icon); } EndPaint(hDlg, hdc); return 0; case MSG_CLOSE: DestroyIcon(new_icon); DestroyMainWindow (hDlg); PostQuitMessage (hDlg); return 0; } return DefaultMainWinProc(hDlg, message, wParam, lParam);}static void ControlsListDemo (HWND hWnd){ DlgListDemo.controls = CtrlListDemoFiles; DialogBoxIndirectParam (&DlgListDemo, hWnd, ListDemoFilesBoxProc, 0L);}static void ControlsProgressBar (HWND hWnd){ DlgProgressBar.controls = CtrlProgressBar; DialogBoxIndirectParam (&DlgProgressBar, hWnd, ProgressBarProc, 0L);}static void ControlsIcon (HWND hWnd){ DlgIcon.controls = CtrlIcon; DialogBoxIndirectParam (&DlgIcon, hWnd, IconProc, 0L);}static void ControlsEdit (HWND hWnd){ DlgBoxInputChar.controls = CtrlInputChar; DialogBoxIndirectParam (&DlgBoxInputChar, HWND_DESKTOP, InputCharDialogBoxProc, 0L);}static void ControlsTrackDemo (HWND hWnd){ DlgTrackDemo.controls = CtrlTrackDemo; DialogBoxIndirectParam (&DlgTrackDemo, hWnd, TrackDemoProc, 0L);}static void ControlsGDIDemo (HWND hWnd){ DlgGDIDemo.controls = CtrlGDIDemo; DialogBoxIndirectParam (&DlgGDIDemo, hWnd, GDIDemoProc, 0L);}static void ControlsDrawDemo (HWND hWnd){ DlgDrawDemo.controls = CtrlDrawDemo; DialogBoxIndirectParam (&DlgDrawDemo, hWnd, DrawDemoProc, 0L);}static void ControlsFontDemo (HWND hWnd){ DlgFontDemo.controls = CtrlFontDemo; DialogBoxIndirectParam (&DlgFontDemo, hWnd, FontDemoProc, 0L);}static int MenuWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ HDC hdc; switch (message) { case MSG_PAINT: hdc = BeginPaint (hWnd); TextOut (hdc, 100, 100, "Demos"); EndPaint (hWnd, hdc); return 0; case MSG_CLOSE: DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; case MSG_COMMAND: switch(wParam){ case IDM_LIST: ControlsListDemo (hWnd); break; case IDM_PROGRESSBAR: ControlsProgressBar (hWnd); break; case IDM_ICON: ControlsIcon (hWnd); break; case IDM_EDIT: ControlsEdit (hWnd); break; case IDM_PROPSHEET: testPropertySheet (hWnd); break; case IDM_EXIT: SendMessage (hWnd, MSG_CLOSE, 0, 0L); break; case IDM_TRACKBAR: ControlsTrackDemo (hWnd); break; case IDM_GDIDEMO: ControlsGDIDemo (hWnd); break; case IDM_DRAWDEMO: ControlsDrawDemo (hWnd); break; case IDM_FONTDEMO: ControlsFontDemo (hWnd); break; break; } } return DefaultMainWinProc(hWnd, message, wParam, lParam);}static HMENU createpmenudialogs (void){ HMENU hmnu; MENUITEMINFO mii; memset (&mii, 0, sizeof(MENUITEMINFO)); mii.type = MFT_STRING; mii.id = 0; mii.typedata = (DWORD)"Dialogs"; hmnu = CreatePopupMenu (&mii); mii.type = MFT_STRING ; mii.state = 0; mii.id = IDM_TRACKBAR; mii.typedata = (DWORD)"trackbar demo"; InsertMenuItem(hmnu, 0, TRUE, &mii); mii.type = MFT_STRING ; mii.state = 0; mii.id = IDM_GDIDEMO; mii.typedata = (DWORD)"gdi demo"; InsertMenuItem(hmnu, 1, TRUE, &mii); mii.type = MFT_STRING ; mii.state = 0; mii.id = IDM_DRAWDEMO; mii.typedata = (DWORD)"draw demo"; InsertMenuItem(hmnu, 2, TRUE, &mii); mii.type = MFT_STRING; mii.state = 0; mii.id = IDM_FONTDEMO; mii.typedata = (DWORD)"font demo"; InsertMenuItem(hmnu, 3, TRUE, &mii); return hmnu;}static HMENU createpmenufile (void){ HMENU hmnu; MENUITEMINFO mii; memset (&mii, 0, sizeof(MENUITEMINFO)); mii.type = MFT_STRING; mii.id = 0; mii.typedata = (DWORD)"Controls"; hmnu = CreatePopupMenu (&mii); memset (&mii, 0, sizeof(MENUITEMINFO)); mii.type = MFT_STRING; mii.state = 0; mii.id = IDM_LIST; mii.typedata = (DWORD)"list"; InsertMenuItem(hmnu, 0, TRUE, &mii); mii.type = MFT_STRING; mii.state = 0; mii.id = IDM_PROGRESSBAR; mii.typedata = (DWORD)"progressbar"; InsertMenuItem(hmnu, 1, TRUE, &mii); mii.type = MFT_STRING; mii.state = 0; mii.id = IDM_ICON; mii.typedata = (DWORD)"icon"; InsertMenuItem(hmnu, 2, TRUE, &mii); mii.type = MFT_STRING; mii.state = 0; mii.id = IDM_EDIT; mii.typedata = (DWORD)"edit"; InsertMenuItem(hmnu, 3, TRUE, &mii); mii.type = MFT_STRING; mii.state = 0; mii.id = IDM_PROPSHEET; mii.typedata = (DWORD)"propsheet"; InsertMenuItem(hmnu, 4, TRUE, &mii); mii.type = MFT_SEPARATOR; mii.state = 0; mii.id = 0; mii.typedata = 0; InsertMenuItem(hmnu, 5, TRUE, &mii); mii.type = MFT_STRING; mii.state = 0; mii.id = IDM_EXIT; mii.typedata = (DWORD)"Exit"; InsertMenuItem(hmnu, 6, TRUE, &mii); return hmnu;}static HMENU createmenu (void){ HMENU hmnu; MENUITEMINFO mii; hmnu = CreateMenu(); memset (&mii, 0, sizeof(MENUITEMINFO)); mii.type = MFT_STRING; mii.id = 100; mii.typedata = (DWORD)"Controls"; mii.hsubmenu = createpmenufile (); InsertMenuItem(hmnu, 0, TRUE, &mii); mii.type = MFT_STRING; mii.id = 110; mii.typedata = (DWORD)"Demos"; mii.hsubmenu = createpmenudialogs (); InsertMenuItem(hmnu, 1, TRUE, &mii); return hmnu;}int MiniGUIMain (int argc, const char* argv[]){ MSG Msg; HWND hMainWnd; MAINWINCREATE CreateInfo; CreateInfo.dwStyle = WS_SYSMENU | WS_BORDER | WS_CAPTION; CreateInfo.dwExStyle = WS_EX_NONE | WS_EX_USEPRIVATECDC; CreateInfo.spCaption = "达盛MenuDemo"; CreateInfo.hMenu = createmenu(); CreateInfo.hCursor = GetSystemCursor(0); CreateInfo.hIcon = 0; CreateInfo.MainWindowProc = MenuWinProc; CreateInfo.lx = 0; CreateInfo.ty = 0; CreateInfo.rx = 320; CreateInfo.by = 240; CreateInfo.iBkColor = COLOR_lightwhite; CreateInfo.dwAddData = 0; CreateInfo.hHosting = HWND_DESKTOP; hMainWnd = CreateMainWindow (&CreateInfo); if (hMainWnd == HWND_INVALID) return -1; ShowWindow(hMainWnd, SW_SHOWNORMAL); while (GetMessage(&Msg, hMainWnd)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } MainWindowThreadCleanup (hMainWnd); return 0;}#include <minigui/dti.c>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -