📄 fontdemo.c
字号:
/*** $Id: fontdemo.c,v 1.10 2003/08/15 08:45:46 weiym Exp $**** The demo of font.**** Copyright (C) 2001 ~ 2002 Wei Yongming.** Copyright (C) 2003 Feynman Software.**** Create date: 2002/01/17*//*** This source is free software; you can redistribute it and/or** modify it under the terms of the GNU General Public** License as published by the Free Software Foundation; either** version 2 of the License, or (at your option) any later version.**** This software is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU** General Public License for more details.**** You should have received a copy of the GNU General Public** License along with this library; if not, write to the Free** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,** MA 02111-1307, USA*//*** TODO:*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/dti.c>static 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);} int FontTestMainWinProc (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);}static void InitCreateInfo (PMAINWINCREATE pCreateInfo){ pCreateInfo->dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION; pCreateInfo->dwExStyle = WS_EX_NONE; pCreateInfo->spCaption = "达胜FontDemo"; pCreateInfo->hMenu = 0; pCreateInfo->hCursor = GetSystemCursor (0); pCreateInfo->hIcon = 0;//GetSmallSystemIcon (IDI_APPLICATION); pCreateInfo->MainWindowProc = FontTestMainWinProc; pCreateInfo->lx = 0; pCreateInfo->ty = 0; pCreateInfo->rx = 320; pCreateInfo->by = 240; pCreateInfo->iBkColor = COLOR_lightwhite; pCreateInfo->dwAddData = 0; pCreateInfo->hHosting = HWND_DESKTOP;}int MiniGUIMain (int args, const char* arg[]){ MSG Msg; MAINWINCREATE CreateInfo; HWND hMainWnd; InitCreateInfo (&CreateInfo); hMainWnd = CreateMainWindow (&CreateInfo); if (hMainWnd == HWND_INVALID)// exit (3); return -1; ShowWindow (hMainWnd, SW_SHOWNORMAL); while (GetMessage (&Msg, hMainWnd)) { TranslateMessage (&Msg); DispatchMessage (&Msg); } MainWindowThreadCleanup (hMainWnd); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -