void COpenDlg::OnBnClickedDifffilebrowse() { CString temp; UpdateData(); temp.LoadString(IDS_SELECTFILE); BrowseForFile(m_sUnifiedDiffFile, temp, IDS_PATCHFILEFILTER); UpdateData(FALSE); }
void COpenDlg::OnBnClickedYourfilebrowse() { CString temp; UpdateData(); temp.LoadString(IDS_SELECTFILE); BrowseForFile(m_sYourFile, temp); UpdateData(FALSE); }
void CMainDlg::OnSave() { CString sFile; int fhLabel = 0; LPSTRUCT_LABELITEM lpLabelItem = NULL; unsigned char cTemp; UpdateData(TRUE); lpLabelItem = (LPSTRUCT_LABELITEM)listLabel.GetAt(pos); if(sLabel != lpLabelItem->szLabel) { free(lpLabelItem->szLabel); lpLabelItem->cLength_label = sLabel.GetLength(); lpLabelItem->szLabel = (LPTSTR)malloc(lpLabelItem->cLength_label + 1); memset(lpLabelItem->szLabel,0,lpLabelItem->cLength_label); strncpy(lpLabelItem->szLabel,sLabel,lpLabelItem->cLength_label); lpLabelItem->szLabel[lpLabelItem->cLength_label] = '\0'; GenerateChecksum(lpLabelItem); } if(!BrowseForFile(&sFile)) return; if((fhLabel = _open(sFile,_O_BINARY | _O_CREAT | _O_APPEND | _O_WRONLY,_S_IWRITE)) == -1) return; _chsize(fhLabel,0); cTemp = sVersion.GetLength(); _write(fhLabel,&cTemp,1); _write(fhLabel,sVersion,sVersion.GetLength()); cTemp += GenerateChecksum(sVersion,sVersion.GetLength()); _write(fhLabel,&cTemp,1); pos = listLabel.GetHeadPosition(); while(pos != NULL) { lpLabelItem = (LPSTRUCT_LABELITEM)listLabel.GetNext(pos); _write(fhLabel,&lpLabelItem->cLength_id,1); _write(fhLabel,lpLabelItem->szID,lpLabelItem->cLength_id); _write(fhLabel,&lpLabelItem->cLength_label,1); _write(fhLabel,lpLabelItem->szLabel,lpLabelItem->cLength_label); GenerateChecksum(lpLabelItem); _write(fhLabel,&lpLabelItem->cChecksum,1); } _close(fhLabel); }
void TSetupDlg::SetUseServerCert (BOOL bForceBrowse) { BOOL bOn = m_USESERVERCERT.Checked (); /* If checked, then browse for cert. * if the user canceled the browse, then uncheck */ if (bOn && bForceBrowse && m_SERVERCERT.TextLength () == 0 && !BrowseForFile (m_hInstance, m_SERVERCERT, IDS_X509BROWSE)) { bOn = FALSE; m_USESERVERCERT.Check (bOn); } m_SERVERCERT.Enable (bOn); m_BROWSESERVERCERT.Enable (bOn); }
void TLoginDlg::OnCommand (DWORD dwCmd, LPARAM lParam) { switch (dwCmd) { case MAKELPARAM (IDC_BROWSEUIDCERT, BN_CLICKED): BrowseForFile (m_hInstance, m_UID, IDS_PKCS12BROWSE); break; case MAKELPARAM (IDC_OPTIONS, BN_CLICKED): OnOptions (); break; case MAKELPARAM (IDOK, BN_CLICKED): SaveToProps (); EndDialog (m_hWnd, dwCmd); break; case MAKELPARAM (IDCANCEL, BN_CLICKED): EndDialog (m_hWnd, dwCmd); break; } }
/*------------------------------------------------------------------------ Procedure: GetOcamlPath ID:1 Purpose: Read the registry key HKEY_LOCAL_MACHINE\Software\Objective Caml or HKEY_CURRENT_USER\Software\Objective Caml, and creates it if it doesn't exists. If any error occurs, i.e. the given path doesn't exist, or the key didn't exist, it will put up a browse dialog box to allow the user to enter the path. The path will be verified that it points to a file that exists. If that file is in a directory called 'bin', it will look for another directory in the same level called lib' and set the Lib path to that. Input: None explicit Output: 1 means sucess, zero failure Errors: Almost all system calls will be verified ------------------------------------------------------------------------*/ int GetOcamlPath(void) { char path[1024], *p; while (( !ReadRegistry(HKEY_CURRENT_USER, "Software", "Objective Caml", "InterpreterPath", path) && !ReadRegistry(HKEY_LOCAL_MACHINE, "Software", "Objective Caml", "InterpreterPath", path)) || _access(path, 0) != 0) { /* Registry key doesn't exist or contains invalid path */ /* Ask user */ if (!BrowseForFile("Ocaml interpreter|ocaml.exe", path)) { ShowDbgMsg("Impossible to find ocaml.exe. I quit"); exit(0); } WriteRegistry(HKEY_CURRENT_USER, "Software", "Objective Caml", "InterpreterPath", path); /* Iterate to validate again */ } strcpy(OcamlPath, path); p = strrchr(OcamlPath,'\\'); if (p) { *p = 0; strcpy(LibDir,OcamlPath); *p = '\\'; p = strrchr(LibDir,'\\'); if (p && !stricmp(p,"\\bin")) { *p = 0; strcat(LibDir,"\\lib"); } } return 1; }
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_SYSCOMMAND: // Prevent screensavers, etc, while running. switch (wparam) { case SC_SCREENSAVE: case SC_MONITORPOWER: return 0; } break; case WM_SYSKEYDOWN: switch (wparam) { case VK_F10: case VK_MENU: case VK_RSHIFT: return 0; } break; case WM_CREATE: create_gl_context(hwnd); return 0; case WM_CLOSE: case WM_DESTROY: case WM_QUIT: { WINDOWPLACEMENT placement; GetWindowPlacement(g_hwnd, &placement); g_pos_x = placement.rcNormalPosition.left; g_pos_y = placement.rcNormalPosition.top; g_quit = true; return 0; } case WM_SIZE: // Do not send resize message if we minimize. if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED) { g_resize_width = LOWORD(lparam); g_resize_height = HIWORD(lparam); g_resized = true; } return 0; case WM_COMMAND: switch (wparam & 0xffff) { case ID_M_OPENROM: { char rom_file[PATH_MAX] = {0}; if (BrowseForFile(rom_file)) { strlcpy(g_extern.fullpath, rom_file, sizeof(g_extern.fullpath)); g_extern.lifecycle_mode_state |= (1ULL << MODE_LOAD_GAME); PostMessage(g_hwnd, WM_CLOSE, 0, 0); } break; } case ID_M_RESET: rarch_game_reset(); break; case ID_M_QUIT: PostMessage(g_hwnd, WM_CLOSE, 0, 0); break; } break; } return DefWindowProc(hwnd, message, wparam, lparam); }
void dialogEditor_dataitem::OnSave() { int fhOutput = -1; CString sError; int iLoop = 0; int iSub = 0; unsigned char cTemp; LPSTRUCT_LIVEBITITEM lpDataItem = NULL; unsigned long* lpOffset = NULL; POSITION pos = NULL; SaveChanges(); BrowseForFile(&sError,"Select a filename for the Data Item Data File",OFN_OVERWRITEPROMPT); if((fhOutput = _open(sError,_O_BINARY | _O_CREAT | _O_WRONLY,_S_IWRITE)) == -1) return; if((_chsize(fhOutput,0)) == -1) return; // Live Data File Format // 1 bytes [Version Length] // x bytes [Version] // 1 bytes [Version Checksum] // [..] // 1 bytes [Byte] // 1 bytes [Bit] // 1 bytes [Name Length] // x bytes [Name] // 4 bytes [Address High] // 4 bytes [Address Low] // 1 bytes [Type] // 2 bytes [Operand Addition] // 2 bytes [Operand Subtract] // 2 bytes [Operand Multiplier] // 2 bytes [Operand Divisor] // 2 bytes [Decimals] // 1 bytes [Unit Length] // x bytes [Unit] // 2 bytes [Description Length] // x bytes [Description] // 1 bytes [Checksum] // [..] cTemp = (char)sVersion.GetLength(); _write(fhOutput,&cTemp,1); _write(fhOutput,(LPCTSTR)sVersion,cTemp); cTemp += GenerateChecksum(sVersion,sVersion.GetLength()); _write(fhOutput,&cTemp,1); pos = listDataItem.GetHeadPosition(); while(pos != NULL) { lpDataItem = (LPSTRUCT_LIVEBITITEM)listDataItem.GetNext(pos); _write(fhOutput,&lpDataItem->cByte,1); _write(fhOutput,&lpDataItem->cBit,1); _write(fhOutput,&lpDataItem->cLength_name,1); _write(fhOutput,lpDataItem->szName,lpDataItem->cLength_name); _write(fhOutput,&lpDataItem->ulAddress_high,4); _write(fhOutput,&lpDataItem->ulAddress_low,4); _write(fhOutput,&lpDataItem->cType,1); _write(fhOutput,&lpDataItem->usOperand_addition,2); _write(fhOutput,&lpDataItem->usOperand_subtract,2); _write(fhOutput,&lpDataItem->usOperand_multiplier,2); _write(fhOutput,&lpDataItem->usOperand_divisor,2); _write(fhOutput,&lpDataItem->usDecimals,2); _write(fhOutput,&lpDataItem->cLength_unit,1); _write(fhOutput,lpDataItem->szUnit,lpDataItem->cLength_unit); _write(fhOutput,&lpDataItem->usLength_description,2); _write(fhOutput,lpDataItem->szDescription,lpDataItem->usLength_description); cTemp = GenerateChecksum(lpDataItem); _write(fhOutput,&cTemp,1); } }
void dialogEditor_dataitem::LoadDataFile() { CString sError; int fh = 0; unsigned char cRead = 0; unsigned char cChecksum = 0; unsigned char cStorage[1024]; LPSTRUCT_LIVEBITITEM lpDataItem = NULL; int iLoop = 0; // Live Data File Format // 1 bytes [Version Length] // x bytes [Version] // 1 bytes [Version Checksum] // [..] // 1 bytes [Byte] // 1 bytes [Bit] // 1 bytes [Name Length] // x bytes [Name] // 4 bytes [Address High] // 4 bytes [Address Low] // 1 bytes [Type] // 2 bytes [Operand Addition] // 2 bytes [Operand Subtract] // 2 bytes [Operand Multiplier] // 2 bytes [Operand Divisor] // 2 bytes [Decimals] // 1 bytes [Unit Length] // x bytes [Unit] // 2 bytes [Description Length] // x bytes [Description] // 1 bytes [Checksum] // [..] BrowseForFile(&sError,"Select the Data Item Data File",OFN_FILEMUSTEXIST); if((fh = _open(sError,_O_BINARY | _O_RDONLY,_S_IREAD)) == -1) return; _lseek(fh,0,SEEK_SET); _read(fh,&cRead,1); _read(fh,&cStorage[0],cRead); cStorage[cRead] = '\0'; sVersion = cStorage; _read(fh,&cRead,1); while(!_eof(fh)) { if((lpDataItem = new STRUCT_LIVEBITITEM) == NULL) return; _read(fh,&lpDataItem->cByte,1); _read(fh,&lpDataItem->cBit,1); _read(fh,&lpDataItem->cLength_name,1); _read(fh,&cStorage,lpDataItem->cLength_name); cStorage[lpDataItem->cLength_name] = '\0'; lpDataItem->szName = (LPTSTR)malloc(lpDataItem->cLength_name + 1); memset(lpDataItem->szName,0,lpDataItem->cLength_name); strncpy(lpDataItem->szName,(LPCTSTR)&cStorage[0],lpDataItem->cLength_name + 1); _read(fh,&cStorage,4); memcpy(&lpDataItem->ulAddress_high,&cStorage,4); _read(fh,&cStorage,4); memcpy(&lpDataItem->ulAddress_low,&cStorage,4); _read(fh,&lpDataItem->cType,1); _read(fh,&cStorage,2); memcpy(&lpDataItem->usOperand_addition,&cStorage,2); _read(fh,&cStorage,2); memcpy(&lpDataItem->usOperand_subtract,&cStorage,2); _read(fh,&cStorage,2); memcpy(&lpDataItem->usOperand_multiplier,&cStorage,2); _read(fh,&cStorage,2); memcpy(&lpDataItem->usOperand_divisor,&cStorage,2); _read(fh,&cStorage,2); memcpy(&lpDataItem->usDecimals,&cStorage,2); _read(fh,&lpDataItem->cLength_unit,1); _read(fh,&cStorage,lpDataItem->cLength_unit); cStorage[lpDataItem->cLength_unit] = '\0'; lpDataItem->szUnit = (LPTSTR)malloc(lpDataItem->cLength_unit + 1); memset(lpDataItem->szUnit,0,lpDataItem->cLength_unit); strncpy(lpDataItem->szUnit,(LPCTSTR)&cStorage[0],lpDataItem->cLength_unit + 1); _read(fh,&lpDataItem->usLength_description,2); _read(fh,&cStorage,lpDataItem->usLength_description); cStorage[lpDataItem->usLength_description] = '\0'; lpDataItem->szDescription = (LPTSTR)malloc(lpDataItem->usLength_description + 1); memset(lpDataItem->szDescription,0,lpDataItem->usLength_description); strncpy(lpDataItem->szDescription,(LPCTSTR)&cStorage[0],lpDataItem->usLength_description + 1); _read(fh,&cRead,1); listDataItem.AddTail(lpDataItem); } _close(fh); pos = listDataItem.GetHeadPosition(); }
void TSetupDlg::OnCommand (DWORD dwCmd, LPARAM lParam) { m_dwNotifyCode = dwCmd; switch (dwCmd) { /* Page 1 */ case MAKELPARAM (IDC_DSN, EN_CHANGE): ValidatePage (); break; case MAKELPARAM (IDC_SERVER, CBN_DROPDOWN): m_SERVER.OnCbnDropDown (); break; case MAKELPARAM (IDC_SERVER, CBN_CLOSEUP): m_SERVER.OnCbnCloseUp (); break; case MAKELPARAM (IDC_SERVER, CBN_EDITCHANGE): m_SERVER.OnCbnEditChange (); ValidatePage (); break; /* Page 2 */ case MAKELPARAM (IDC_AUTHMETHOD, CBN_SELCHANGE): SetAuthMethod (); break; case MAKELPARAM (IDC_USEUID, BN_CLICKED): SetUseUID (); ValidatePage (); break; case MAKELPARAM (IDC_UID, EN_CHANGE): ValidatePage (); break; case MAKELPARAM (IDC_BROWSEUIDCERT, BN_CLICKED): if (BrowseForFile (m_hInstance, m_UID, IDS_PKCS12BROWSE)) m_PWD.SetFocus (); break; case MAKELPARAM (IDC_USESERVERCERT, BN_CLICKED): SetUseServerCert (TRUE); ValidatePage (); break; case MAKELPARAM (IDC_SERVERCERT, EN_CHANGE): ValidatePage (); break; case MAKELPARAM (IDC_BROWSESERVERCERT, BN_CLICKED): BrowseForFile (m_hInstance, m_SERVERCERT, IDS_X509BROWSE); break; /* Page 3 */ case MAKELPARAM (IDC_USEDEFAULTDB, BN_CLICKED): SetUseDefaultDB (); ValidatePage (); break; case MAKELPARAM (IDC_USEDEFAULTIL, BN_CLICKED): SetUseDefaultIL (); ValidatePage (); break; case MAKELPARAM (IDC_USEDEFAULTCS, BN_CLICKED): SetUseDefaultCS (); ValidatePage (); break; case MAKELPARAM (IDC_DEFAULTDB, CBN_SELCHANGE): case MAKELPARAM (IDC_DEFAULTDB, CBN_EDITCHANGE): case MAKELPARAM (IDC_DEFAULTCS, CBN_SELCHANGE): case MAKELPARAM (IDC_DEFAULTCS, CBN_EDITCHANGE): case MAKELPARAM (IDC_DEFAULTIL, CBN_SELCHANGE): case MAKELPARAM (IDC_DEFAULTIL, CBN_EDITCHANGE): ValidatePage (); break; /* Global buttons */ case MAKELPARAM (IDC_BACKBTN, BN_CLICKED): ChangePage (m_iCurPage - 1); break; case MAKELPARAM (IDC_NEXTBTN, BN_CLICKED): if (m_iCurPage == 0) FillAuthMethods (); else if (m_iCurPage == 1) { FillIsolationLevels (); if (!FillDBCombos ()) { SetFocus (GetDlgItem (m_hPageWnd[1], IDC_PWD)); break; } } if (m_iCurPage == m_iNumPages - 1) { SaveToProps (); EndDialog (m_hWnd, IDOK); } else ChangePage (m_iCurPage + 1); break; case MAKELPARAM (IDCANCEL, BN_CLICKED): EndDialog (m_hWnd, dwCmd); break; } }
void CMainDlg::OnLoad() { CString sFile; int fhLabel = 0; unsigned char cRead; unsigned char cStorage[255]; LPSTRUCT_LABELITEM lpLabelItem = NULL; int iLoop; if(!BrowseForFile(&sFile)) return; if((fhLabel = _open(sFile,_O_BINARY | _O_RDONLY,_S_IREAD)) == -1) return; _lseek(fhLabel,0,SEEK_SET); _read(fhLabel,&cRead,1); _read(fhLabel,&cStorage,cRead); strncpy(sVersion.GetBufferSetLength(cRead),(LPCTSTR)&cStorage[0],cRead); sVersion.ReleaseBuffer(); _read(fhLabel,&cRead,1); while(!_eof(fhLabel)) { if((lpLabelItem = new STRUCT_LABELITEM) == NULL) return; _read(fhLabel,&lpLabelItem->cLength_id,1); lpLabelItem->szID = (LPTSTR)malloc(lpLabelItem->cLength_id + 1); memset(lpLabelItem->szID,0,lpLabelItem->cLength_id); _read(fhLabel,&cStorage,lpLabelItem->cLength_id); cStorage[lpLabelItem->cLength_id] = '\0'; strncpy(lpLabelItem->szID,(LPCTSTR)&cStorage[0],lpLabelItem->cLength_id + 1); _read(fhLabel,&lpLabelItem->cLength_label,1); lpLabelItem->szLabel = (LPTSTR)malloc(lpLabelItem->cLength_label + 1); memset(lpLabelItem->szLabel,0,lpLabelItem->cLength_label); _read(fhLabel,&cStorage,lpLabelItem->cLength_label); cStorage[lpLabelItem->cLength_label] = '\0'; strncpy(lpLabelItem->szLabel,(LPCTSTR)&cStorage[0],lpLabelItem->cLength_label + 1); // _read(fhLabel,&lpLabelItem->cLength_type,1); // lpLabelItem->szType = (LPTSTR)malloc(lpLabelItem->cLength_type + 1); // memset(lpLabelItem->szType,0,lpLabelItem->cLength_type); // _read(fhLabel,&cStorage,lpLabelItem->cLength_type); // cStorage[lpLabelItem->cLength_type] = '\0'; // strncpy(lpLabelItem->szType,(LPCTSTR)&cStorage[0],lpLabelItem->cLength_type + 1); _read(fhLabel,&lpLabelItem->cChecksum,1); listLabel.AddTail(lpLabelItem); } _close(fhLabel); pos = listLabel.GetHeadPosition(); lpLabelItem = (LPSTRUCT_LABELITEM)listLabel.GetAt(pos); for(iLoop = 0;iLoop < lpLabelItem->cLength_id;iLoop++) { sFile.Format("%02X ",(unsigned char)lpLabelItem->szID[iLoop]); sID += sFile; } sLabel = lpLabelItem->szLabel; // sType = lpLabelItem->szType; sChecksum = lpLabelItem->cChecksum; UpdateData(FALSE); usIndex++; sFile.Format("ecuExplorer Label Editor - %i of %i",usIndex,listLabel.GetCount()); SetWindowText(sFile); }