static BOOL SaveCanSetup(HWND hdlg, struct TMhsCanCfg* cfg) { short unBTRVal; UBTR0 sBtr0Reg; UBTR1 sBtr1Reg; UINT unNbt0 = 0; FLOAT fNbt = 0; UINT unBrp0 = 0; UINT unNbt1 = 0; UINT unBrp1 = 0; FLOAT fBrp = 0; WORD unProductNbtNBrp= 0; DOUBLE dBaudRate = 0; DOUBLE dblClock = 16; GetDlgItemTextCpy(cfg->CanSnrStr, hdlg, IDC_SNR_EDIT, MHS_STR_SIZE); if ( g_bBTRRadioBtnChecked ) { cfg->CanBtrValue = GetDlgItemHex(hdlg, IDC_BTR_EDIT); unBTRVal = cfg->CanBtrValue; sBtr1Reg.ucBTR1 = (0x00FF & unBTRVal); sBtr0Reg.ucBTR0 = (unBTRVal >> 8); // Get the baudrate for BTR0 and BTR1 values. dBaudRate = dCalculateBaudRateFromBTRs(sBtr0Reg.ucBTR0 ,sBtr1Reg.ucBTR1); // Calculate the NBT and BRP product. and NBT value using BTR0 value unProductNbtNBrp = (UINT)((dblClock/(dBaudRate/1000))/2.0* (defFACT_FREQUENCY / defFACT_BAUD_RATE)); unBrp0 = (sBtr0Reg.sBTR0Bit.ucBRPbit+1); unNbt0 = unProductNbtNBrp/unBrp0; fNbt = (FLOAT)unProductNbtNBrp/unBrp0; unNbt1 = (sBtr1Reg.sBTR1Bit.ucTSEG1bit+1)+ (sBtr1Reg.sBTR1Bit.ucTSEG2bit+1)+1; unBrp1 = unProductNbtNBrp/unNbt1; fBrp = (FLOAT)unProductNbtNBrp/unNbt1; //Check if the BTR0 and BTR1 value entered is valid. if Not valid // Restore the previos value else calculate the new list. if( unNbt0>defMAX_NBT || unNbt0<defMIN_NBT || fNbt != unNbt0 || unBrp1>defMAX_BRP || unBrp1<defMIN_BRP || unBrp1 != fBrp || unNbt1>defMAX_NBT || unNbt1<defMIN_NBT ) { MessageBox(hdlg, "Invalid BTRs Configuration!", "Warning", MB_OK|MB_ICONSTOP); return FALSE; } } else {
static void SaveCanSetup(HWND hdlg, struct TMhsCanCfg *cfg) { GetDlgItemTextCpy(cfg->CanSnrStr, hdlg, IDC_SNR_EDIT, MHS_STR_SIZE); cfg->CanBtrValue = GetDlgItemHex(hdlg, IDC_BTR_EDIT); cfg->CanSpeed = GetComboBox(hdlg, IDC_CAN_SPEED); }
BOOL FAR PASCAL CfgEdtBoxPrc (HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam) { #define PRPLOW "PrpLow" #define PRPHGH "PrpHgh" TMIDEF FAR * lpTMIDef; /* Inst local data block ptr */ BOOL bfXlt_OK; switch (uMsg) { case WM_INITDIALOG: /****************************************************************/ /* Store instance specific data pointer */ /****************************************************************/ if (!SetProp (hWnd, PRPLOW, (HANDLE) LOWORD (lParam)) || !SetProp (hWnd, PRPHGH, (HANDLE) HIWORD (lParam))) { EndDialog (hWnd, -1); break; } lpTMIDef = (TMIDEF FAR *) lParam; /****************************************************************/ /****************************************************************/ CtrDlgBox (NULL, hWnd, NULL, CTR_CTR); /****************************************************************/ SetDlgItemHex (hWnd, DI_VBSWIN, lpTMIDef->scSysCfg.sVBSwIn); SetDlgItemHex (hWnd, DI_VBHWIR, lpTMIDef->scSysCfg.sVBHwIn); SetDlgItemHex (hWnd, DI_MXHWIR, lpTMIDef->scSysCfg.sMxHwIn); SetDlgItemInt (hWnd, DI_LINNUM, lpTMIDef->scSysCfg.sLinNum, FALSE); SetDlgItemInt (hWnd, DI_MPXINP, lpTMIDef->scSysCfg.sMpxInp, FALSE); SetDlgItemInt (hWnd, DI_MPXOUT, lpTMIDef->scSysCfg.sMpxOut, FALSE); CheckDlgButton (hWnd, DI_WAICAL, lpTMIDef->scSysCfg.sWaiCal); SetDlgItemInt (hWnd, DI_SILCMP, lpTMIDef->lcLinCfg.sSilCmp, FALSE); SetDlgItemInt (hWnd, DI_MAXSIL, lpTMIDef->lcLinCfg.sMaxSil, FALSE); SetDlgItemInt (hWnd, DI_MAXSND, lpTMIDef->lcLinCfg.sMaxSnd, FALSE); // SetDlgItemInt (hWnd, DI_DIGINI, lpTMIDef->lcLinCfg.sDigIni, FALSE); // SetDlgItemInt (hWnd, DI_DIGTRM, lpTMIDef->lcLinCfg.sDigTrm, FALSE); CheckDlgButton (hWnd, DI_AGCMOD, lpTMIDef->lcLinCfg.sAGCMod); /****************************************************************/ /* Disable selections if no Multiplexer connected */ /****************************************************************/ if (!lpTMIDef->scSysCfg.sMxHwIn) { EnableWindow (GetDlgItem (hWnd, DI_MPXINP), FALSE); EnableWindow (GetDlgItem (hWnd, DI_MPXOUT), FALSE); } //Oops! must re-enable if users changes it! /************************************************************/ /* Set focus on 1st edit cntrl, ask Windows not to override */ /************************************************************/ SetFocus (GetDlgItem (hWnd, IDOK)); return (FALSE); case WM_CTLCOLOR: if ((CTLCOLOR_DLG == HIWORD (lParam)) || (CTLCOLOR_STATIC == HIWORD (lParam)) || (CTLCOLOR_BTN == HIWORD (lParam))) { SetBkColor ((HDC) wParam, TMIGlo.ulDBxClr); return ((BOOL) TMIGlo.hDBxBsh); } return (FALSE); case WM_COMMAND: if (NULL == (lpTMIDef = (TMIDEF FAR *) MAKELONG (GetProp (hWnd, PRPLOW), GetProp (hWnd, PRPHGH)))) { EndDialog (hWnd, -1); break; } switch(wParam) { /****************************************************************/ /****************************************************************/ case IDOK: lpTMIDef->scSysCfg.sVBSwIn = (short) GetDlgItemHex (hWnd, DI_VBSWIN); lpTMIDef->scSysCfg.sVBHwIn = (short) GetDlgItemHex (hWnd, DI_VBHWIR); lpTMIDef->scSysCfg.sMxHwIn = (short) GetDlgItemHex (hWnd, DI_MXHWIR); lpTMIDef->scSysCfg.sLinNum = GetDlgItemInt (hWnd, DI_LINNUM, &bfXlt_OK, FALSE); lpTMIDef->scSysCfg.sMpxInp = GetDlgItemInt (hWnd, DI_MPXINP, &bfXlt_OK, FALSE); lpTMIDef->scSysCfg.sMpxOut = GetDlgItemInt (hWnd, DI_MPXOUT, &bfXlt_OK, FALSE); lpTMIDef->scSysCfg.sWaiCal = IsDlgButtonChecked (hWnd, DI_WAICAL); lpTMIDef->lcLinCfg.sSilCmp = GetDlgItemInt (hWnd, DI_SILCMP, &bfXlt_OK, FALSE); lpTMIDef->lcLinCfg.sMaxSil = GetDlgItemInt (hWnd, DI_MAXSIL, &bfXlt_OK, FALSE); lpTMIDef->lcLinCfg.sMaxSnd = GetDlgItemInt (hWnd, DI_MAXSND, &bfXlt_OK, FALSE); // lpTMIDef->lcLinCfg.sDigIni = GetDlgItemInt (hWnd, DI_DIGINI, &bfXlt_OK, FALSE); // lpTMIDef->lcLinCfg.sDigTrm = GetDlgItemInt (hWnd, DI_DIGTRM, &bfXlt_OK, FALSE); lpTMIDef->lcLinCfg.sAGCMod = IsDlgButtonChecked (hWnd, DI_AGCMOD); EndDialog(hWnd, 0); return(TRUE); case IDCANCEL: EndDialog(hWnd, -1); return(TRUE); default: return(FALSE); } break; case WM_DESTROY: RemoveProp (hWnd, PRPLOW); RemoveProp (hWnd, PRPHGH); break; default: return(FALSE); } return(FALSE); }
LRESULT CALLBACK ScreenBackSettingsProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static BOOL focus = FALSE; static HWND hwndKB = NULL; int rgbCurrent; COLORREF nextColor; switch (uMsg) { case WM_INITDIALOG: SetWindowLong(hDlg, GWL_EXSTYLE, GetWindowLong(hDlg, GWL_EXSTYLE) | WS_EX_CAPTIONOKBTN); if (FindWindow(L"MS_SIPBUTTON", NULL) == NULL) { // SetWindowLong(hDlg, GWL_EXSTYLE, GetWindowLong(hDlg, GWL_EXSTYLE) | WS_EX_CONTEXTHELP); hwndKB = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_KB_BUTTON), hDlg, (DLGPROC) KBButtonDlgProc); } if (!isStaticBar) { ShowWindow(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_ALPHABLEND), SW_HIDE); } SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_GRADIENT), BM_SETCHECK, cur_cs->backGradient ? BST_CHECKED : BST_UNCHECKED, 0); SetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR1, cur_cs->backColor1); SetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR2, cur_cs->backColor2); SetDlgItemText(hDlg, IDC_EDIT_CS_BACK_WALLPAPER, cur_cs->backWallpaper); SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_ALPHABLEND), BM_SETCHECK, cur_cs->backWallpaperAlphaBlend ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_CENTER), BM_SETCHECK, cur_cs->backWallpaperCenter ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_TILE), BM_SETCHECK, cur_cs->backWallpaperTile ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_FIT_WIDTH), BM_SETCHECK, cur_cs->backWallpaperFitWidth ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_FIT_HEIGHT), BM_SETCHECK, cur_cs->backWallpaperFitHeight ? BST_CHECKED : BST_UNCHECKED, 0); return TRUE; case WM_MOVE: PositionKBButton(hwndKB, hDlg); break; case WM_ACTIVATE: if (wParam == WA_CLICKACTIVE || wParam == WA_ACTIVE) { EnableWindow(hwndKB, TRUE); } else if (!::IsChild(hDlg, (HWND)lParam)) { EnableWindow(hwndKB, FALSE); } break; case WM_CTLCOLOREDIT: if (focus) { //static DWORD start = -1; //if (start == -1) { // start = GetTickCount(); //} PostMessage((HWND) lParam, EM_SETSEL, 0, -1); //if (GetTickCount() - start > 1000) { // start = -1; focus = FALSE; //} } return 0; case WM_COMMAND: if (HIWORD(wParam) == EN_SETFOCUS) { if (configuracion && configuracion->autoShowKeyboardOnTextboxFocus) ToggleKeyboard(TRUE); focus = TRUE; PostMessage((HWND) lParam, EM_SETSEL, 0, -1); } else if (HIWORD(wParam) == EN_KILLFOCUS) { if (configuracion && configuracion->autoShowKeyboardOnTextboxFocus) ToggleKeyboard(FALSE); focus = FALSE; } switch(LOWORD(wParam)) { case IDOK: if (cur_cs == &ms) { BOOL backGradient = SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_GRADIENT), BM_GETCHECK, 0, 0) == BST_CHECKED; TCHAR backWallpaper[MAX_PATH]; GetDlgItemText(hDlg, IDC_EDIT_CS_BACK_WALLPAPER, backWallpaper, CountOf(backWallpaper)); TCHAR wallpaper[MAX_PATH]; StringCchCopy(wallpaper, CountOf(wallpaper), configuracion->strFondoPantalla); if (g_hDlg[1]) { GetDlgItemText(g_hDlg[1], IDC_EDIT_BACK_WALLPAPER, wallpaper, CountOf(wallpaper)); } #ifdef EXEC_MODE BOOL isTransparent = FALSE; #else BOOL isTransparent = configuracion->fondoTransparente; if (g_hDlg[1]) { configuracion->fondoTransparente = SendMessage(GetDlgItem(g_hDlg[1], IDC_CHECK_BACK_TRANSPARENT), BM_GETCHECK, 0, 0) == BST_CHECKED; } #endif if ((backGradient || wcslen(backWallpaper) > 0) && (isTransparent || wcslen(wallpaper) > 0)) { int resp = MessageBox(hDlg, L"Enabling a gradient or image background for the mainscreen pages, disables any wallpaper set in the \"Wallpaper\" tab. Continue?", L"Continue", MB_YESNO); if (resp == IDNO) { break; } } } cur_cs->backGradient = SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_GRADIENT), BM_GETCHECK, 0, 0) == BST_CHECKED; cur_cs->backColor1 = GetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR1, NULL); cur_cs->backColor2 = GetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR2, NULL); GetDlgItemText(hDlg, IDC_EDIT_CS_BACK_WALLPAPER, cur_cs->backWallpaper, CountOf(cur_cs->backWallpaper)); cur_cs->backWallpaperAlphaBlend = SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_ALPHABLEND), BM_GETCHECK, 0, 0) == BST_CHECKED; cur_cs->backWallpaperCenter = SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_CENTER), BM_GETCHECK, 0, 0) == BST_CHECKED; cur_cs->backWallpaperTile = SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_TILE), BM_GETCHECK, 0, 0) == BST_CHECKED; cur_cs->backWallpaperFitWidth = SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_FIT_WIDTH), BM_GETCHECK, 0, 0) == BST_CHECKED; cur_cs->backWallpaperFitHeight = SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_FIT_HEIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED; EndDialog(hDlg, LOWORD(wParam)); break; case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); break; case IDC_BUTTON_CS_BACK_COLOR1: rgbCurrent = GetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR1, NULL); if (ColorSelector(hDlg, rgbCurrent, &nextColor)) { SetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR1, nextColor); } break; case IDC_BUTTON_CS_BACK_COLOR2: rgbCurrent = GetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR2, NULL); if (ColorSelector(hDlg, rgbCurrent, &nextColor)) { SetDlgItemHex(hDlg, IDC_EDIT_CS_BACK_COLOR2, nextColor); } break; case IDC_BUTTON_CS_BACK_WALLPAPER: TCHAR str[MAX_PATH]; TCHAR fullPath[MAX_PATH]; TCHAR browseDir[MAX_PATH]; GetDlgItemText(hDlg, IDC_EDIT_CS_BACK_WALLPAPER, str, MAX_PATH); configuracion->getAbsolutePath(fullPath, MAX_PATH, str); getPathFromFile(fullPath, browseDir); if (openFileBrowse(hDlg, OFN_EXFLAG_THUMBNAILVIEW, fullPath, browseDir)) { configuracion->getRelativePath(str, MAX_PATH, fullPath); SetDlgItemText(hDlg, IDC_EDIT_CS_BACK_WALLPAPER, str); } break; case IDC_CHECK_CS_BACK_ALPHABLEND: if (SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_ALPHABLEND), BM_GETCHECK, 0, 0) == BST_CHECKED) { int resp = MessageBox(hDlg, L"You should enable this only if the selected image has transparency information " L"and you want to alphablend it to the wallpaper.\n" L"Enable it?\n", L"Are you sure?", MB_YESNO); if (resp == IDNO) { SendMessage(GetDlgItem(hDlg, IDC_CHECK_CS_BACK_ALPHABLEND), BM_SETCHECK, BST_UNCHECKED, 0); } } break; } break; // case WM_HELP: // ToggleKeyboard(); // break; } return FALSE; }