?? input.c
字號:
/* ** $Id: input.c,v 1.7 2004/06/17 10:36:04 weiym Exp $**** Listing 5.2**** input.c: Sample program for MiniGUI Programming Guide** Use dialog box to interact with user.**** Copyright (C) 2003 Feynman Software.**** License: GPL*/#include <stdio.h>#include <stdlib.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>static DLGTEMPLATE DlgBoxInputLen ={ WS_BORDER | WS_CAPTION, WS_EX_NONE, 0, 0, 400, 160, "請輸入長度", 0, 0, 4, NULL, 0};#define IDC_SIZE_MM 100#define IDC_SIZE_INCH 110static CTRLDATA CtrlInputLen [] ={ { CTRL_STATIC, WS_VISIBLE | SS_SIMPLE, 10, 10, 380, 18, IDC_STATIC, "請輸入長度(單位:毫米)", 0 }, { CTRL_EDIT, WS_VISIBLE | WS_TABSTOP | WS_BORDER, 10, 40, 380, 24, IDC_SIZE_MM, NULL, 0 }, { CTRL_STATIC, WS_VISIBLE | SS_SIMPLE, 10, 70, 380, 18, IDC_SIZE_INCH, "相當于 0.00 英寸", 0 }, { CTRL_BUTTON, WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, 170, 100, 60, 25, IDOK, "確定", 0 }};static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data){ if (id == IDC_SIZE_MM && nc == EN_CHANGE) { char buff [60]; double len; GetWindowText (hwnd, buff, 32); len = (double) atoi (buff); len = len / 25.4; sprintf (buff, "相當于 %.5f 英寸", len); SetDlgItemText (GetParent (hwnd), IDC_SIZE_INCH, buff); }} static int InputLenDialogBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam){ switch (message) { case MSG_INITDIALOG: SetWindowAdditionalData (hDlg, lParam); SetNotificationCallback (GetDlgItem (hDlg, IDC_SIZE_MM), my_notif_proc); return 1; case MSG_COMMAND: switch (wParam) { case IDOK: { char buff [40]; double* length = (double*) GetWindowAdditionalData (hDlg); GetWindowText (GetDlgItem (hDlg, IDC_SIZE_MM), buff, 32); *length = (double) atoi (buff); printf("confirm button pressed!"); } case IDCANCEL: EndDialog (hDlg, wParam); break; } break; } return DefaultDialogProc (hDlg, message, wParam, lParam);}static void InputLenDialogBox (HWND hWnd, double* length){ DlgBoxInputLen.controls = CtrlInputLen; DialogBoxIndirectParam (&DlgBoxInputLen, hWnd, InputLenDialogBoxProc, (LPARAM)length);}int MiniGUIMain (int argc, const char* argv[]){ double length;#ifdef _LITE_VERSION SetDesktopRect(0, 0, 1024, 768);#endif InputLenDialogBox (HWND_DESKTOP, &length); printf ("The length is %.5f mm.\n", length); return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -