⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 miniguidemo.c~

📁 minigui的相关资料建立minigui环境必需
💻 C~
📖 第 1 页 / 共 3 页
字号:
/* ** $Id: miniguidemo.c,v 1.7 2003/06/13 07:15:49 weiym Exp $**** Listing 2.1**** helloworld.c: Sample program for MiniGUI Programming Guide**      The first MiniGUI application.**** Copyright (C) 2003 Feynman Software.**** License: GPL*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <signal.h>#include <time.h>#include <sys/types.h>#include <sys/wait.h>#include <math.h>/* This isn't in the headers */#ifndef M_PI#define M_PI        3.14159265358979323846#endif#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include "miniguidemo.h"//Controls Liststatic int p_offset  = 0;static int offset    = 0;static int offset_v  = 0;static RECT rcCircle = {0,0, 320, 240};/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/#if 0static int ProgressBarProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam){    int i, sum;        switch(message)    {    	case MSG_INITDIALOG:			SendDlgItemMessage (hDlg, 100, PBM_SETRANGE, 50, 500);			return 1;        	case MSG_KEYDOWN:			printf("Press  %d\n",wParam);			printf("p_offset  %d\n",p_offset);			switch(wParam) 			{	    		case SCANCODE_CURSORBLOCKLEFT:					p_offset -= 10;					SendDlgItemMessage (hDlg, 100, PBM_SETPOS, p_offset, 0L);					break;	    		    		case SCANCODE_CURSORBLOCKRIGHT:					p_offset += 10;					SendDlgItemMessage (hDlg, 100, PBM_SETPOS, p_offset, 0L);					break;	    		    		case SCANCODE_ESCAPE:					PostMessage (hDlg, MSG_CLOSE, 0, 0);					break;			}			break;    }    return DefaultMainWinProc (hDlg, message, wParam, lParam);}#endif/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static int InputCharDialogBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam){    static PLOGFONT my_font;    HWND hwnd;    switch (message)     {    	case MSG_INITDIALOG:        	my_font = CreateLogFont (NULL, "Arial", "ISO8859-1",                         FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,                        FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,                         30, 0);			hwnd = GetDlgItem (hDlg, IDC_CHAR);			SetWindowFont (hwnd, my_font);			SendMessage (hwnd, MSG_KEYDOWN, SCANCODE_INSERT, 0L);        	return 1;		/*    	case MSG_KEYDOWN:			switch(wParam) 			{	    		case SCANCODE_ESCAPE:				PostMessage (hDlg, MSG_CLOSE, 0, 0);				break;			}			break;		*/    	case MSG_COMMAND:        	switch (wParam)         	{        		case IDOK:        		case IDCANCEL:	    			DestroyLogFont (my_font);            		EndDialog (hDlg, wParam);            		break;        	}        	break;    }    return DefaultDialogProc (hDlg, message, wParam, lParam);}/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static int radius = 10;static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data){    if (nc == TBN_CHANGE)     {        radius = SendMessage (hwnd, TBM_GETPOS, 0, 0);        InvalidateRect (GetParent (hwnd), &rcCircle, TRUE);    }}/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static int TrackDemoProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    HWND hwnd;    switch (message)     {    	case MSG_CREATE:        	hwnd = CreateWindow (CTRL_TRACKBAR,                           "",                           WS_VISIBLE | TBS_NOTIFY | TBS_TIP,                           100,                           10, 10, 280, 50, hWnd, 0);	   //zhaoic			SetFocusChild (hwnd);        	SendMessage (hwnd, TBM_SETRANGE, 0, 100);        	SendMessage (hwnd, TBM_SETLINESIZE, 1, 0);        	SendMessage (hwnd, TBM_SETPAGESIZE, 10, 0);        	SendMessage (hwnd, TBM_SETTICKFREQ, 10, 0);        	SendMessage (hwnd, TBM_SETPOS, radius, 0);        	SetNotificationCallback (hwnd, my_notif_proc);        	break;    	case MSG_PAINT:        	{HDC hdc = BeginPaint (hWnd);        	ClipRectIntersect (hdc, &rcCircle);        	Circle (hdc, 140, 120, radius);        	EndPaint (hWnd, hdc);        	return 0;}           	case MSG_COMMAND:        	switch (wParam)         	{        		case IDOK:        		case IDCANCEL:            	EndDialog (hWnd, wParam);            	break;        	}        	break;    	case MSG_KEYDOWN:			switch(wParam) 			{	    		case SCANCODE_ESCAPE:					PostMessage (hWnd, MSG_CLOSE, 0, 0);					break;			}			break;    	case MSG_DESTROY:        	DestroyAllControls (hWnd);        	return 0;    	case MSG_CLOSE:        	DestroyMainWindow (hWnd);        	PostQuitMessage (hWnd);        	return 0;   	}    return DefaultMainWinProc(hWnd, message, wParam, lParam);}///gdidemo proc/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static void TellSpeed (HWND hwnd, unsigned int start_tick, unsigned int end_tick, const char* drawing, unsigned int count){        char buff [1024];        unsigned int seconds = (end_tick - start_tick)/100;        sprintf (buff, "Draw %u %s(s) whthin %u seconds. \n\n"                        "Spend %f second for per-drawing.",                         count, drawing, seconds, (end_tick - start_tick) / (count * 100.0));        MessageBox (hwnd, buff, drawing, MB_OK | MB_ICONINFORMATION);}/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static void TellNotImplemented (HWND hwnd, const char* drawing){    char buff [1024];    sprintf (buff, "%s: not implemented. \n", drawing);    MessageBox (hwnd, buff, drawing, MB_OK | MB_ICONINFORMATION);}#define CHECK_MSG#define DEFAULT_WIDTH   320#define DEFAULT_HEIGHT  240#define DEFAULT_X       320#define DEFAULT_Y       240/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static void GDIDemo_NormalLines (HWND hwnd, HDC hdc){    int x = DEFAULT_X, y = DEFAULT_Y;    int tox = DEFAULT_WIDTH, toy = DEFAULT_WIDTH;    int count;    unsigned int start_tick, end_tick;    unsigned int nr_colors = GetGDCapability (hdc, GDCAP_COLORNUM);    /* Line */    start_tick = GetTickCount ();    count = 3000;    SetPenColor (hdc, PIXEL_yellow);        while (count--)     {        SetPenColor (hdc, rand() % nr_colors);        MoveTo (hdc, x, y);        LineTo (hdc, tox, toy);        tox = rand() % DEFAULT_WIDTH;        toy = rand() % DEFAULT_WIDTH;        CHECK_MSG;    }        end_tick = GetTickCount ();    TellSpeed (hwnd, start_tick, end_tick, "Line", 100000);    /* Circle */    start_tick = GetTickCount ();    count = 3000;    while (count--) {        tox = rand() % DEFAULT_WIDTH;        toy = rand() % DEFAULT_WIDTH;        SetPenColor (hdc, rand() % nr_colors);        Circle (hdc, tox, toy, rand() % DEFAULT_X);        CHECK_MSG;    }    end_tick = GetTickCount ();    TellSpeed (hwnd, start_tick, end_tick, "Circle", 10000);}/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static void GDIDemo_Filling (HWND hwnd, HDC hdc){    int tox = DEFAULT_WIDTH, toy = DEFAULT_WIDTH;    int count;    unsigned int start_tick, end_tick;    unsigned int nr_colors = GetGDCapability (hdc, GDCAP_COLORNUM);    /* Filled Box */    start_tick = GetTickCount ();    count = 3000;    while (count--) {        tox = rand() % DEFAULT_WIDTH;        toy = rand() % DEFAULT_WIDTH;        SetBrushColor (hdc, rand() % nr_colors);        FillBox (hdc, tox, toy, rand() % DEFAULT_X, rand() % DEFAULT_Y);        CHECK_MSG;    }    end_tick = GetTickCount ();    TellSpeed (hwnd, start_tick, end_tick, "Filled Box", 500);    TellNotImplemented (hwnd, "Filled Circle");}/*
*************************************************************************************************************
- 函数名称 : Exep_S3cint_Init(void)
- 函数说明 : 异常及中断控制器的初始化
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/static void GDIDemo_MemDC (HWND hwnd, HDC hdc){    HDC mem_dc;    int tox = DEFAULT_WIDTH, toy = DEFAULT_WIDTH;    int count;    unsigned int start_tick, end_tick;    unsigned int nr_colors = GetGDCapability (hdc, GDCAP_COLORNUM);        /* Compatible DC */    mem_dc = CreateCompatibleDC (hdc);    SetBrushColor (mem_dc, 0);    FillBox (mem_dc, 0, 0, 65535, 65535);    start_tick = GetTickCount ();    count = 3000;    while (count--) {        tox = rand() % DEFAULT_WIDTH; toy = rand() % DEFAULT_WIDTH;        MoveTo (mem_dc, tox, toy);        SetPenColor (mem_dc, rand() % nr_colors);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -