?? menubutton.c
字號(hào):
/*** $Id: menubutton.c,v 1.4 2004/06/06 03:27:56 weiym Exp $** ** Listing 11.1**** menubutton.c: Sample program for MiniGUI Programming Guide** The usage of MENUBUTTON control.** ** Copyright (C) 2003 Feynman Software.**** License: GPL*/#include <stdio.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#define IDC_HOUR 100#define IDC_MINUTE 110#define IDC_SECOND 120#define IDL_DAXIA 200#define IDC_PROMPT 300static DLGTEMPLATE DlgMyDate ={ WS_BORDER | WS_CAPTION, WS_EX_NONE, 100, 100, 360, 135, "約會(huì)大俠", 0, 0, 9, NULL, 0};static CTRLDATA CtrlMyDate[] ={ { "static", WS_CHILD | SS_RIGHT | WS_VISIBLE, 10, 20, 90, 20, IDC_STATIC, "我打算于", 0 }, { CTRL_COMBOBOX, WS_CHILD | WS_VISIBLE | CBS_READONLY | CBS_AUTOSPIN | CBS_AUTOLOOP | CBS_EDITBASELINE, 100, 18, 40, 20, IDC_HOUR, "", 0 }, { "static", WS_CHILD | SS_CENTER | WS_VISIBLE, 140, 20, 20, 20, IDC_STATIC, "時(shí)", 0 }, { CTRL_COMBOBOX, WS_CHILD | WS_VISIBLE | CBS_READONLY | CBS_AUTOSPIN | CBS_AUTOLOOP | CBS_EDITBASELINE, 160, 18, 40, 20, IDC_MINUTE, "", 0 }, { "static", WS_CHILD | SS_CENTER | WS_VISIBLE, 200, 20, 40, 20, IDC_STATIC, "去找", 0 }, { CTRL_MENUBUTTON, WS_CHILD | WS_VISIBLE, 240, 15, 100, 25, IDL_DAXIA, "", 0 }, { "static", WS_CHILD | SS_RIGHT | WS_VISIBLE, 10, 50, 280, 20, IDC_PROMPT, "This is", 0 }, { CTRL_BUTTON, WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP, 10, 70, 130, 25, IDOK, "確定", 0 }, { "button", WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, 150, 70, 130, 25, IDCANCEL, "取消", 0 },};static const char* daxia [] ={ "黃藥師", "歐陽(yáng)鋒", "段皇爺", "洪七公", "周伯通", "郭靖", "黃蓉",};static const char* daxia_char [] ={ "怪僻", "惡毒", "假慈悲", "一身正氣", "調(diào)皮,不負(fù)責(zé)任", "傻乎乎", "乖巧",};static void daxia_notif_proc (HWND hwnd, int id, int nc, DWORD add_data){ if (nc == CBN_SELCHANGE) { int cur_sel = SendMessage (hwnd, MBM_GETCURITEM, 0, 0); if (cur_sel >= 0) { SetWindowText (GetDlgItem (GetParent(hwnd), IDC_PROMPT), daxia_char [cur_sel]); } }}static void prompt (HWND hDlg){ char date [1024] = "你的約會(huì)內(nèi)容:\n"; int hour = SendDlgItemMessage(hDlg, IDC_HOUR, CB_GETSPINVALUE, 0, 0); int min = SendDlgItemMessage(hDlg, IDC_MINUTE, CB_GETSPINVALUE, 0, 0); int sel = SendDlgItemMessage(hDlg, IDL_DAXIA, MBM_GETCURITEM, 0, 0); sprintf (date, "您打算于今日 %02d:%02d 去見那個(gè)%s的%s", hour, min, daxia_char [sel], daxia [sel]); MessageBox (hDlg, date, "約會(huì)內(nèi)容", MB_OK | MB_ICONINFORMATION);}static int MyDateBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam){ int i; switch (message) { case MSG_INITDIALOG: SendDlgItemMessage(hDlg, IDC_HOUR, CB_SETSPINFORMAT, 0, (LPARAM)"%02d"); SendDlgItemMessage(hDlg, IDC_HOUR, CB_SETSPINRANGE, 0, 23); SendDlgItemMessage(hDlg, IDC_HOUR, CB_SETSPINVALUE, 20, 0); SendDlgItemMessage(hDlg, IDC_HOUR, CB_SETSPINPACE, 1, 1); SendDlgItemMessage(hDlg, IDC_MINUTE, CB_SETSPINFORMAT, 0, (LPARAM)"%02d"); SendDlgItemMessage(hDlg, IDC_MINUTE, CB_SETSPINRANGE, 0, 59); SendDlgItemMessage(hDlg, IDC_MINUTE, CB_SETSPINVALUE, 0, 0); SendDlgItemMessage(hDlg, IDC_MINUTE, CB_SETSPINPACE, 1, 2); for (i = 0; i < 7; i++) { MENUBUTTONITEM mbi; mbi.text = daxia[i]; mbi.bmp = NULL; mbi.data = 0; SendDlgItemMessage(hDlg, IDL_DAXIA, MBM_ADDITEM, -1, (LPARAM)&mbi); } SetNotificationCallback (GetDlgItem (hDlg, IDL_DAXIA), daxia_notif_proc); SendDlgItemMessage(hDlg, IDL_DAXIA, MBM_SETCURITEM, 0, 0); SetWindowText (GetDlgItem (hDlg, IDC_PROMPT), daxia_char [0]); return 1; case MSG_COMMAND: switch (wParam) { case IDOK: prompt (hDlg); case IDCANCEL: EndDialog (hDlg, wParam); break; } break; } return DefaultDialogProc (hDlg, message, wParam, lParam);}int MiniGUIMain (int argc, const char* argv[]){#ifdef _LITE_VERSION SetDesktopRect(0, 0, 1024, 768);#endif DlgMyDate.controls = CtrlMyDate; DialogBoxIndirectParam (&DlgMyDate, HWND_DESKTOP, MyDateBoxProc, 0L); return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -