?? z_j.c.bak
字號:
/*** $Id: combobox.c,v 1.10 2006/05/10 09:51:33 xwyan Exp $** ** Listing 23.1**** combobox.c: Sample program for MiniGUI Programming Guide** The usage of COMBOBOX control.** ** Copyright (C) 2004 ~ 2006 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 300#define _LANG_ZHCN 1static CTRLDATA CtrlMyDate[] ={ { CTRL_COMBOBOX, WS_VISIBLE | CBS_DROPDOWNLIST | CBS_NOTIFY, 240, 15, 100, 25, IDL_DAXIA, "", 80 }, { CTRL_BUTTON, WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP, 10, 90, 130, 25, IDOK, #ifdef _LANG_ZHCN "確定",#else "OK",#endif 0 }, { "button", WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, 210, 90, 130, 25, IDCANCEL,#ifdef _LANG_ZHCN "取消",#else "Cancel",#endif 0 },};static DLGTEMPLATE DlgMyDate ={ WS_BORDER | WS_CAPTION, WS_EX_NONE, 300, 300, 500, 150, "添加記錄", 0, 0, TABLESIZE(CtrlMyDate), NULL, 0};static const char* daxia [] ={ "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日",};static const char* daxia_char [] ={ "怪僻", "惡毒", "假慈悲", "一身正氣", "調皮,不負責任", "傻乎乎", "乖巧",};static void daxia_notif_proc (HWND hwnd, int id, int nc, DWORD add_data){ if (nc == CBN_SELCHANGE) { int cur_sel = SendMessage (hwnd, CB_GETCURSEL, 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, CB_GETCURSEL, 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++) { SendDlgItemMessage(hDlg, IDL_DAXIA, CB_ADDSTRING, 0, (LPARAM)daxia [i]); } SetNotificationCallback (GetDlgItem (hDlg, IDL_DAXIA), daxia_notif_proc); SendDlgItemMessage(hDlg, IDL_DAXIA, CB_SETCURSEL, 0, 0);#ifdef _LANG_ZHCN SetWindowText (GetDlgItem (hDlg, IDC_PROMPT), daxia_char [0]);#endif 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 z_j (hwnd){ DlgMyDate.controls = CtrlMyDate; DialogBoxIndirectParam (&DlgMyDate, hwnd, MyDateBoxProc, 0L); return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -