Пример #1
0
bool InitAsm()
{
	if(! g_AsmFit.Read(ASMFN)) {
		CString msg;
		msg.Format("Can't load ASM model file %s.", ASMFN);
		//::MessageBox(NULL, msg, "message", MB_OK | MB_ICONWARNING);
		MessageBox1(msg);
		return false;
	}

	g_FDcascade = (CvHaarClassifierCascade*)cvLoad(FDFN, 0, 0, 0);
	if (!g_FDcascade) {
		CString msg;
		msg.Format("Can't load %s.", _T(FDFN));
		::MessageBox1(msg);
		return false;
	}

	g_FDstorage = cvCreateMemStorage(0);
	if (!g_FDstorage) {
		::MessageBox1("Can't create memory storage for face detection.");
		return false;
	}
	return true;
}
Пример #2
0
static void SaveModemSetting(HWND hWnd)
{
	int n;
	char string[MAX_NUM_LEN];
	char ipaddr[4][4];

	gOptions.ModemEnable = SendMessage(ModemWnd[0], CB_GETCURSEL, 0, 0);

	if (module_type != MODEM_MODULE_EM660) {
		memset(string, 0, sizeof(string));
		GetWindowText(ModemWnd[1], string, sizeof(string));
		SaveStr("APN", string, 1);
	}

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[2], string, sizeof(string));
	SaveStr("ModemDialNumber", string, 1);

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[3], string, sizeof(string));
	SaveStr("ModemUserName", string, 1);

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[4], string, sizeof(string));
	SaveStr("ModemPassword", string, 1);

	GetWindowText(ModemWnd[5], ipaddr[0], sizeof(ipaddr[0]));
	GetWindowText(ModemWnd[6], ipaddr[1], sizeof(ipaddr[1]));
	GetWindowText(ModemWnd[7], ipaddr[2], sizeof(ipaddr[2]));
	GetWindowText(ModemWnd[8], ipaddr[3], sizeof(ipaddr[3]));

	if (CheckIP(ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3], 1) 
		|| ((strcmp(ipaddr[0], "0")==0) && (strcmp(ipaddr[1], "0")==0) &&(strcmp(ipaddr[2], "0")==0) && (strcmp(ipaddr[3], "0")==0))) {
		n = sprintf(string, "%d.%d.%d.%d", atoi(ipaddr[0]), atoi(ipaddr[1]), atoi(ipaddr[2]), atoi(ipaddr[3]));
		string[n] = '\0';
		SaveStr("HeartBeatServer", string, 1);
	}

	SaveOptions(&gOptions);

        reload_modem_configuration();
        modem_reconnect();
        if (gOptions.ModemEnable == 0) {
                modem_thread_exit();
        } else {
                modem_thread_init();
        }
	
	MessageBox1 (hWnd ,LoadStrByID(HID_RESTART) ,LoadStrByID(HIT_RUN),MB_OK | MB_ICONINFORMATION);
}
Пример #3
0
static int SaveNewWiFiSetting(HWND hWnd)
{
	char tmpstring[128];
	//int idx=0;

	memset(tmpstring, 0, sizeof(tmpstring));
	GetWindowText(WifiWnd[0], tmpstring, sizeof(tmpstring));
	if(tmpstring && strlen(tmpstring)>0){
		SaveStr("SSID", tmpstring, 1);
	} else {
		MessageBox1(hWnd, LoadStrByID(MID_WIFI_ERR1), LoadStrByID(HIT_RUN), MB_OK | MB_ICONSTOP);
		curFocusWnd = 0;
		SetFocusChild(WifiWnd[curFocusWnd]);	
		return 0;
	}

	//wifipasswd
	memset(tmpstring, 0, sizeof(tmpstring));
	GetWindowText(WifiWnd[1], tmpstring, sizeof(tmpstring));
	if (tmpstring[0]) {
		SaveStr("wifipasswd", tmpstring, 1);
		printf("wifi passwd:%s\n", tmpstring);
	}

	//ip assign mode: dhcp or fix
	if (wifidhcpflag != gOptions.wifidhcpfunon) {
		gOptions.wifidhcpfunon = wifidhcpflag;
		SaveInteger("wifidhcp", wifidhcpflag);
	}

	SaveStr("wifiip", (char*)newip[0], 1);
	SaveStr("wifimask", (char*)newip[1], 1);
	SaveStr("wifigateway", (char*)newip[2], 1);

	wireless_load_configuration();
	wireless_request_reconnect();
	return 1;
}
Пример #4
0
static int NewWiFiWinProc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int id,nc;
	static char keyupFlag=0;

	switch (message)
	{
		case MSG_CREATE:
			wifidhcpflag = gOptions.wifidhcpfunon;
			InitWifiWindow(hWnd);		//add controls
			InitParameters();

			curFocusWnd =0;
			SetFocusChild(WifiWnd[curFocusWnd]);
			UpdateWindow(hWnd,TRUE);
			break;

		case MSG_ERASEBKGND:
			{
				HDC hdc = (HDC)wParam;
				const RECT* clip = (const RECT*)lParam;
				BOOL fGetDC = FALSE;
				RECT rcTemp;
				if(hdc == 0) {
					hdc = GetClientDC(hWnd);
					fGetDC = TRUE;
				}

				if(clip) {
					rcTemp = *clip;
					ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
					ScreenToClient(hWnd,&rcTemp.right, &rcTemp.bottom);
					IncludeClipRect(hdc, &rcTemp);
				}

				FillBoxWithBitmap (hdc, 0, 0, gOptions.LCDWidth, 0, &wifibkg);
				if(fGetDC) {
					ReleaseDC (hdc);
				}
				return 0;
			}

		case MSG_PAINT:
			hdc=BeginPaint(hWnd);	
			EndPaint(hWnd,hdc);
			return 0;

		case MSG_KEYUP:
			if(3 == gOptions.TFTKeyLayout){
				keyupFlag=1;
			}
			break;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
			if (3 == gOptions.TFTKeyLayout) {
				if (1==keyupFlag) {
					keyupFlag=0;
				} else {
					break;
				}
			}
			if (gOptions.KeyPadBeep){
				ExKeyBeep();
			}

			if ((LOWORD(wParam)==SCANCODE_ESCAPE)){
				PostMessage(hWnd, MSG_COMMAND, WIFI_EXIT, 0);
			} else 	if (LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN) {
				char tmpssid[128];
				if (curFocusWnd==0) {
					GetWindowText(WifiWnd[0], tmpssid, sizeof(tmpssid));
					if(tmpssid && strlen(tmpssid)>0) {
						if(hIMEWnd!=HWND_INVALID){
							SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
							hIMEWnd=HWND_INVALID;
						}
						curFocusWnd++;
					}
				} else if (curFocusWnd==1) {
					if(hIMEWnd!=HWND_INVALID){
						SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
						hIMEWnd=HWND_INVALID;
					}
					curFocusWnd++;
				} else if(++curFocusWnd>16) {
					curFocusWnd=0;
				}

				if (wifidhcpflag == 1 && curFocusWnd == 3) {
					curFocusWnd=15;
				}
				if (curFocusWnd == 4 || curFocusWnd == 5 ||curFocusWnd == 6 ){
					curFocusWnd = 7;
				}
				if (curFocusWnd == 8 || curFocusWnd == 9 || curFocusWnd == 10){
					curFocusWnd = 11;
				}
				if (curFocusWnd == 12 || curFocusWnd == 13 || curFocusWnd == 14){
					curFocusWnd = 15;
				}
				SetFocusChild(WifiWnd[curFocusWnd]);		
				return 0;
			} else if (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP){
				char tmpssid[128];
				if(curFocusWnd==0){
					GetWindowText(WifiWnd[0], tmpssid, sizeof(tmpssid));
					if(tmpssid && strlen(tmpssid)>0){
						if(hIMEWnd!=HWND_INVALID){
							SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
							hIMEWnd=HWND_INVALID;
						}
						curFocusWnd--;
					}
				} else if (curFocusWnd==1) {
					if(hIMEWnd!=HWND_INVALID){
						SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
						hIMEWnd=HWND_INVALID;
					}
					curFocusWnd--;
				
				} else if(--curFocusWnd<0){
					curFocusWnd=16;
				}

				if (wifidhcpflag == 1 && curFocusWnd == 14) {
					curFocusWnd= 2;
				}

				if (curFocusWnd == 10|| curFocusWnd == 11|| curFocusWnd == 12 ||curFocusWnd == 13 ){
					curFocusWnd = 7;
				} else if (curFocusWnd == 6|| curFocusWnd == 7|| curFocusWnd == 8 || curFocusWnd == 9){
					curFocusWnd = 3;
				} else if (curFocusWnd == 3 || curFocusWnd == 4 || curFocusWnd == 5){
					curFocusWnd = 2;
				} else if(curFocusWnd == 14){
					curFocusWnd = 11;
				}

				SetFocusChild(WifiWnd[curFocusWnd]);
				return 0;

			} else if(LOWORD(wParam)==SCANCODE_F9 || 
					((gOptions.TFTKeyLayout==0 || gOptions.TFTKeyLayout==4) && (LOWORD(wParam)==SCANCODE_F11))) {
				if((curFocusWnd==0 || curFocusWnd==1) && (gOptions.IMEFunOn==1 && gOptions.TFTKeyLayout!=3))
				{
					T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight,gOptions.HzImeOn);
				}
			} else if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT) || (LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
				|| ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE)) {

				if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT) && gOptions.IMEFunOn==1 
						&& gOptions.TFTKeyLayout==3 && (curFocusWnd==0 || curFocusWnd==1)) {
					T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);
					return 0;
				}

				if(curFocusWnd==2 && ((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT || ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE))
					||LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)) {

					int tmpsel = SendMessage(WifiWnd[curFocusWnd], CB_GETCURSEL, 0, 0);		
					if (tmpsel == 0) {
						SendMessage(WifiWnd[curFocusWnd], CB_SETCURSEL, 1, 0);
						dhcpswitch(1);
						UpdateWindow(hWnd,TRUE);
						wifidhcpflag =1;
					} else {
						SendMessage(WifiWnd[curFocusWnd], CB_SETCURSEL, 0, 0);
						dhcpswitch(0);
						UpdateWindow(hWnd,TRUE);
						wifidhcpflag = 0;
					}
				}
				if (curFocusWnd >2 && curFocusWnd<15 && wifidhcpflag ==0) {
					if (LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT ){
						curFocusWnd --;
						if (curFocusWnd == 2){
							curFocusWnd =14;
						}
					}else if (LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT){
						curFocusWnd ++;
						if (curFocusWnd ==15){
							curFocusWnd = 3;
						}
					}
					SetFocusChild(WifiWnd[curFocusWnd]);
				}
				return 0;	
			} else if ((LOWORD(wParam)==SCANCODE_ENTER) || (LOWORD(wParam)==SCANCODE_F10)) {
				char tmpssid[128];
				switch(curFocusWnd)
				{
					case 0:
						GetWindowText(WifiWnd[0], tmpssid, sizeof(tmpssid));
						if(tmpssid && strlen(tmpssid)>0)
							SendMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
						else
							MessageBox1(hWnd ,LoadStrByID(HIT_ERROR0) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
						break;
					case 16:		//exit
						SendMessage(hWnd, MSG_COMMAND, WIFI_EXIT, 0);
						break;
					default:
						SendMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
				}
				return 0;
			} else if(LOWORD(wParam)==SCANCODE_MENU) {
				SendMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
				return 0;
			}
			break;

		case MSG_COMMAND:
			id = LOWORD(wParam);
			nc = HIWORD(wParam);
			if(id==WIFI_SAVE) {
				if(isModified() && SaveNewWiFiSetting(hWnd)) {
					MessageBox1(hWnd ,LoadStrByID(HIT_RIGHT) ,LoadStrByID(HIT_RUN),MB_OK| MB_ICONINFORMATION);
					if(!ismenutimeout) {
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					}
				} else if(!ismenutimeout) {
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
			} else if (id==WIFI_EXIT) {
				if(isModified() && MessageBox1(hWnd,LoadStrByID(MID_SAVEDATA),LoadStrByID(MID_APPNAME),
					MB_OKCANCEL|MB_ICONQUESTION|MB_BASEDONPARENT)==IDOK) {
					PostMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
				} else if(!ismenutimeout) {
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
			}
			break;

		case MSG_CLOSE:
			if(hIMEWnd!=HWND_INVALID){
				SendMessage(hIMEWnd,MSG_CLOSE,0,0);
				hIMEWnd=HWND_INVALID;
			}

			UnloadBitmap(&wifibkg);
			//MainWindowCleanup(hWnd);
			DestroyMainWindow(hWnd);
			return 0;

	}
	return DefaultMainWinProc(hWnd,message,wParam,lParam);
}
Пример #5
0
static int get_new_ip(void)
{
	char str[3][50];
	char cc[3][16];
	int err=0;
	int i;
	if(wifidhcpflag) {
		return 1;
	}
	for(i=0;i<4;i++){
		GetWindowText(WifiWnd[3+i],cc[i],16);
	}
	if(CheckIP(cc[0],cc[1],cc[2],cc[3],1)) {
		sprintf(str[0],"%s.%s.%s.%s",cc[0],cc[1],cc[2],cc[3]);
	} else {
		err=1;
	}

	for(i=0;i<4;i++) {
		GetWindowText(WifiWnd[7+i],cc[i],16);
	}
	if(CheckIP(cc[0],cc[1],cc[2],cc[3],0)) {
		sprintf(str[1],"%s.%s.%s.%s",cc[0],cc[1],cc[2],cc[3]);
	} else {
		err=2;
	}

	for(i=0;i<4;i++) {
		GetWindowText(WifiWnd[11+i],cc[i],16);
	}
	if(CheckIP(cc[0],cc[1],cc[2],cc[3],0)) {
		sprintf(str[2],"%s.%s.%s.%s",cc[0],cc[1],cc[2],cc[3]);
	} else {
		err=3;
	}

	if(err) {
		switch(err)
		{
			case 1:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_NETERROR1) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
				break;
			case 2:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_NETERROR2) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
                                break;
			case 3:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_NETERROR3) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
                                break;
			default:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_ERROR0) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
                                break;
		}
		return 0;
	} else {
		memset(newip, 0, 54);
		sprintf(newip[0],"%s",str[0]);
		sprintf(newip[1],"%s",str[1]);
		sprintf(newip[2],"%s",str[2]);
	}
	return 1;
}
Пример #6
0
static int ModemWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;

	switch (message){
		case MSG_CREATE:
			InitModemWin(hWnd);
			ModemCurWnd = 0;
			SetFocusChild(ModemWnd[ModemCurWnd]);
			UpdateWindow(hWnd, TRUE);
			break;

		case MSG_ERASEBKGND:
			{
				HDC hdc = (HDC)wParam;
				const RECT* clip = (const RECT*)lParam;
				BOOL fGetDC = FALSE;
				RECT rcTemp;
				if(hdc == 0){
					hdc = GetClientDC(hWnd);
					fGetDC = TRUE;
				}

				if(clip){
					rcTemp = *clip;
					ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
					ScreenToClient(hWnd, &rcTemp.right, &rcTemp.bottom);
					IncludeClipRect(hdc, &rcTemp);
				}

				FillBoxWithBitmap (hdc, 0, 0, gOptions.LCDWidth, gOptions.LCDHeight, &ModemBkg);
				if(fGetDC){
					ReleaseDC(hdc);
				}

				return 0;
			}

		case MSG_PAINT:
			hdc = BeginPaint(hWnd);
			EndPaint(hWnd, hdc);
			return 0;

		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
			if(gOptions.KeyPadBeep)
				ExKeyBeep();

			if (LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN){
				if (ModemCurWnd == 11) {
					ModemCurWnd = 0;
				} else if (ModemCurWnd == 0 && module_type == MODEM_MODULE_EM660) {
					ModemCurWnd += 2;
				} else if (4 < ModemCurWnd && ModemCurWnd < 9) {
					ModemCurWnd = 9;
				} else {
					ModemCurWnd++;
				}
				SetFocusChild(ModemWnd[ModemCurWnd]);
				return 0;
			}

			if (LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT || LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT ||
					(gOptions.TFTKeyLayout == 3 && LOWORD(wParam)  == SCANCODE_BACKSPACE)){
				if (ModemCurWnd == 0){
					if (SendMessage(ModemWnd[ModemCurWnd], CB_GETCURSEL, 0, 0)==0)
						SendMessage(ModemWnd[ModemCurWnd], CB_SETCURSEL, 1, 0);
					else
						SendMessage(ModemWnd[ModemCurWnd], CB_SETCURSEL, 0, 0);
					return 0;
				}

				if (4 < ModemCurWnd && ModemCurWnd < 8 && LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT){
					ModemCurWnd += 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
				}

				if (5 < ModemCurWnd && ModemCurWnd < 9 && LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT){
					ModemCurWnd -= 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
				}

				if ((ModemCurWnd == 9 || ModemCurWnd == 10) && LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT){
					ModemCurWnd += 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}

				if ((ModemCurWnd == 10 || ModemCurWnd == 11) && LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT){
					ModemCurWnd -= 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}
				if (ModemCurWnd == 9 && LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT){
					ModemCurWnd = 11;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}
				if (ModemCurWnd == 11 && LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT){
					ModemCurWnd = 9;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}
			}

			if (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP){
				if (ModemCurWnd == 0) {
					ModemCurWnd = 11;
				} else if (ModemCurWnd == 2 && module_type == MODEM_MODULE_EM660) {
					ModemCurWnd -= 2;
				} else if(ModemCurWnd == 9) {
					ModemCurWnd = 5;
				} else if (4 < ModemCurWnd && ModemCurWnd < 9) {
					ModemCurWnd = 4;
				} else {
					ModemCurWnd--;
				}
				SetFocusChild(ModemWnd[ModemCurWnd]);
				return 0;
			}


			if (LOWORD(wParam)==SCANCODE_F9 || ((gOptions.TFTKeyLayout == 0 || 
							gOptions.TFTKeyLayout == 4) && (LOWORD(wParam) == SCANCODE_F11))) {
				if ((ModemCurWnd > 1 && ModemCurWnd < 5) || (module_type != MODEM_MODULE_EM660 && ModemCurWnd == 1)) {
					T9IMEWindow(hWnd, 0, 200,gOptions.LCDWidth, gOptions.LCDHeight, 0);
				}
				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_F8){
				CreateModemInfoWindow(hWnd);
				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_ENTER){
				if (ModemCurWnd == 9){
					PostMessage(hWnd, MSG_COMMAND, IDOK, 0);
				}

				if (ModemCurWnd == 10){
					PostMessage(hWnd, MSG_COMMAND, IDCANCEL, 0);
				}

				if (ModemCurWnd == 11){
					CreateModemInfoWindow(hWnd);
				}

				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_ESCAPE){
				PostMessage(hWnd, MSG_COMMAND, IDCANCEL, 0);
			}

			if (LOWORD(wParam)==SCANCODE_MENU){
				PostMessage(hWnd, MSG_COMMAND, IDOK, 0);
				return 0;
			}

			break;

		case MSG_COMMAND:
			switch(LOWORD(wParam)){
				case IDOK:
					if(isModemSettingChanged()){
						if(!ismenutimeout){
							SaveModemSetting(hWnd);
							PostMessage(hWnd, MSG_CLOSE, 0, 0);
						}
					}else{
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					}
					break;

				case IDCANCEL:
					if(isModemSettingChanged()){
						if(MessageBox1(hWnd, LoadStrByID(MID_SAVEDATA), LoadStrByID(MID_APPNAME),MB_OKCANCEL | MB_ICONQUESTION | MB_BASEDONPARENT) == IDOK)
						{
							if(!ismenutimeout){
								SaveModemSetting(hWnd);
								PostMessage(hWnd, MSG_CLOSE, 0, 0);
							}
						}
						else
						{
							if(!ismenutimeout)
								PostMessage(hWnd, MSG_CLOSE, 0, 0);
						}
					}else{
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					}
					break;

			}
			break;

		case MSG_CLOSE:
			UnloadBitmap(&ModemBkg);
			//MainWindowCleanup(hWnd);
			DestroyMainWindow(hWnd);
			return 0;
	}

	return DefaultMainWinProc(hWnd, message, wParam, lParam);

}
Пример #7
0
static int  ProcessDeluser(U16 pin, HWND hWnd, int delupass)
{
	int fpcheck=0, pwdcheck=0, basecheck=0;
	int hidcheck=0;		//liming
	int photocheck=0;

	char delhintbuff[100];
	int delcount=0;
	TUser duser;

	delret=0;
	memset(delhintbuff,0,100);

	//delall
	if (delupass==0)
	{
		sprintf(delhintbuff,"%s?",LoadStrByID(MID_USEBASE));
		basecheck=1;
	}

	//delfp
	if (delupass==1)
	{
		sprintf(delhintbuff,"%s?",LoadStrByID(HID_DEL_FP));
		fpcheck=1;
	}

	//delpwd
	if (delupass==2)
	{
		sprintf(delhintbuff,"%s?",LoadStrByID(HID_DEL_PWD));
		pwdcheck=1;
	}

	//delhid
	if (delupass==3)
	{
		sprintf(delhintbuff,"%s?",LoadStrByID(MID_DEL_CARD));
		hidcheck=1;
	}

	//delphoto
	if (delupass==4)
	{
		sprintf(delhintbuff,"%s?", LoadStrByID(MID_QUERY_SET1));
		photocheck=1;
	}

	//For face
#ifdef FACE
	int facecheck=0;
	if (delupass==5)
	{
		sprintf(delhintbuff,"%s%s?", LoadStrByID(MID_REMOVEHINT), LoadStrByID(MID_DEL_FACE));
		facecheck=1;
	}
#endif
	//end face

	if (MessageBox1 (hWnd,delhintbuff, LoadStrByID(MID_APPNAME), MB_OKCANCEL | MB_ICONQUESTION | MB_BASEDONPARENT) != IDOK)
	{
		delret=0;
		return 0;
	}

	//提示清除管理员权限
	memset(&duser, 0, sizeof(TUser));
	FDB_GetUser(pin, &duser);
	if(delupass>0 && ((nopwd && nofp)||(nopwd && nohid)||(nofp && nohid)) && duser.Privilege==(BYTE)PRIVILLEGE3)
	{
		if(MessageBox1(hWnd,LoadStrByID(MID_ADUSER_HINT),LoadStrByID(MID_APPNAME),MB_OKCANCEL|MB_ICONINFORMATION|MB_BASEDONPARENT)==IDOK)
		{
			int j=0;
			duser.Privilege=0;
			j=FDB_ChgUser(&duser);
			FDB_AddOPLog(ADMINPIN, OP_CLEAR_ADMIN,duser.PIN,j,0,0);
		}
		else
			return 0;
	}
	//
	//delete photo
	if (photocheck)
	{
		HWND statushWnd;

		statushWnd=createStatusWin1(hWnd, 250, 50, LoadStrByID(MID_APPNAME), LoadStrByID(MID_PHOTO_HINT1));
		busyflag = 1;
		ProcDeleteUserPhoto();
		FDB_AddOPLog(ADMINPIN, OP_DEL_ATTPHOTO,ADMINPIN,0,0,0);
		destroyStatusWin1(statushWnd);
		nophoto=1;
		delret=5;
		InvalidateRect(hWnd,NULL,TRUE);
		SendMessage(btndelphoto, MSG_ENABLE, 0, 0);
		photodelhint=1;
		SetMenuTimeOut(time(NULL));
		SetFocusChild(btnexit2);
	}

	//delete hid
	if (hidcheck)
	{
		TUser uh;
		memset(&uh,0,sizeof(TUser));
		if(FDB_GetUser(pin,&uh)!=NULL)
		{
			int j;
			memset(uh.Card,0,4);
			j=FDB_ChgUser(&uh);
			FDB_AddOPLog(ADMINPIN, OP_DEL_RFCARD,uh.PIN,j,0,0);
			delret=4;		//
			hiddelhint=1;
			InvalidateRect(hWnd,NULL,TRUE);
			SendMessage(btndelhid,MSG_ENABLE,0,0);
			nohid=1;
			SetFocusChild(btnexit2);
		}
	}

	//delete fp
	if (fpcheck)
	{	//dellfp
		int j=FDB_DeleteTmps(pin);
		FDB_AddOPLog(ADMINPIN, OP_DEL_FP,pin,j,0,0);
		delcount++;
		SendMessage(btndelfp,MSG_ENABLE,0,0);
		delret=2;
		fpdelhint=1;
		InvalidateRect(hWnd,NULL,TRUE);
		SendMessage(btndelfp,MSG_ENABLE,0,0);
		nofp=1;
		SetFocusChild(btnexit2);
	}

	if (pwdcheck)
	{
		TUser u1;
		int j;

		memset(&u1,0,sizeof(u1));
		FDB_GetUser(pin,&u1);
		nmemset((BYTE*)u1.Password, 0, sizeof(u1.Password));
		j=FDB_ChgUser(&u1);
		FDB_AddOPLog(ADMINPIN, OP_DEL_PWD,u1.PIN,j,0,0);
		delret=3;
		pwddelhint=1;
		InvalidateRect(hWnd,NULL,TRUE);
		SendMessage(btndelpwd,MSG_ENABLE,0,0);
		nopwd=1;
		SetFocusChild(btnexit2);

	}

	if (basecheck)
	{
		int j = FDB_DelUser(pin);
		FDB_AddOPLog(ADMINPIN, OP_DEL_USER,pin,j,0,0);
		if(FDB_OK==j)
		{
			if(gOptions.IsSupportSMS)
			{
				TUData tudt;
				U16 smsID;
				TSms tsms;

				if(FDB_GetUData(pin,&tudt)!=NULL)
				{
					smsID=tudt.SmsID;
					FDB_DelUData(pin,0);
					memset(&tudt,0,sizeof(TUData));
					if(FDB_GetUDataBySmsID(smsID,(PUData)&tudt)==0)
					{
						memset(&tsms,0,sizeof(TSms));
						if(FDB_GetSms(smsID,&tsms)!=NULL)
						{
							tsms.Tag=UDATA_TAG_TEMP;
							FDB_ChgSms(&tsms);
						}
					}
				}
			}

			if(gOptions.UserExtendFormat)
				FDB_DelExtUser(pin);

			if (gOptions.CameraOpen && !nophoto)
			{
				busyflag = 1;
				ProcDeleteUserPhoto();
				SetMenuTimeOut(time(NULL));
			}
			delcount++;
		}
		delret=1;
	}

#ifdef FACE
	if (facecheck)
	{
		FDB_DeleteFaceTmps(pin);
		delcount++;
		delret=6;
		facedelhint=1;
		InvalidateRect(hWnd,NULL,TRUE);
		SendMessage(btndelface,MSG_ENABLE,0,0);
		noface=1;
		SetFocusChild(btnexit2);
	}
#endif
	if (delcount>0)
	{
		sync();
		FPDBInit();
	}

	if (basecheck)
	{
		SendMessage(hWnd,MSG_CLOSE,0,0);
	}
	return 1;
}
Пример #8
0
static int WiFiPWDWinProc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int nc, id;
	static char keyupFlag=0;
	switch (message)
	{
		case MSG_CREATE:
			InitWindow(hWnd);		//add controls
			InitPWDSetting();
			UpdateWindow(hWnd,TRUE);
			curCtlidx=0;
			SetFocusChild(WifiPWDWnd[curCtlidx]);
			break;

		case MSG_ERASEBKGND:
		{
	            	HDC hdc = (HDC)wParam;
			const RECT* clip = (const RECT*)lParam;
			BOOL fGetDC = FALSE;
			RECT rcTemp;
			if(hdc == 0)
			{
				hdc = GetClientDC(hWnd);
				fGetDC = TRUE;
			}

			if(clip)
			{
				rcTemp = *clip;
				ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
				ScreenToClient(hWnd,&rcTemp.right, &rcTemp.bottom);
				IncludeClipRect(hdc, &rcTemp);
			}

			FillBoxWithBitmap (hdc, 0, 0, gOptions.LCDWidth, 0, get_submenubg_jgp());
			if(fGetDC) ReleaseDC (hdc);
			return 0;
		}

		case MSG_PAINT:
			hdc=BeginPaint(hWnd);	
			EndPaint(hWnd,hdc);
			return 0;

		case MSG_KEYUP:
			if(3 == gOptions.TFTKeyLayout)
			{
				keyupFlag=1;
			}
			break;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
			if(3 == gOptions.TFTKeyLayout)
			{
				if(1==keyupFlag)
					keyupFlag=0;
				else
					break;
			}
			if (gOptions.KeyPadBeep)
				ExKeyBeep();

			if ((LOWORD(wParam)==SCANCODE_ESCAPE))
			{
				PostMessage(hWnd, MSG_COMMAND, WIFI_PWDEXIT, 0);
			}
			else if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN) || (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP))
			{
                                if(hIMEWnd!=HWND_INVALID)
                                {
                                        SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
                                        hIMEWnd=HWND_INVALID;
                                }

				SelectNext(wParam);
				return 0;
			}
			else if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT) || (LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
				|| ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE))
			{
				if(pwdmode==0)
				{
					if(curCtlidx==0 || curCtlidx==1)
					{
						int curidx = SendMessage(WifiPWDWnd[curCtlidx], CB_GETCURSEL, 0, 0);
						if(LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT  || ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE))
						{
							if(--curidx<0) curidx=3;
						}
						else if(LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
						{
							if(++curidx>3) curidx=0;
						}
						SendMessage(WifiPWDWnd[curCtlidx], CB_SETCURSEL, curidx, 0);
						
						if(curCtlidx==0)
						{
							curpwdidx=curidx;
							RefreshPWDWindow(curpwdidx);
						}
						else
						{
							tmppwdmode[curpwdidx]=curidx;
//							SetWindowText(WifiPWDWnd[2+curpwdidx],"");
							SendMessage(WifiPWDWnd[2+curpwdidx], EM_LIMITTEXT, lenValue[curidx], 0L);
						}
						return 0;
					}
					 else if((LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT) &&(curCtlidx>=2 && curCtlidx<=5)&&
					    gOptions.IMEFunOn==1&&gOptions.TFTKeyLayout==3)
					{
                        T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);	//不支持中文输入
						return 0;
					}
					else if(curCtlidx>=6 && curCtlidx<=7)
					{
						if(curCtlidx==6) curCtlidx=7;
						else curCtlidx=6;
						SetFocusChild(WifiPWDWnd[curCtlidx]);
						return 0;
					}
				}
				else
				{
					if(curCtlidx>=1 && curCtlidx<=2)
					{
						if(curCtlidx==1) curCtlidx=2;
						else curCtlidx=1;
						SetFocusChild(WifiPWDWnd[curCtlidx]);
						return 0;
					}
					else if((LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT) && curCtlidx==0 &&
					    gOptions.IMEFunOn==1 && gOptions.TFTKeyLayout==3)
					{
                        T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);	//不支持中文输入
					}
				}
			}
			else if(LOWORD(wParam)==SCANCODE_ENTER) 
			{
				if((pwdmode==0 && curCtlidx<6) || (pwdmode==1 && curCtlidx<1))
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0L);
			}
			else if(LOWORD(wParam)==SCANCODE_F10)
			{
				if((pwdmode==0 && curCtlidx==7)||(pwdmode==1 && curCtlidx==2))
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDEXIT, 0L);
				else
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0L);
			}
			else if(LOWORD(wParam)==SCANCODE_MENU)
			{
				PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0);
			}
