📄 mgdemo.c
字号:
/* ** $Id: mgdemo.c,v 1.20 2005/02/18 08:31:12 lihong Exp $**** The main programm of minigui presentation**** Copyright (C) 2004 Feynman Software.**** Create date: 2004/07/20*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <locale.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <minigui/mgext.h>#include "global.h"#define IDC_TIMER 100HWND hStartbar = 0, hTopbar = 0;extern MDSCENE *current_scene;extern MDSCENE desktop_scene;void create_splash_window (void);void OpenTpDialogBox (HWND hWnd);static void init_btn_bmp (void){ gal_pixel pixel;#ifdef MGDEMO_ENGLISH
pixel = GetPixelInBitmap (bmp_forward_en, bmp_forward_en->bmWidth - 1, 0);
#else
pixel = GetPixelInBitmap (bmp_forward, bmp_forward->bmWidth - 1, 0);
#endif bmp_b_default->bmType = BMP_TYPE_COLORKEY; bmp_b_default->bmColorKey = pixel;
#ifdef MGDEMO_ENGLISH
pixel = GetPixelInBitmap (bmp_back_en, 0, 0);
#else
pixel = GetPixelInBitmap (bmp_back, 0, 0);
#endif bmp_b_default->bmType = BMP_TYPE_COLORKEY; bmp_b_default->bmColorKey = pixel;}/*******************************************************************************/static int TopbarWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ switch (message) { case MSG_INITDIALOG: SetWindowBkColor (hWnd, PIXEL_blue); UpdateWindow (hWnd, TRUE); return 1; case MSG_LBUTTONDOWN: { int x = LOWORD(lParam); if (x > 256) { SendNotifyMessage (hDesktop, MSG_COMMAND, ID_NEXT, 0); return 0; } else if (x > 192) { SendNotifyMessage (hDesktop, MSG_COMMAND, ID_PREV, 0); return 0; } break; } case MSG_COMMAND: if (wParam == ID_SCENE) { if ( current_scene == &desktop_scene || (MDSCENE*)lParam == &desktop_scene ) InvalidateRect (hWnd, NULL, TRUE); return 0; } break; case MSG_PAINT: { HDC hdc = BeginPaint (hWnd); if (current_scene != &desktop_scene) {
#ifdef MGDEMO_ENGLISH
FillBoxWithBitmap (hdc, 192, 3, 0, 0, bmp_back_en);
FillBoxWithBitmap (hdc, 256, 3, 0, 0, bmp_forward_en);
#else
FillBoxWithBitmap (hdc, 192, 3, 0, 0, bmp_back);
FillBoxWithBitmap (hdc, 256, 3, 0, 0, bmp_forward);
#endif } EndPaint (hWnd, hdc); return 0; } case MSG_CLOSE: { DestroyAllControls (hWnd); DestroyMainWindow(hWnd); PostQuitMessage(hWnd); return 0; } } //end switch return DefaultMainWinProc(hWnd, message, wParam, lParam);}static int StartbarWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ static RECT rcMsg; const char *text; static int txt_idx = 0; switch (message) { case MSG_INITDIALOG: SetWindowBkColor (hWnd, PIXEL_blue); UpdateWindow (hWnd, TRUE); GetClientRect (hWnd, &rcMsg); //SetTimer (hWnd, IDC_TIMER, 100); SetTimer (hWnd, IDC_TIMER, 1000); return 1; case MSG_PAINT: { HDC hdc = BeginPaint (hWnd); SetBkColor (hdc, PIXEL_blue); SetBkMode (hdc, BM_TRANSPARENT); SetTextColor (hdc, PIXEL_lightwhite); if (current_scene && current_scene->tips[txt_idx]) { text = current_scene->tips[txt_idx]; DrawText (hdc, text, strlen(text), &rcMsg, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } EndPaint (hWnd, hdc); return 0; } case MSG_TIMER: { if (current_scene->tips[txt_idx] && current_scene->tips[txt_idx+1]) { txt_idx ++; InvalidateRect (hWnd, NULL, TRUE); } return 0; } case MSG_COMMAND: if (wParam == ID_SCENE) { txt_idx = 0; InvalidateRect (hWnd, NULL, TRUE); return 0; } break; case MSG_CLOSE: { KillTimer (hWnd, IDC_TIMER); DestroyAllControls (hWnd); DestroyMainWindow(hWnd); PostQuitMessage(hWnd); return 0; } } //end switch return DefaultMainWinProc(hWnd, message, wParam, lParam);}/* -------------------------------------------------------------------------- */#define MARGIN 1#define BTN_W ((SCR_WIDTH-MARGIN)/4-MARGIN)#define BTN_H (STARTBAR_H-MARGIN*2-MARGIN)/*static CTRLDATA CtrlNull[] ={ {},};*/static DLGTEMPLATE DlgMenubar = { WS_NONE, WS_EX_TOOLWINDOW | WS_EX_TOPMOST, 0, (SCR_HEIGHT-STARTBAR_H) , SCR_WIDTH, STARTBAR_H , "menubar", 0, 0, 0, NULL, 0};static DLGTEMPLATE DlgCaption ={ WS_NONE, WS_EX_TOOLWINDOW | WS_EX_TOPMOST, 0, 0, SCR_WIDTH, 25, "caption", 0, 0, 0, NULL, 0};int MiniGUIMain (int args, const char* arg[]){ MSG Msg; if (!InitMiniGUIExt()) { return 2; }printf ("begin MiniGUI Main\n");#ifndef _MD_INCORE_BMP fhbmp_load_all ("res/");#endif#if 0 OpenTpDialogBox (HWND_DESKTOP); #endif create_splash_window (); hStartbar = CreateMainWindowIndirect(&DlgMenubar, HWND_DESKTOP, StartbarWinProc); if(hStartbar == HWND_INVALID) return -1; hTopbar = CreateMainWindowIndirect(&DlgCaption, hStartbar, TopbarWinProc); create_desktop (hStartbar); while(GetMessage(&Msg, hStartbar)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } RegisterKeyMsgHook (NULL, NULL); MainWindowThreadCleanup(hStartbar);#ifndef _MD_INCORE_BMP fhbmp_unload_all ();#endif return 0;}#ifndef _LITE_VERSION#include "minigui/dti.c"#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -