📄 desktop.c
字号:
/* ** $Id: desktop.c,v 1.27 2005/02/18 08:29:48 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_CONTROLS 1101#define IDC_GDI 1102#define IDC_INTEGRATE 1103#define IDC_HTML 1104HWND hDesktop = 0;MDSCENE* current_scene = 0;BOOL is_scene_running = FALSE, scene_cmd_stop = FALSE;extern CTRLSCENE my_ctrl_scenes[];extern CTRLSCENE my_gdi_scenes[];extern int InitGDIScenes (MDSCENE *start_scene, MDSCENE *end_scene);extern void create_icon_desktop(HWND);extern HWND create_mgdillo_win (HWND, const char*);/* ----------------------------------- desktop scene -------------------------------- */static intdesktop_scene_proc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ switch (message) { case MSG_PAINT: { HDC hdc = BeginPaint (hWnd); FillBoxWithBitmap (hdc, 40, 20, 0, 0, bmp_feynman); EndPaint (hWnd, hdc); return 0; } } /* end switch */ return default_desktop_win_proc (hWnd, message, wParam, lParam);}int desktop_scene_init (HWND hWnd, MDSCENE *scene){ SetWindowBkColor (hWnd, PIXEL_lightwhite); UpdateWindow (hWnd, TRUE); CreateWindowEx ( "button", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_BITMAP, 0, IDC_GDI, //180, 30, 102, 44, 180, 10, 102, 35, hWnd,
#ifdef MGDEMO_ENGLISH
(DWORD)bmp_gdibtn_en);
#else
(DWORD)bmp_gdibtn);
#endif CreateWindowEx ( "button", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_BITMAP, 0, IDC_INTEGRATE, //180, 105, 102, 44, 180, 50, 102, 35, hWnd,
#ifdef MGDEMO_ENGLISH
(DWORD)bmp_integratebtn_en);
#else (DWORD)bmp_integratebtn);
#endif CreateWindowEx ( "button", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_BITMAP, 0, IDC_CONTROLS, 180, 90, 102, 35, hWnd,
#ifdef MGDEMO_ENGLISH
(DWORD)bmp_ctrlbtn_en);
#else
(DWORD)bmp_ctrlbtn);
#endif CreateWindowEx ( "button", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_BITMAP, 0, IDC_HTML, 180, 130, 102, 35, hWnd,
#ifdef MGDEMO_ENGLISH
(DWORD)bmp_htmlbtn_en);
#else (DWORD)bmp_htmlbtn);
#endif return 0;}void desktop_scene_deinit (HWND hWnd, MDSCENE *scene){ DestroyAllControls (hWnd);}const char * desktop_scene_tips[] ={
#ifdef MGDEMO_ENGLISH
"Wellcome to use MiniGUI",
#else "欢迎使用 MiniGUI 图形系统!",
#endif NULL};/* desktop scene */MDSCENE desktop_scene ={ NULL, NULL, desktop_scene_init, desktop_scene_deinit, desktop_scene_proc, desktop_scene_tips,};/* --------------------------------------------------------------------------------------- */void scene_changed (HWND hWnd, BOOL bNext){ extern HWND hStartbar; MDSCENE *old_scene = current_scene; scene_deinit (hWnd, current_scene); SendNotifyMessage (hStartbar, MSG_COMMAND, ID_SCENE, (LPARAM)old_scene); SendNotifyMessage (hTopbar, MSG_COMMAND, ID_SCENE, (LPARAM)old_scene); if (bNext) current_scene = current_scene->next; else current_scene = current_scene->prev; scene_init (hWnd, current_scene);}int goto_next_scene (HWND hWnd){ if (!current_scene || !current_scene->next) return 0; scene_changed (hWnd, TRUE); return 0;}int goto_prev_scene (HWND hWnd){ if (!current_scene || !current_scene->prev) return 0; scene_changed (hWnd, FALSE); return 0;}intdefault_desktop_win_proc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ switch (message) { case MSG_INITDIALOG: current_scene = &desktop_scene; desktop_scene.next = (MDSCENE *)my_ctrl_scenes; scene_init (hWnd, current_scene); InitControlScenes (&desktop_scene, NULL); InitGDIScenes (&desktop_scene, NULL); //SetTimer (hWnd, IDC_DKTIMER, 10); SetTimer (hWnd, IDC_DKTIMER, 100); return 1; case MSG_COMMAND: { int id = LOWORD(wParam); if (id == ID_NEXT) { if (is_scene_running) { scene_cmd_stop = TRUE; } else goto_next_scene (hWnd); } else if (id == ID_PREV) { if (is_scene_running) { scene_cmd_stop = TRUE; } else goto_prev_scene (hWnd); } else if (id == IDC_CONTROLS) { desktop_scene.next = (MDSCENE *)my_ctrl_scenes; goto_next_scene (hWnd); } else if (id == IDC_GDI) { desktop_scene.next = (MDSCENE *)my_gdi_scenes; goto_next_scene (hWnd); } else if (id == IDC_INTEGRATE) { create_icon_desktop (hWnd); } else if (id == IDC_HTML) { create_mgdillo_win (hWnd, NULL); } return 0; } case MSG_CLOSE: { KillTimer (hWnd, IDC_DKTIMER); DestroyAllControls (hWnd); DestroyMainWindow(hWnd); PostQuitMessage(hWnd); return 0; } } //end switch return DefaultMainWinProc(hWnd, message, wParam, lParam);}static int desktop_win_proc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ if (current_scene && current_scene->scene_proc) return current_scene->scene_proc(hWnd, message, wParam, lParam); else return default_desktop_win_proc (hWnd, message, wParam, lParam);}/*static CTRLDATA CtrlDesktop [] ={ { },};*/static DLGTEMPLATE DlgDesktop = { WS_NONE, WS_EX_NONE , 0, 25, SCR_WIDTH, (SCR_HEIGHT-25-STARTBAR_H), "desktop", 0, 0, //0, CtrlDesktop, 0, NULL, 0};HWND create_desktop (HWND hHosting){ hDesktop = CreateMainWindowIndirect(&DlgDesktop, hHosting, desktop_win_proc); return hDesktop;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -