static INT_PTR CALLBACK DefInpProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { int var; static bool chOk; switch (Msg) { case WM_INITDIALOG: { chOk = false; // Setup edit controls values (ROMs Paths) for(int x = 0; x < 8; x++) { SetDlgItemText(hDlg, IDC_ROMSDIR_EDIT1 + x, szAppRomPaths[x]); } // Setup the tabs hTabControl = GetDlgItem(hDlg, IDC_ROMPATH_TAB); TC_ITEM tcItem; tcItem.mask = TCIF_TEXT; UINT idsString[8] = { IDS_ROMPATH_1,IDS_ROMPATH_2,IDS_ROMPATH_3,IDS_ROMPATH_4,IDS_ROMPATH_5,IDS_ROMPATH_6,IDS_ROMPATH_7,IDS_ROMPATH_8 }; for(int nIndex = 0; nIndex < 8; nIndex++) { tcItem.pszText = FBALoadStringEx(hAppInst, idsString[nIndex], true); TabCtrl_InsertItem(hTabControl, nIndex, &tcItem); } int TabPage = TabCtrl_GetCurSel(hTabControl); // hide all controls excluding the selected controls for(int x = 0; x < 8; x++) { if(x != TabPage) { ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_BR1 + x), SW_HIDE); // browse buttons ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_EDIT1 + x), SW_HIDE); // edit controls } } // Show the proper controls ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_BR1 + TabPage), SW_SHOW); // browse buttons ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_EDIT1 + TabPage), SW_SHOW); // edit controls UpdateWindow(hDlg); WndInMid(hDlg, hParent); SetFocus(hDlg); // Enable Esc=close break; } case WM_NOTIFY: { NMHDR* pNmHdr = (NMHDR*)lParam; if (pNmHdr->code == TCN_SELCHANGE) { int TabPage = TabCtrl_GetCurSel(hTabControl); // hide all controls excluding the selected controls for(int x = 0; x < 8; x++) { if(x != TabPage) { ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_BR1 + x), SW_HIDE); // browse buttons ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_EDIT1 + x), SW_HIDE); // edit controls } } // Show the proper controls ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_BR1 + TabPage), SW_SHOW); // browse buttons ShowWindow(GetDlgItem(hDlg, IDC_ROMSDIR_EDIT1 + TabPage), SW_SHOW); // edit controls UpdateWindow(hDlg); return FALSE; } break; } case WM_COMMAND: { LPMALLOC pMalloc = NULL; BROWSEINFO bInfo; ITEMIDLIST* pItemIDList = NULL; TCHAR buffer[MAX_PATH]; if (LOWORD(wParam) == IDOK) { for (int i = 0; i < 8; i++) { // if (GetDlgItemText(hDlg, IDC_ROMSDIR_EDIT1 + i, buffer, sizeof(buffer)) && lstrcmp(szAppRomPaths[i], buffer)) { GetDlgItemText(hDlg, IDC_ROMSDIR_EDIT1 + i, buffer, sizeof(buffer)); if (lstrcmp(szAppRomPaths[i], buffer)) chOk = true; lstrcpy(szAppRomPaths[i], buffer); // } } SendMessage(hDlg, WM_CLOSE, 0, 0); break; } else { if (LOWORD(wParam) >= IDC_ROMSDIR_BR1 && LOWORD(wParam) <= IDC_ROMSDIR_BR8) { var = IDC_ROMSDIR_EDIT1 + LOWORD(wParam) - IDC_ROMSDIR_BR1; } else { if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL) { SendMessage(hDlg, WM_CLOSE, 0, 0); } break; } } SHGetMalloc(&pMalloc); memset(&bInfo, 0, sizeof(bInfo)); bInfo.hwndOwner = hDlg; bInfo.pszDisplayName = buffer; bInfo.lpszTitle = FBALoadStringEx(hAppInst, IDS_ROMS_SELECT_DIR, true); bInfo.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS; pItemIDList = SHBrowseForFolder(&bInfo); if (pItemIDList) { if (SHGetPathFromIDList(pItemIDList, buffer)) { int strLen = _tcslen(buffer); if (strLen) { if (buffer[strLen - 1] != _T('\\')) { buffer[strLen] = _T('\\'); buffer[strLen + 1] = _T('\0'); } SetDlgItemText(hDlg, var, buffer); } } pMalloc->Free(pItemIDList); } pMalloc->Release(); break; } case WM_CLOSE: { hParent = NULL; EndDialog(hDlg, 0); if (chOk) { bRescanRoms = true; CreateROMInfo(hDlg); } } } return 0; }
static int AppInit() { #if defined (_MSC_VER) && defined (_DEBUG) _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF); // Check for memory corruption _CrtSetDbgFlag(_CRTDBG_DELAY_FREE_MEM_DF); // _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); // #endif OpenDebugLog(); // Create a handle to the main thread of execution DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, 0, false, DUPLICATE_SAME_ACCESS); // Load config for the application ConfigAppLoad(); FBALocaliseInit(szLocalisationTemplate); kailleraInit(); #if 1 || !defined (FBA_DEBUG) // print a warning if we're running for the 1st time if (nIniVersion < nBurnVer) { ScrnInit(); //SplashDestroy(1); FirstUsageCreate(); ConfigAppSave(); // Create initial config file } #endif // Set the thread priority for the main thread SetThreadPriority(GetCurrentThread(), nAppThreadPriority); bCheatsAllowed = true; #ifdef USE_SDL SDL_Init(0); #endif // Init the Burn library BurnLibInit(); ComputeGammaLUT(); if (VidSelect(nVidSelect)) { nVidSelect = 0; VidSelect(nVidSelect); } hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR)); // Build the ROM information CreateROMInfo(); // Write a clrmame dat file if we are verifying roms #if defined (ROM_VERIFY) create_datfile(_T("fba.dat"), 0); #endif bNumlockStatus = SetNumLock(false); return 0; }