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

📄 controlinput.c

📁 这是linux下 MiniGUI的一个程序
💻 C
字号:
/*
**  Create date: 2005/06/13.
**  Created by: JuncofeniteXu.
**  DuplexEditor, the M$ Windows like Para Editor on MiniGUI.** 
**
**  $those code must finish three things:
** 	first, read data from parameter files, just like the button 'read', --do it in *ReadStoreData.c ;
**	second, if the button 'save' or 'next', and so on, had been clicked, check its action area and check them ;
**	third, if the data bit not enough, such as the key0 only have 'FF', set it to '00FF',  and showback.
**  if find some lawless input, po-up some warnning, and return a fail flag,
**  else return a success flag.	
**
**  use ControlInput.h to declare the following function may be more criterial
**
**  have any problem you can send e-mail to: xujunfeng000@sohu.com
**  especially, if you want to use this in commerce, you must pay for it
**  tel:
*/

/*
**  TODO:
*/

#include <stdio.h>#include <stdlib.h>#include <string.h> 
#include <ctype.h>

#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <minigui/mgext.h>

#include "DuplexEditor.h"

void integrity_to_nbits(char temp[20], int n)
{
	int i = strlen(temp), j = n - 1;			if(i == n)
	{				return;	}
	
	for(j = n-1; i > 0; j --, i --)	//for(j = n-1; j > 0, i > 0; j --, i --)	//because max(i) = n, the judge i>0 better than j>0 	{
		temp[j] = temp[i - 1];
	}			for(i = 0; i < j + 1; i ++)
	{		temp[i] = '0';	}	
	temp[n] = '\0';
}

BOOL judge_bytes_isHEX(char temp[20])
{
	int i = 0;
	
	while( temp[i] != '\0')
	{
		if( !isxdigit(temp[i]))
		{			
			return FALSE;
		}
		i ++;
	} 
	
	// the string of keys can be NULL
		
	return TRUE;
}

BOOL AssistantKeyEditor_RestrictAndFeedback(HWND hDlg, HWND hChildWnd[10])
{
	char temp[20] = {0L};	
	int i = 0;
		
	//key team-num
	memset(temp,'\0',20);
	GetDlgItemText(hDlg, duplex_KeyDistinguishWordEdit, temp, 20);
	if( (temp[0] == '\0')  || (temp[0] < '0' || temp[0] > '9') 			|| (temp[1] != '\0' &&(temp[1] < '0' || temp[1] > '9')))	{
		MessageBox(hDlg, "密钥组号的范围:0~99", "提示:", 0);
		return FALSE;
	}
	
	//the key data 0 to 9
	for ( i = 0; i < 10; i ++)
	{
		memset(temp,'\0',20);
		GetWindowText ( hChildWnd[i], temp, 20);
		if( !judge_bytes_isHEX(temp))
		{
			MessageBox(hDlg, "密钥数据的范围:0000~FFFF", "提示:", 0);
			SetFocus(hChildWnd[i]);
			return FALSE;			
		}
		integrity_to_nbits( temp, 4);
		SetWindowText( hChildWnd[i], temp);
	}
	
	return TRUE;
}

BOOL MainKeyEditor_RestrictAndFeedback(HWND hDlg, HWND hChildWnd[17], int tag, char Mkey[265])
{
	char temp[20] = {0L};	
	int i = 0;
	int seek = 0;	
	
	if(tag == 0)
	{
		//key distinguish-word		memset(Mkey, '\0', 265);		memset(temp,'\0',20);
		GetDlgItemText(hDlg, duplex_KeyDistinguishWordEdit, temp, 20);
		if( (temp[0] == '\0') || !judge_bytes_isHEX(temp))		{
			MessageBox(hDlg, "鉴别字的范围:0000~270F", "提示:", 0);
			return FALSE;
		}		integrity_to_nbits( temp, 4);		if( atox_EXT(temp) > 9999)		{						MessageBox(hDlg, "鉴别字的范围:0000~270F", "提示:", 0);
			return FALSE;		}		SetDlgItemText(hDlg, duplex_KeyDistinguishWordEdit, temp);
		
		Mkey[0] = temp[0];
		Mkey[1] = temp[1];
		Mkey[2] = temp[2];
		Mkey[3] = temp[3];
		//printf("\n%s",  temp);	}
	
	//the key data 1 to 16, or 17 to 32, or 33 to 64,
	for ( i = 1; i < 17; i ++)
	{
		memset(temp,'\0',20);
		GetWindowText ( hChildWnd[i], temp, 20);
		if( !judge_bytes_isHEX(temp))
		{
			MessageBox(hDlg, "密钥数据的范围:0000~FFFF", "提示:", 0);
			SetFocus(hChildWnd[i]);
			return FALSE;			
		}
		integrity_to_nbits( temp, 4);
		SetWindowText( hChildWnd[i], temp);
		
		seek = i*4 + tag*64;
		// infact, it is: 4 + (i-1)*4 + tag*64
		Mkey[seek] = temp[0];
		Mkey[seek + 1] = temp[1];
		Mkey[seek + 2] = temp[2];
		Mkey[seek + 3] = temp[3];		//printf("\n%2d:%s", i, Mkey);	}
		//printf("\n%d:\n%s", tag, Mkey);	
	return TRUE;
}

void MainKeyEditor_BackoffAndFeedback(HWND hChildWnd[17], int tag, char Mkey[265])
{
	char temp[20] = {0L};	
	int i = 0;
	int seek = 0;
	
	//read the key data
	for( i = 1; i < 17; i ++)
	{
		seek = i * 4 + tag * 64;
		// infact, it is: 4 + (i-1)*4 + tag*64
		memset(temp,'\0',20);
		temp[0] = Mkey[seek];
		temp[1] = Mkey[seek + 1];
		temp[2] = Mkey[seek + 2];
		temp[3] = Mkey[seek + 3];
		SetWindowText( hChildWnd[i], temp);
	}
}

⌨️ 快捷键说明

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