📄 painter.c
字号:
/* ** $Id: painter.c,v 1.3 2003/11/23 13:09:22 weiym Exp $**** Listing 24.3**** painter.c: Sample program for MiniGUI Programming Guide** Painting by using mouse.**** Copyright (C) 2003 Feynman Software.**** License: GPL*/#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>static int PainterWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ HDC hdc; static BOOL bdraw = FALSE; static int pre_x, pre_y; switch (message) { case MSG_LBUTTONDOWN: bdraw = TRUE; SetCapture(hWnd); pre_x = LOWORD (lParam); pre_y = HIWORD (lParam); break; case MSG_MOUSEMOVE: { int x = LOWORD (lParam); int y = HIWORD (lParam); ScreenToClient(hWnd, &x, &y); if (bdraw) { hdc = GetClientDC(hWnd); SetPenColor(hdc, PIXEL_red); MoveTo(hdc, pre_x, pre_y); LineTo(hdc, x, y); ReleaseDC(hdc); pre_x = x; pre_y = y; } break; } case MSG_LBUTTONUP: bdraw = FALSE; ReleaseCapture(); break; case MSG_RBUTTONDOWN: InvalidateRect(hWnd, NULL, TRUE); break; case MSG_CLOSE: DestroyAllControls (hWnd); DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc (hWnd, message, wParam, lParam);}int MiniGUIMain (int args, const char* arg[]){ MSG Msg; HWND hMainWnd; MAINWINCREATE CreateInfo;#ifdef _LITE_VERSION SetDesktopRect(0, 0, 1024, 768);#endif CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION; CreateInfo.dwExStyle = WS_EX_NONE; CreateInfo.spCaption = "painter"; CreateInfo.hMenu = 0; CreateInfo.hCursor = GetSystemCursor(0); CreateInfo.hIcon = 0; CreateInfo.MainWindowProc = PainterWinProc; CreateInfo.lx = 0; CreateInfo.ty = 0; CreateInfo.rx = 240; CreateInfo.by = 320; 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;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -