?? menubutton.c
字號:
/*** $Id: menubutton.c,v 1.13 2007-10-25 08:31:37 weiym Exp $** ** Listing 24.1**** combobox.c: Sample program for MiniGUI Programming Guide** The usage of COMBOBOX control.** ** Copyright (C) 2004 ~ 2007 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, 150,#ifdef _LANG_ZHCN "約會大俠",#else "Meeting Plan",#endif 0, 0, 9, NULL, 0};static CTRLDATA CtrlMyDate[] ={ { "static", WS_CHILD | SS_RIGHT | WS_VISIBLE, 10, 20, 90, 20, IDC_STATIC,#ifdef _LANG_ZHCN "我打算于",#else "At ",#endif 0 }, { CTRL_COMBOBOX, WS_CHILD | WS_VISIBLE | CBS_READONLY | CBS_AUTOSPIN | CBS_AUTOLOOP, 100, 18, 40, 20, IDC_HOUR, "", 0 }, { "static", WS_CHILD | SS_CENTER | WS_VISIBLE, 140, 20, 20, 20, IDC_STATIC,#ifdef _LANG_ZHCN "時",#else ":",#endif 0 }, { CTRL_COMBOBOX, WS_CHILD | WS_VISIBLE | CBS_READONLY | CBS_AUTOSPIN | CBS_AUTOLOOP, 160, 18, 40, 20, IDC_MINUTE, "", 0 }, { "static", WS_CHILD | SS_CENTER | WS_VISIBLE, 200, 20, 30, 20, IDC_STATIC,#ifdef _LANG_ZHCN "去找",#else "I'll meet",#endif 0 }, { CTRL_MENUBUTTON, WS_CHILD | WS_VISIBLE, 240, 15, 100, 25, IDL_DAXIA, "", 0 },#ifdef _LANG_ZHCN { "static", WS_CHILD | SS_RIGHT | WS_VISIBLE, 10, 50, 280, 20, IDC_PROMPT, "怪僻", 0 },#else { "static", WS_CHILD | SS_RIGHT | WS_VISIBLE, 10, 50, 330, 35, IDC_PROMPT, "Zeus is the leader of the gods and god of the sky and thunder in Greek mythology.", 0 },#endif { CTRL_BUTTON, WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP, 30, 85, 130, 25, IDOK, "OK", 0 }, { "button", WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, 200, 85, 130, 25, IDCANCEL, "Cancel", 0 },};#ifdef _LANG_ZHCNstatic const char* daxia [] ={ "黃藥師", "歐陽鋒", "段皇爺", "洪七公", "周伯通", "郭靖", "黃蓉",};static const char* daxia_char [] ={ "怪僻", "惡毒", "假慈悲", "一身正氣", "調皮,不負責任", "傻乎乎", "乖巧",};#elsestatic const char* daxia [] ={ "Zeus", "Pan", "Apollo", "Heracles", "Achilles", "Jason", "Theseus",};static const char* daxia_char [] ={ "Zeus is the leader of the gods and god of the sky and thunder in Greek mythology.", "Pan is the Greek god who watches over shepherds and their flocks.", "Apollo is a god in Greek and Roman mythology, the son of Zeus and Leto, and the twin of Artemis.", "Heracles was the greatest of the mythical Greek heroes, best known for his superhuman strength and many stories are told of his life.", "Achilles was the greatest warrior in the Trojan War.", "Jason is a hero of Greek mythology. His father was Aeson, the rightful king of Iolcus.", "Theseus was a legendary king of Athens. Theseus was considered by Athenians as the great reformer.",};#endifstatic 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){#ifdef _LANG_ZHCN char date [1024] = "你的約會內容:\n";#else char date [1024] = "\n";#endif 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);#ifdef _LANG_ZHCN sprintf (date, "您打算于今日 %02d:%02d 去見那個%s的%s", hour, min, daxia_char [sel], daxia [sel]); MessageBox (hDlg, date, "約會內容", MB_OK | MB_ICONINFORMATION);#else sprintf (date, "You will meet %s at %02d:%02d", daxia [sel], hour, min); MessageBox (hDlg, date, "Meeting Plan", MB_OK | MB_ICONINFORMATION);#endif}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 _MGRM_PROCESSES JoinLayer(NAME_DEF_LAYER , "menubutton" , 0 , 0);#endif DlgMyDate.controls = CtrlMyDate; DialogBoxIndirectParam (&DlgMyDate, HWND_DESKTOP, MyDateBoxProc, 0L); return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -