📄 monthcal.c
字号:
#include <stdlib.h>#include <time.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <minigui/mywindows.h>#include <minigui/mgext.h>#include "monthcal.h"#include "../../mybuttonreg.h"#define IDC_MC 100#define IDC_OK 200#define IDC_RETURN 201static BITMAP OK_pushed;static BITMAP OK_unpushed;static BITMAP OK_mousemove;static BITMAP return_pushed;static BITMAP return_unpushed;static BITMAP return_mousemove;static BITMAP jpg_bkgnd_MC;static HWND HMonth;static HWND hCtrl_OK;static HWND hCtrl_return;static void emLoadBitmap(){ LoadBitmap (HDC_SCREEN, &OK_pushed, "image/button/tool_creat_pushed.jpg"); LoadBitmap (HDC_SCREEN, &OK_unpushed, "image/button/tool_creat_unpushed.jpg"); LoadBitmap (HDC_SCREEN, &OK_mousemove, "image/button/tool_creat_mousemove.jpg"); LoadBitmap (HDC_SCREEN, &return_pushed, "image/button/tool_return_pushed.jpg"); LoadBitmap (HDC_SCREEN, &return_unpushed, "image/button/tool_return_unpushed.jpg"); LoadBitmap (HDC_SCREEN, &return_mousemove, "image/button/tool_return_mousemove.jpg"); }static void emUnLoadBitmap(){ UnloadBitmap (&OK_pushed); UnloadBitmap (&OK_unpushed); UnloadBitmap (&OK_mousemove); UnloadBitmap (&return_pushed); UnloadBitmap (&return_unpushed); UnloadBitmap (&return_mousemove);}static void Monthcal_notify_proc (HWND hwnd, int id, int nc, DWORD add_data){ if ( hwnd == hCtrl_OK&& nc == MYBUTTON_PUSHED) { //SetWindowAdditionalData(hwnd, (DWORD)&OK_pushed); } if ( hwnd == hCtrl_OK && nc == BN_CLICKED&&id==IDC_OK) { //SetWindowAdditionalData(hwnd, (DWORD)&OK_unpushed); SendNotifyMessage(HMonth,IDC_OK,0,0); } if( hwnd == hCtrl_OK && nc == MYBUTTON_MOUSEMOVE) { //SetWindowAdditionalData(hwnd, (DWORD)&OK_mousemove); } //----------------------------------------------------------- if ( hwnd == hCtrl_return&& nc == MYBUTTON_PUSHED) { //SetWindowAdditionalData(hwnd, (DWORD)&return_pushed); } if ( hwnd == hCtrl_return && nc == BN_CLICKED&&id==IDC_RETURN) { //SetWindowAdditionalData(hwnd, (DWORD)&return_unpushed); SendNotifyMessage(HMonth,MSG_CLOSE,0,0); } if( hwnd == hCtrl_return && nc == MYBUTTON_MOUSEMOVE) { //SetWindowAdditionalData(hwnd, (DWORD)&return_mousemove ); }//----------------------------------------------------------- InvalidateRect (hwnd, NULL, TRUE);}DLGTEMPLATE DlgTime = { WS_VISIBLE | WS_CAPTION | WS_BORDER, WS_EX_NONE, 0, 0, 320, 216, "日历", 0, 0, 0, 0, 0};/*******************************************************************************/static int TimeWinProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam){ HDC hdc = (HDC)wParam; const RECT* clip = (const RECT*) lParam; BOOL fGetDC = FALSE; RECT rcTemp; switch (message) { case MSG_INITDIALOG: HMonth=hDlg; //emLoadBitmap(); CreateWindow ("monthcalendar", "monthcalendar", WS_CHILD | WS_VISIBLE | MCS_NOTIFY | MCS_CHN, IDC_MC, 10, 5, 220, 178, HMonth, 0); /* hCtrl_OK= CreateWindowEx(CTRL_MYBUTTON, "日程表", WS_VISIBLE | WS_CHILD, WS_EX_TRANSPARENT, IDC_OK, 235, 35, 70, 28, HMonth, (DWORD)&OK_unpushed); */ hCtrl_OK =CreateWindow ("button", "日程表", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, IDC_OK, 235, 35, 70, 28, HMonth,0); /* hCtrl_return= CreateWindowEx(CTRL_MYBUTTON, "返回", WS_VISIBLE | WS_CHILD, WS_EX_TRANSPARENT, IDC_RETURN, 235, 120, 70, 28, HMonth, (DWORD)&return_unpushed);*/ hCtrl_return =CreateWindow ("button", "返回", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, IDC_RETURN, 235, 120, 70, 28, HMonth,0); SetNotificationCallback ( hCtrl_OK, Monthcal_notify_proc); SetNotificationCallback ( hCtrl_return, Monthcal_notify_proc ); break; case MSG_MOUSEMOVE: SetWindowAdditionalData( hCtrl_OK, (DWORD)&OK_unpushed ); InvalidateRect (hCtrl_OK, NULL, TRUE); SetWindowAdditionalData( hCtrl_return, (DWORD)&return_unpushed ); InvalidateRect (hCtrl_return, NULL, TRUE); break; case MSG_ERASEBKGND: if (hdc == 0) { hdc = GetClientDC (HMonth); fGetDC = TRUE; } if (clip) { rcTemp = *clip; ScreenToClient (HMonth, &rcTemp.left, &rcTemp.top); ScreenToClient (HMonth, &rcTemp.right, &rcTemp.bottom); IncludeClipRect (hdc, &rcTemp); }// FillBoxWithBitmap (hdc, rcTemp.left, rcTemp.top, 0, 0, &jpg_bkgnd_EM); FillBoxWithBitmap (hdc, 0, 0, 320, 192, &jpg_bkgnd_MC); if (fGetDC) ReleaseDC (hdc); return 0; case IDC_OK: month( hDlg); break; case MSG_CLOSE: { //emUnLoadBitmap(); EndDialog (hDlg, 0); } return 0; } return DefaultDialogProc (hDlg, message, wParam, lParam);}int monthcal (HWND hWnd){ if (!InitMiniGUIExt()) { return 2; }RegisterMyButtonControl ();// DlgTime.controls = CtrlTime; LoadBitmap (HDC_SCREEN, &jpg_bkgnd_MC, "./image/background/bkgnd29.jpg"); DialogBoxIndirectParam (&DlgTime, HWND_DESKTOP, TimeWinProc, 0L); MiniGUIExtCleanUp (); UnloadBitmap(&jpg_bkgnd_MC); UnregisterMyButtonControl (); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -