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

📄 duplexeditor.c

📁 这是linux下 MiniGUI的一个程序
💻 C
字号:
/*** $Id: main.c,v 1.12 2005/05/29 02:17:41 JuncofeniteXu Exp $**** DCU-99Editor, the M$ Windows like Para Editor on MiniGUI.** Copyright (c) 2005, ZYE (710@www.710.com).**** Some idea and source come from VConGUI (Virture Console GUI) **** Create date: ** BTW: today, my sweetheart lovly MinMin comes back from millitery training.*/ /***  This source is not free software; but you can redistribute it and/or**  modify it under the terms of the GNU General Public**  License as published by the Free Software Foundation; either**  version 2 of the License, or (at your option) any later version.****  This software is distributed in the hope that it will be useful,**  but WITHOUT ANY WARRANTY; without even the implied warranty of**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU**  General Public License for more details.****  You should have received a copy of the GNU General Public**  License along with this library; if not, write to the Free**  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,**  MA 02111-1307, USA*//*** Modify records:****  Who             	 When         Where       For What                Status**-----------------------------------------------------------------------------** TODO:*/#include <stdio.h>#include <stdlib.h>#include <string.h> #include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include "DuplexEditor.h"static int duplex_MainFuncProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    static HWND hChilWndMainKey[17], hChildWndAssistantKey[10], hChildWndAssistantKeyTitle[10];    static int sel = -1, tag = -1;    static char Mkey[265];    char Akey[47];    //because Mkey use in different command, but Akey just used in one command(the change have been reserverd)    int i = 0;    switch (message)     {    	case MSG_INITDIALOG:     	{   	    		    	SendDlgItemMessage(hWnd, duplex_KeyTypeSel, CB_ADDSTRING, 0, (LPARAM)"主密钥");    	SendDlgItemMessage(hWnd, duplex_KeyTypeSel, CB_ADDSTRING, 0, (LPARAM)"辅助密钥");    	SendDlgItemMessage(hWnd, duplex_KeyTypeSel, CB_SETCURSEL, 0, 0);     	sel = 0;    	tag = 0;    	     	hChilWndMainKey[ 0] = -1;    	hChilWndMainKey[ 1] = GetDlgItem(hWnd, duplex_MainKey01Edit);    	hChilWndMainKey[ 2] = GetDlgItem(hWnd, duplex_MainKey02Edit);    	hChilWndMainKey[ 3] = GetDlgItem(hWnd, duplex_MainKey03Edit);    	hChilWndMainKey[ 4] = GetDlgItem(hWnd, duplex_MainKey04Edit);    	hChilWndMainKey[ 5] = GetDlgItem(hWnd, duplex_MainKey05Edit);    	hChilWndMainKey[ 6] = GetDlgItem(hWnd, duplex_MainKey06Edit);    	hChilWndMainKey[ 7] = GetDlgItem(hWnd, duplex_MainKey07Edit);    	hChilWndMainKey[ 8] = GetDlgItem(hWnd, duplex_MainKey08Edit);    	hChilWndMainKey[ 9] = GetDlgItem(hWnd, duplex_MainKey09Edit);    	hChilWndMainKey[10] = GetDlgItem(hWnd, duplex_MainKey10Edit);    	hChilWndMainKey[11] = GetDlgItem(hWnd, duplex_MainKey11Edit);    	hChilWndMainKey[12] = GetDlgItem(hWnd, duplex_MainKey12Edit);    	hChilWndMainKey[13] = GetDlgItem(hWnd, duplex_MainKey13Edit);    	hChilWndMainKey[14] = GetDlgItem(hWnd, duplex_MainKey14Edit);    	hChilWndMainKey[15] = GetDlgItem(hWnd, duplex_MainKey15Edit);    	hChilWndMainKey[16] = GetDlgItem(hWnd, duplex_MainKey16Edit);    	    	hChildWndAssistantKeyTitle[0] = GetDlgItem(hWnd, duplex_AssistantKey0);    	hChildWndAssistantKey[0] = GetDlgItem(hWnd, duplex_AssistantKeyEdit0);    	hChildWndAssistantKeyTitle[1] = GetDlgItem(hWnd, duplex_AssistantKey1);    	hChildWndAssistantKey[1] = GetDlgItem(hWnd, duplex_AssistantKeyEdit1);    	hChildWndAssistantKeyTitle[2] = GetDlgItem(hWnd, duplex_AssistantKey2);    	hChildWndAssistantKey[2] = GetDlgItem(hWnd, duplex_AssistantKeyEdit2);    	hChildWndAssistantKeyTitle[3] = GetDlgItem(hWnd, duplex_AssistantKey3);    	hChildWndAssistantKey[3] = GetDlgItem(hWnd, duplex_AssistantKeyEdit3);    	hChildWndAssistantKeyTitle[4] = GetDlgItem(hWnd, duplex_AssistantKey4);    	hChildWndAssistantKey[4] = GetDlgItem(hWnd, duplex_AssistantKeyEdit4);    	hChildWndAssistantKeyTitle[5] = GetDlgItem(hWnd, duplex_AssistantKey5);    	hChildWndAssistantKey[5] = GetDlgItem(hWnd, duplex_AssistantKeyEdit5);    	hChildWndAssistantKeyTitle[6] = GetDlgItem(hWnd, duplex_AssistantKey6);    	hChildWndAssistantKey[6] = GetDlgItem(hWnd, duplex_AssistantKeyEdit6);    	hChildWndAssistantKeyTitle[7] = GetDlgItem(hWnd, duplex_AssistantKey7);    	hChildWndAssistantKey[7] = GetDlgItem(hWnd, duplex_AssistantKeyEdit7);    	hChildWndAssistantKeyTitle[8] = GetDlgItem(hWnd, duplex_AssistantKey8);    	hChildWndAssistantKey[8] = GetDlgItem(hWnd, duplex_AssistantKeyEdit8);    	hChildWndAssistantKeyTitle[9] = GetDlgItem(hWnd, duplex_AssistantKey9);     	hChildWndAssistantKey[9] = GetDlgItem(hWnd, duplex_AssistantKeyEdit9);   	    	    	for(i = 1; i < 17; i++ )    		SendMessage(hChilWndMainKey[i], EM_LIMITTEXT,4,0);    		    	for(i = 0; i < 10; i++ )    		SendMessage(hChildWndAssistantKey[i], EM_LIMITTEXT,4,0);        				//initial the interface as main key edit   	     				SendDlgItemMessage(hWnd, duplex_KeyDistinguishWordEdit, EM_LIMITTEXT, 4, 0);	SetWindowText(GetDlgItem(hWnd, duplex_KeyDistinguishWord), "鉴别字:");        			        				ShowWindow(GetDlgItem(hWnd, duplex_MainKey01To08), SW_SHOW);	ShowWindow(GetDlgItem(hWnd, duplex_MainKey09To16), SW_SHOW);	ShowWindow(GetDlgItem(hWnd, duplex_BackOff), SW_SHOW);		for(i = 1; i < 17; i++ )		ShowWindow(hChilWndMainKey[i], SW_SHOW);		    	for(i = 0; i < 10; i++ )    	{    		ShowWindow(hChildWndAssistantKey[i], SW_HIDE);    		ShowWindow(hChildWndAssistantKeyTitle[i], SW_HIDE);    	}		SetWindowText(GetDlgItem(hWnd, duplex_NextOk), "下一步/确定");		        } 			    	break;    	    	case MSG_COMMAND:        switch(LOWORD(wParam))//some controls must use wParam's party to decide which one ,so must use HIGHWORD(),LOWORD()        {		case	duplex_KeyTypeSel:        	{        			//int sel = -1;			//obtain the type			if(HIWORD(wParam) != CBN_SELCHANGE)				break;        		sel = SendDlgItemMessage(hWnd, duplex_KeyTypeSel, CB_GETCURSEL, 0, 0);         		//devision the first edit frame's name(the second static text) and limit length(4,2)        		//mainkey distinguish word:0~0x270f(0~9999), four bits of  0xXXXX; assistant key: 0~99 ,two digital bits        		//show or hide some windows        		if(sel == 0) //main keys        		{        			        			SendDlgItemMessage(hWnd, duplex_KeyDistinguishWordEdit, EM_LIMITTEXT, 4, 0);        			SetWindowText(GetDlgItem(hWnd, duplex_KeyDistinguishWordEdit), "");				SetWindowText(GetDlgItem(hWnd, duplex_KeyDistinguishWord), "鉴别字:");        						        							ShowWindow(GetDlgItem(hWnd, duplex_MainKey01To08), SW_SHOW);				ShowWindow(GetDlgItem(hWnd, duplex_MainKey09To16), SW_SHOW);				ShowWindow(GetDlgItem(hWnd, duplex_BackOff), SW_SHOW);								for(i = 1; i < 17; i++ )					ShowWindow(hChilWndMainKey[i], SW_SHOW);								    	for(i = 0; i < 10; i++ )			    	{			    		ShowWindow(hChildWndAssistantKey[i], SW_HIDE);			    		ShowWindow(hChildWndAssistantKeyTitle[i], SW_HIDE);			    	}								SetWindowText(GetDlgItem(hWnd, duplex_NextOk), "下一步/确定");								tag = 0;				        		}        		else //if( sel == 1) // assistant keys        		{        			        			SendDlgItemMessage(hWnd, duplex_KeyDistinguishWordEdit, EM_LIMITTEXT, 2, 0);        			SetWindowText(GetDlgItem(hWnd, duplex_KeyDistinguishWordEdit), "");				SetWindowText(GetDlgItem(hWnd, duplex_KeyDistinguishWord), "密钥组号:");        						        							ShowWindow(GetDlgItem(hWnd, duplex_MainKey01To08), SW_HIDE);				ShowWindow(GetDlgItem(hWnd, duplex_MainKey09To16), SW_HIDE);				ShowWindow(GetDlgItem(hWnd, duplex_BackOff), SW_HIDE);								for(i = 1; i < 17; i++ )					ShowWindow(hChilWndMainKey[i], SW_HIDE);								    	for(i = 0; i < 10; i++ )			    	{			    		//ShowWindow(hChildWndAssistantKey[i], SW_SHOW);			    		ShowWindow(hChildWndAssistantKeyTitle[i], SW_SHOW);					//the title text may hide some of the edit frame			    		ShowWindow(hChildWndAssistantKey[i], SW_SHOW);			    	}								SetWindowText(GetDlgItem(hWnd, duplex_NextOk), "下一组/确定");								        		}			        		//show the original parameter        		        		        	}        	break;        	case	duplex_Return:        		//return to the jiazhuqi main interface        		PostMessage(hWnd,MSG_CLOSE,0,0);        	break;        			case	duplex_BackOff:        		//return to the jiazhuqi previous interface        		        		if( tag != 0)        		{        			tag --;        			//modify the text of static frame          			switch(tag)	        		{	        			case 0:	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey01To08), "01~08");	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey09To16), "09~16");	        			break;	        				        			case 1:	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey01To08), "17~24");	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey09To16), "25~32");	        			break;	        				        			case 2:	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey01To08), "33~40");	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey09To16), "41~48");	        			break;	        				        		}	        			        		//restore temporary parameter        			MainKeyEditor_BackoffAndFeedback(hChilWndMainKey, tag, Mkey);        					        		}        		//delete previous temporary parameter, this needn't do        	break;		        	case	duplex_NextOk:        		        		if(sel ==0)        		{        			//check parameter        			//store parameter temporarily        			if( !MainKeyEditor_RestrictAndFeedback(hWnd, hChilWndMainKey, tag, Mkey))        			{        				return 0;        			}        						        			        		tag ++;	        			        		if( tag == 4)	        		{	        			tag = 0;	        			//store the fianl data	        			//first calculate checksum		        		MainKeyEditor_StoreChecksum(Mkey);		        		//second,  store in parameter files DuplexParaFile.dat  		        		if( !MainKeyEditor_StoreFinalData(Mkey))		        		{		        			MessageBox(hWnd, "参数存储失败", "提示:", 0);        					return 0;		        		}	        		}	        			        		//modify the text of static frame	        		//modify parameter and show( prepare for next edit)	        		switch(tag)	        		{	        			case 0:	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey01To08), "01~08");	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey09To16), "09~16");	        			break;	        				        			case 1:	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey01To08), "17~24");	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey09To16), "25~32");	        			break;	        				        			case 2:	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey01To08), "33~40");	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey09To16), "41~48");	        			break;	        				        			case 3:	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey01To08), "49~56");	        			SetWindowText(GetDlgItem(hWnd, duplex_MainKey09To16), "57~64");	        			break;	        		}	        		        		}        		else        		{        			//check parameter        			if( !AssistantKeyEditor_RestrictAndFeedback(hWnd, hChildWndAssistantKey))        			{        				return 0;        			}        			//store parameter temporarily 	        			        		//modify parameter and show( preare for next edit)	        		//store parameter	        		//first store in a buffer	        		AssistantKeyEditor_StoreInitialData( hWnd, hChildWndAssistantKey, Akey);	        		//second, calculate checksum	        		AssistantKeyEditor_StoreChecksum(Akey);	        		//third, store in parameter files DCU99ParaFile.dat  	        		if( !AssistantKeyEditor_StoreFinalData(Akey))	        		{	        			MessageBox(hWnd, "参数存储失败", "提示:", 0);	        			return 0;	        		}	        			        		//modify parameter and show( preare for next edit)   	        		auto_step_forward( hWnd, duplex_KeyDistinguishWordEdit, 0, 99);        		} 		   		        	break;        	        	        	default:        	break;        	        }        break;                case MSG_CLOSE:	        DestroyAllControls (hWnd);        DestroyMainWindow (hWnd);        PostQuitMessage (hWnd);        return 0;    }    return DefaultDialogProc (hWnd, message, wParam, lParam);}int MiniGUIMain (int argc, const char* argv[]){#ifdef _LITE_VERSION    SetDesktopRect(0, 0, 240, 280);#endif        duplex_DlgKeyEditor.controls = duplex_CtrlKeyEditor;        DialogBoxIndirectParam (&duplex_DlgKeyEditor, HWND_DESKTOP, duplex_MainFuncProc, 0L);    return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif

⌨️ 快捷键说明

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