//			else if (LOWORD(wParam) == gOptions.IMESwitchKey)
			else if((LOWORD(wParam)==SCANCODE_F9) || 
				(LOWORD(wParam)==SCANCODE_F11 && (gOptions.TFTKeyLayout==0 || gOptions.TFTKeyLayout==4)))
                        {
                                if(((pwdmode==0 && curCtlidx>=2 && curCtlidx<=5) || (pwdmode==1 && curCtlidx==0)) && gOptions.IMEFunOn==1)
                                        T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);	//不支持中文输入
                                break;
                        }
			break;
//Liaozz 20080928 fix bug second 43
		case MSG_CHAR:
		{
			char schar[255];
			int slen;
//			printf("*************char=======l:%d,,,w:%d===\n",lParam, wParam);
			HWND Edtmp = GetFocusChild(hWnd);
			if(pwdmode==0)
			{
				curpwdidx=SendMessage(WifiPWDWnd[0], CB_GETCURSEL, 0, 0);			//password index
				tmppwdmode[curpwdidx]=SendMessage(WifiPWDWnd[1], CB_GETCURSEL, 0, 0);		//password type
				GetWindowText(WifiPWDWnd[2+curpwdidx], schar, 255);				//password string
				slen=strlen(schar);
				//13:Enter; 27:ESC; 127:Backspace
				if(slen==lenValue[tmppwdmode[curpwdidx]] && Edtmp == WifiPWDWnd[2+curpwdidx]
				         && wParam != 127 && wParam != 27 && wParam != 13) {
						ExBeep(1);
					}
			} else {//Liaozz 20081009 fix bug second 43
				 GetWindowText(WifiPWDWnd[0], schar, 255);
					int slen = strlen(schar);
					if (slen == 64 && Edtmp == WifiPWDWnd[0]
					               && wParam != 127 && wParam != 27 && wParam != 13)
						ExBeep(1);
			}
			break;
		}
		//Liaozz end
		case MSG_COMMAND:
			id = LOWORD(wParam);
			nc = HIWORD(wParam);
			if(id==WIFI_PWDSAVE)
			{
				if(beModified())
				{
					if(SaveWifiPWDSetting(hWnd) && !ismenutimeout)
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
				else
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
					
			}
			else if(id==WIFI_PWDEXIT)
			{
				if(beModified() && MessageBox1(hWnd,LoadStrByID(MID_SAVEDATA),LoadStrByID(MID_APPNAME),
									MB_OKCANCEL|MB_ICONQUESTION|MB_BASEDONPARENT)==IDOK)
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0);
				else
				{
					if(!ismenutimeout) PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
			}
			break;

		case MSG_CLOSE:
			//UnloadBitmap(&wifipwdbkg);
			//MainWindowCleanup(hWnd);
			DestroyMainWindow(hWnd);
			return 0;

	}
	return DefaultMainWinProc(hWnd,message,wParam,lParam);

}
Пример #9
0
static int SaveWifiPWDSetting(HWND hWnd)
{
        int i;
        char schar[255];
	int noerr=1;
	int slen;

        if(pwdmode==0)
        {
		curpwdidx=SendMessage(WifiPWDWnd[0], CB_GETCURSEL, 0, 0);			//password index
		tmppwdmode[curpwdidx]=SendMessage(WifiPWDWnd[1], CB_GETCURSEL, 0, 0);		//password type
		GetWindowText(WifiPWDWnd[2+curpwdidx], schar, 255);				//password string
		if(ispwdstrerr(schar, tmppwdmode[curpwdidx]))		//字符类型不正确
		{
			MessageBox1(hWnd, LoadStrByID(MID_WIFI_ERR3), LoadStrByID(HIT_RUN), MB_OK | MB_ICONSTOP);
	                if(!ismenutimeout) SetFocusChild(WifiPWDWnd[2+curpwdidx]);
			return 0;
		}

		slen=strlen(schar);
		if(slen==lenValue[tmppwdmode[curpwdidx]])
		{
			memset(newpwdid, 0, 2);
			sprintf(newpwdid, "%d", curpwdidx+1);
			
			for(i=0;i<4;i++)	//清除原密码(08.01.10)
			{
				memset(&(newpwd[i]), 0, sizeof(WifiPWD));
			}
//			memset(newpwd[curpwdidx].pwdchar, 0, 30);
			memcpy(newpwd[curpwdidx].pwdchar, schar, slen);

			sprintf((char*)newpwd[curpwdidx].pwdtype, "%d", getPasswordMode(tmppwdmode[curpwdidx]));
		}
		else
			noerr=0;
        }
        else
        {
                GetWindowText(WifiPWDWnd[0], schar, 255);
		int slen = strlen(schar);
		if(slen>=8 && slen<=64)
		{
			memset(newwpapsk, 0, 255);
			memcpy(newwpapsk, schar, slen);
		}
		else
			noerr=0;
        }

	if(!noerr)
	{
		MessageBox1(hWnd, LoadStrByID(MID_WIFI_ERR2), LoadStrByID(HIT_RUN), MB_OK | MB_ICONSTOP);
		if(!ismenutimeout)
		{
			if(pwdmode==0)
				SetFocusChild(WifiPWDWnd[2+curpwdidx]);
			else
				SetFocusChild(WifiPWDWnd[0]);
		}
	}
	else
	{
		MessageBox1(hWnd ,LoadStrByID(HIT_RIGHT) ,LoadStrByID(HIT_RUN),MB_OK| MB_ICONINFORMATION);
	}

	return (noerr);
}
Пример #10
0
static int duressparawinproc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    int id,nc;
    char sstr[10];
    int tmpvalue;
    static char keyupFlag=0;
    switch (message)
    {
    case MSG_CREATE:
        //if (LoadBitmap(HDC_SCREEN,&gpmngbk1,GetBmpPath("submenubg.jpg")))
        //        return 0;

        InitWindow(hWnd);		//add controls
        InitWindowText(hWnd);
        UpdateWindow(hWnd,TRUE);
        actindex=0;
        SetFocusChild(EdDAM[actindex]);
        break;

    case MSG_ERASEBKGND:
    {
        HDC hdc = (HDC)wParam;
        const RECT* clip = (const RECT*)lParam;
        BOOL fGetDC = FALSE;
        RECT rcTemp;
        if(hdc == 0)
        {
            hdc = GetClientDC(hWnd);
            fGetDC = TRUE;
        }

        if(clip)
        {
            rcTemp = *clip;
            ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
            ScreenToClient(hWnd,&rcTemp.right, &rcTemp.bottom);
            IncludeClipRect(hdc, &rcTemp);
        }

        FillBoxWithBitmap (hdc, 0, 0, gOptions.LCDWidth, gOptions.LCDHeight, get_submenubg_jgp());
        if(fGetDC) ReleaseDC (hdc);
        return 0;
    }

    case MSG_PAINT:
        hdc=BeginPaint(hWnd);
        EndPaint(hWnd,hdc);
        return 0;

    case MSG_KEYUP:
        if(3 == gOptions.TFTKeyLayout)
        {
            keyupFlag=1;
        }
        break;
    case MSG_KEYDOWN:
        SetMenuTimeOut(time(NULL));
        if(3 == gOptions.TFTKeyLayout)
        {
            if(1==keyupFlag)
                keyupFlag=0;
            else
                break;
        }
        if (gOptions.KeyPadBeep)
            ExKeyBeep();

        if ((LOWORD(wParam)==SCANCODE_ESCAPE))
        {
            PostMessage(hWnd, MSG_COMMAND, ID_EXIT, 0L);
        }

        if(LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN)
        {
            if(actindex==4)
            {
                memset(sstr,0,10);
                GetWindowText(EdDAM[actindex],sstr,3);
                if(strlen(sstr)==0)
                    return 0;
            }
            if(++actindex > 6) actindex = 0;
            //Liaozz 20081008 fix bug third 6
            if (gOptions.IsOnlyRFMachine) {
                if (actindex == 1 || actindex == 2)
                    actindex = 3;
            }
            //Liaozz end
            SetFocusChild(EdDAM[actindex]);
            return 0;
        }

        if( LOWORD(wParam)==SCANCODE_CURSORBLOCKUP)
        {
            if(actindex==4)
            {
                memset(sstr,0,10);
                GetWindowText(EdDAM[actindex],sstr,3);
                if(strlen(sstr)==0)
                    return 0;
            }
            if(--actindex < 0) actindex = 6;
            //Liaozz 20081008 fix bug third 6
            if (gOptions.IsOnlyRFMachine) {
                if (actindex == 1 || actindex == 2)
                    actindex = 0;
            }
            //Liaozz end
            SetFocusChild(EdDAM[actindex]);
            return 0;
        }

        if(LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT || (gOptions.TFTKeyLayout == 3 && LOWORD(wParam) == SCANCODE_BACKSPACE))
        {
            if(actindex<4)
            {
                tmpvalue=SendMessage(EdDAM[actindex], CB_GETCURSEL, 0, 0);
                if(--tmpvalue < 0) tmpvalue = 1;
                SendMessage(EdDAM[actindex], CB_SETCURSEL, tmpvalue, 0);
                return 0;
            }
            else if(actindex>4)
            {
                if(--actindex < 0) actindex = 6;
                SetFocusChild(EdDAM[actindex]);
                return 0;
            }
        }

        if(LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
        {
            if(actindex<4)
            {
                tmpvalue=SendMessage(EdDAM[actindex], CB_GETCURSEL, 0, 0);
                if(++tmpvalue > 1) tmpvalue = 0;
                SendMessage(EdDAM[actindex], CB_SETCURSEL, tmpvalue, 0);
                return 0;
            }
            else if(actindex>4)
            {
                if(++actindex > 6) actindex = 0;
                SetFocusChild(EdDAM[actindex]);
                return 0;
            }
        }

        if(LOWORD(wParam)==SCANCODE_ENTER)
        {
            if(actindex<5)
                PostMessage(hWnd,MSG_COMMAND,(WPARAM)ID_SAVE,0);
        }

        if(LOWORD(wParam)==SCANCODE_F10)
        {
            if(actindex!=6)
                PostMessage(hWnd, MSG_COMMAND, (WPARAM)ID_SAVE, 0L);
            else
                PostMessage(hWnd, MSG_COMMAND, (WPARAM)ID_EXIT, 0L);
        }

        if(LOWORD(wParam)==SCANCODE_MENU)
            PostMessage (hWnd, MSG_COMMAND, (WPARAM)ID_SAVE, 0L);

        break;

    case MSG_COMMAND:
        id = LOWORD(wParam);
        nc = HIWORD(wParam);
        if(nc==EN_CHANGE)
        {
            if(id == DAM_ID+4)
            {
                memset(sstr,0,5);
                GetWindowText(EdDAM[actindex],sstr,3);
                tmpvalue = atoi(sstr);
                if(tmpvalue>255)
                {
                    SetWindowText(EdDAM[actindex],"0");
                    SendMessage(EdDAM[actindex],EM_SETCARETPOS,0,1);
                }
            }
        }

        switch(id)
        {
        case ID_SAVE:
            SaveDuressParameter(hWnd);
            LoadOptions(&gOptions);
            MessageBox1(hWnd ,LoadStrByID(HIT_RIGHT) ,LoadStrByID(HIT_RUN),MB_OK| MB_ICONINFORMATION);
            if(!ismenutimeout) PostMessage(hWnd,MSG_CLOSE,0,0);
            break;

        case ID_EXIT:
            if(ismodified() && MessageBox1(hWnd,LoadStrByID(MID_SAVEDATA), LoadStrByID(MID_APPNAME),
                                           MB_OKCANCEL | MB_ICONQUESTION | MB_BASEDONPARENT) == IDOK)
                SendMessage(hWnd, MSG_COMMAND, ID_SAVE, 0);
            if(!ismenutimeout) PostMessage(hWnd,MSG_CLOSE,0,0L);
            break;
        }

        break;

    case MSG_CLOSE:
        //UnloadBitmap(&gpmngbk1);
        //MainWindowCleanup(hWnd);
        DestroyMainWindow(hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd,message,wParam,lParam);

}
Пример #11
0
static int AttPhotoProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	static char keyupFlag=0;
	switch (message)
	{
		case MSG_CREATE:
			InitAttPhotoWindow(hWnd);
			UpdateWindow(hWnd, TRUE);
			SetFocusChild(AttPhotoItemWnd[0]);
			break;

		case MSG_PAINT:
			hdc = BeginPaint(hWnd);
			EndPaint(hWnd, hdc);
			return 0;

		case MSG_ERASEBKGND:
			{
				HDC hdc = (HDC)wParam;
				const RECT* clip = (const RECT*) lParam;
				BOOL fGetDC = FALSE;
				RECT rcTemp;

				if (hdc == 0) {
					hdc = GetClientDC(hWnd);
					fGetDC = TRUE;
				}

				if (clip) {
					rcTemp = *clip;
					ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
					ScreenToClient(hWnd, &rcTemp.right, &rcTemp.bottom);
					IncludeClipRect(hdc, &rcTemp);
				}

				FillBoxWithBitmap(hdc, 0, 0, gOptions.LCDWidth, 0, get_submenubg_jgp());

				if (fGetDC)
					ReleaseDC(hdc);
				return 0;
			}
		case MSG_KEYUP:
			{
				if(gOptions.TFTKeyLayout==3)
				{
					keyupFlag=1;
				}
			}
			break;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
			if(gOptions.TFTKeyLayout==3)
			{
				if(keyupFlag==1)
				{
					keyupFlag=0;
				}
				else
					break;
			}
			if(gOptions.KeyPadBeep)
				ExKeyBeep();

			if (LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN)
			{
				if (++AttPhotoItem>9)
				{
					AttPhotoItem = 0;
				}

				SetFocus(AttPhotoItemWnd[AttPhotoItem]);
				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP)
			{
				if (--AttPhotoItem < 0)
				{
					AttPhotoItem=9; 
				}

				SetFocus(AttPhotoItemWnd[AttPhotoItem]);
				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
			{

			}

			if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT) || (gOptions.TFTKeyLayout==3 && LOWORD(wParam)==SCANCODE_BACKSPACE))
			{
			}

			if ((LOWORD(wParam)==SCANCODE_MENU)||(LOWORD(wParam)==SCANCODE_F10))
			{
				if (isChangedPhotoOpt())
				{
					if(PhotoOptOK(hWnd, AttPhotoItemWnd, 8) && !ismenutimeout)
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					else
						return 0;
				}
				else
					PostMessage(hWnd, MSG_CLOSE, 0, 0);

				return 0;
			}

			if(LOWORD(wParam) == SCANCODE_ENTER)
			{
				if(AttPhotoItem == 9)
				{
					PostMessage(hWnd, MSG_COMMAND, IDCANCEL, 0);
					return 0;
				}
				if(AttPhotoItem != 6)
				{
					PostMessage(hWnd, MSG_COMMAND, IDOK, 0);
					return 0;
				}
			}

			if (LOWORD(wParam)==SCANCODE_ESCAPE)
			{
				PostMessage(hWnd, MSG_COMMAND, IDCANCEL, 0);
				return 0;
			}
			break;
		case MSG_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDOK:
					if(PhotoOptOK(hWnd, AttPhotoItemWnd, 8) && !ismenutimeout)
					{
						MessageBox1 (hWnd, LoadStrByID(HIT_RIGHT),LoadStrByID(HIT_RUN), MB_OK| MB_ICONINFORMATION);
						PostMessage(hWnd, MSG_CLOSE,0,0);
					}
					else
					{
						PostMessage(hWnd, MSG_CLOSE,0,0);
					}
					break;
				case IDCANCEL:
					if(isChangedPhotoOpt())
					{
						if(MessageBox1(hWnd, LoadStrByID(MID_SAVEDATA), LoadStrByID(MID_APPNAME),
									MB_OKCANCEL | MB_ICONQUESTION | MB_BASEDONPARENT) == IDOK)
						{
							if(PhotoOptOK(hWnd, AttPhotoItemWnd, 8))
							{
								MessageBox1 (hWnd, LoadStrByID(HIT_RIGHT),LoadStrByID(HIT_RUN), MB_OK| MB_ICONINFORMATION);
								PostMessage(hWnd, MSG_CLOSE,0,0);
							}
							else
							{
								MessageBox1 (hWnd, LoadStrByID(HIT_ERR),LoadStrByID(HIT_RUN), MB_OK| MB_ICONINFORMATION);
								PostMessage(hWnd, MSG_CLOSE,0,0);
							}
						}
						else
						{
							if(!ismenutimeout)
								PostMessage(hWnd, MSG_CLOSE, 0, 0);
						}
					}
					else
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					break;
				case IDC_ATT_DEL:
					if(DelAttPhoto() == 0)
					{
						MessageBox1 (hWnd, LoadStrByID(HIT_RIGHT),LoadStrByID(HIT_RUN), MB_OK| MB_ICONINFORMATION);
					}
					else
					{
						MessageBox1 (hWnd, LoadStrByID(HIT_ERROR0),LoadStrByID(HIT_RUN), MB_OK| MB_ICONINFORMATION);
					}
					break;
			}
			break;

		case MSG_CLOSE:
			//UnloadBitmap(&system1bk);
			//MainWindowCleanup(hWnd);
			DestroyMainWindow(hWnd);
			return 0;
	}

	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}