void Group_Create_OnNames (HWND hDlg) { TCHAR szSeparators[ cchRESOURCE ]; GetString (szSeparators, IDS_SEPARATORS); lstrcat (szSeparators, TEXT(" \t")); LPTSTR pszNames = GetEditText (GetDlgItem (hDlg, IDC_NEWGROUP_NAME)); EnableWindow (GetDlgItem (hDlg, IDOK), (pszNames && *pszNames)); BOOL fMultiple = FALSE; for (LPTSTR psz = pszNames; !fMultiple && psz && *psz; ++psz) { if (lstrchr (szSeparators, *psz)) fMultiple = TRUE; } FreeString (pszNames); EnableWindow (GetDlgItem (hDlg, IDC_NEWGROUP_ID_AUTO), !fMultiple); EnableWindow (GetDlgItem (hDlg, IDC_NEWGROUP_ID_MANUAL), !fMultiple); if (fMultiple) { CheckDlgButton (hDlg, IDC_NEWGROUP_ID_AUTO, TRUE); CheckDlgButton (hDlg, IDC_NEWGROUP_ID_MANUAL, FALSE); Group_Create_OnID (hDlg); } }
void Filesets_Dump_OnBrowse (HWND hDlg, LPSET_DUMP_PARAMS psdp) { TCHAR szFilter[ cchRESOURCE ]; GetString (szFilter, IDS_RESTORE_FILTER); TCHAR chFilter = szFilter[ lstrlen(szFilter)-1 ]; for (LPTSTR pszFilter = szFilter; (*pszFilter) && ((pszFilter = (LPTSTR)lstrchr (pszFilter, chFilter)) != NULL); ++pszFilter) { *pszFilter = TEXT('\0'); } TCHAR szFilename[ MAX_PATH ]; GetDlgItemText (hDlg, IDC_DUMP_FILENAME, szFilename, MAX_PATH); OPENFILENAME sfn; memset (&sfn, 0x00, sizeof(sfn)); sfn.lStructSize = sizeof(sfn); sfn.hwndOwner = hDlg; sfn.hInstance = THIS_HINST; sfn.lpstrFilter = szFilter; sfn.nFilterIndex = 1; sfn.lpstrFile = szFilename; sfn.nMaxFile = MAX_PATH; sfn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; sfn.lpstrDefExt = TEXT("dmp"); if (GetSaveFileName (&sfn)) { SetDlgItemText (hDlg, IDC_DUMP_FILENAME, szFilename); Filesets_Dump_EnableOK (hDlg); } }
static DWORD WINAPI ListenEnv( LPVOID lpParameter ) { HANDLE pipe = (HANDLE)lpParameter; connected = true; ConnectNamedPipe( pipe, 0 ); char buffer[MAX_PATH]; char* envs = 0; DWORD read = 0; int len = 0; while( ReadFile( pipe, buffer, MAX_PATH, &read, 0 ) || read ) { envs = (char*)realloc( envs, len + read ); lmemcpy( envs + len, buffer, read ); len += read; read = 0; } if( envs ) { wchar_t* var = (wchar_t*)envs; while( *var ) { int len = lstrlenW( var ); if( lstrchr( var + 1, '=' ) > 0 ) { int pos = lstrchr( var + 1, '=' ) + 1; var[pos] = 0; while( lstrlenW( var ) && var[lstrlenW( var ) - 1] <= ' ' ) var[lstrlenW( var ) - 1] = 0; wchar_t* val = var + pos + 1; while( *val && *val <= ' ' ) val++; SetEnvironmentVariableW( var, val ); } var += len + 1; } free( envs ); } DisconnectNamedPipe(pipe); return 0; }
void WizMount_OnInitDialog (HWND hDlg) { QueryDriveMapList (&l.List); size_t cMap = 0; for (size_t iDrive = 0; iDrive < 26; ++iDrive) { if (l.List.aDriveMap[iDrive].szMapping[0]) ++cMap; } if (cMap) { g.pWizard->SetState (STEP_MOUNTING); return; } // Fill in the combo box // DWORD dwDrives = GetLogicalDrives() | 0x07; // Always pretend A,B,C: are used int iItemSel = -1; HWND hCombo = GetDlgItem (hDlg, IDC_MAP_LETTER); SendMessage (hCombo, WM_SETREDRAW, FALSE, 0); for (int ii = 0; ii < 26; ++ii) { if (!(dwDrives & (1<<ii))) { TCHAR szText[ cchRESOURCE ]; GetString (szText, IDS_MAP_LETTER); LPTSTR pch; if ((pch = (LPTSTR)lstrchr (szText, TEXT('*'))) != NULL) *pch = TEXT('A') + ii; int iItem = SendMessage (hCombo, CB_ADDSTRING, 0, (LPARAM)szText); SendMessage (hCombo, CB_SETITEMDATA, iItem, ii); if (iItemSel == -1) iItemSel = iItem; } } SendMessage (hCombo, WM_SETREDRAW, TRUE, 0); SendMessage (hCombo, CB_SETCURSEL, iItemSel, 0); SetDlgItemText (hDlg, IDC_MAP_PATH, cm_slash_mount_root); CheckDlgButton (hDlg, IDC_NOMAP, FALSE); CheckDlgButton (hDlg, IDC_YESMAP, TRUE); }
void AutoMapEdit_OnInitDialog (HWND hDlg) { PDRIVEMAP pMap = (PDRIVEMAP)GetWindowLongPtr (hDlg, DWLP_USER); DWORD dwDrives = GetLogicalDrives() | 0x07; // Always pretend A,B,C: are used // Fill in the combo box // if (pMap->chDrive != 0) dwDrives &= ~( 1 << (pMap->chDrive - chDRIVE_A) ); int iItemSel = -1; HWND hCombo = GetDlgItem (hDlg, IDC_DRIVE); SendMessage (hCombo, WM_SETREDRAW, FALSE, 0); for (int ii = 0; ii < 26; ++ii) { if (!(dwDrives & (1<<ii))) { TCHAR szText[ cchRESOURCE ]; GetString (szText, IDS_MAP_LETTER); LPTSTR pch; if ((pch = (LPTSTR)lstrchr (szText, TEXT('*'))) != NULL) *pch = TEXT('A') + ii; int iItem = SendMessage (hCombo, CB_ADDSTRING, 0, (LPARAM)szText); SendMessage (hCombo, CB_SETITEMDATA, iItem, ii); if (pMap->chDrive && (ii == pMap->chDrive - chDRIVE_A)) iItemSel = iItem; else if ((!pMap->chDrive) && (iItemSel == -1)) iItemSel = iItem; } } SendMessage (hCombo, WM_SETREDRAW, TRUE, 0); SendMessage (hCombo, CB_SETCURSEL, iItemSel, 0); TCHAR szMapping[ MAX_PATH ]; AdjustAfsPath (szMapping, ((pMap->szMapping[0]) ? pMap->szMapping : cm_slash_mount_root), TRUE, FALSE); SetDlgItemText (hDlg, IDC_PATH, szMapping); SetDlgItemText (hDlg, IDC_DESC, pMap->szSubmount); CheckDlgButton (hDlg, IDC_PERSISTENT, (pMap->chDrive == 0) ? TRUE : (pMap->fPersistent)); AutoMapEdit_Enable (hDlg); }
void User_SplitDisplayName (LPTSTR pszFull, LPTSTR pszName, LPTSTR pszInstance) { if (pszName) lstrcpy (pszName, pszFull); if (pszInstance) lstrcpy (pszInstance, TEXT("")); if (!fIsMachineAccount (pszFull)) { if (pszName && pszInstance) { LPTSTR pchDot; if ((pchDot = (LPTSTR)lstrchr (pszName, TEXT('.'))) != NULL) { *pchDot = TEXT('\0'); lstrcpy (pszInstance, &pchDot[1]); } } } }
bool WriteRegistryTreeToFile(const TCHAR *key, const TCHAR *filename) { ASSERT(key && key[0] != 0); ASSERT(filename && filename[0] != 0); if (key == NULL || key[0] == 0) return false; if (filename == NULL || filename[0] == 0) return false; TCHAR *cp = lstrchr(key, _T('\\')); if (cp == NULL) return false; int len = cp - key; HKEY hKey = NULL; #define IS_PATH(id, short_id) \ (lstrcmpn(key, _T(#id), len) == 0 || lstrcmpn(key, _T(#short_id), len) == 0) hKey = id if IS_PATH(HKEY_CLASSES_ROOT, HKCR); else if IS_PATH(HKEY_CURRENT_USER, HKCU);
void SERVER::ShortenName (LPTSTR pszTarget, LPTSTR pszSource, BOOL fForce) { lstrcpy (pszTarget, pszSource); if (fForce || !fLongServerNames) { // If the name is really an IP address, don't shorten it. // BOOL fIsIPAddress = TRUE; for (LPTSTR pch = pszTarget; *pch && fIsIPAddress; ++pch) { if (!isdigit(*pch) && !(*pch == TEXT('.'))) fIsIPAddress = FALSE; } if (!fIsIPAddress) { if ((pszTarget = (LPTSTR)lstrchr (pszTarget, TEXT('.'))) != NULL) *pszTarget = TEXT('\0'); } } }
int WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd) { LPTSTR CmdLine; LPTSTR p; CmdLine = GetCommandLine(); DPRINT("CmdLine: <%s>\n",CmdLine); p = lstrchr(CmdLine, TEXT('-')); if (p == NULL) return 0; if (!lstrcmpi(p, TEXT("-newsetup"))) { RunNewSetup(hInstance); } else if (!lstrcmpi(p, TEXT("-mini"))) { RunLiveCD(hInstance); } #if 0 /* Add new setup types here */ else if (...) { } #endif return 0; }
void Server_Install_OnBrowse (HWND hDlg) { TCHAR szFilter[ cchRESOURCE ]; GetString (szFilter, IDS_FILTER_ALLFILES); TCHAR chFilter = szFilter[ lstrlen(szFilter)-1 ]; for (LPTSTR pszFilter = szFilter; (*pszFilter) && ((pszFilter = (LPTSTR)lstrchr (pszFilter, chFilter)) != NULL); ++pszFilter) { *pszFilter = TEXT('\0'); } TCHAR szFilename[ MAX_PATH ]; GetDlgItemText (hDlg, IDC_FILENAME, szFilename, MAX_PATH); OPENFILENAME ofn; memset (&ofn, 0x00, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hDlg; ofn.hInstance = THIS_HINST; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFilename; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; TCHAR szPath[ MAX_PATH ]; GetCurrentDirectory (MAX_PATH, szPath); BOOL rc = GetOpenFileName (&ofn); SetCurrentDirectory (szPath); if (rc) SetDlgItemText (hDlg, IDC_FILENAME, szFilename); }
BOOL Group_Create_OnOK (HWND hDlg) { LPCREATEGROUPDLG lpp = (LPCREATEGROUPDLG)GetWindowLongPtr (hDlg, DWLP_USER); // Start a background task to do all the work. // LPGROUP_CREATE_PARAMS pTask = New (GROUP_CREATE_PARAMS); memset (pTask, 0x00, sizeof(GROUP_CREATE_PARAMS)); if (IsDlgButtonChecked (hDlg, IDC_NEWGROUP_ID_AUTO)) pTask->idGroup = UID_AUTOSELECT; else // (IsDlgButtonChecked (hDlg, IDC_NEWGROUP_ID_MANUAL)) pTask->idGroup = SP_GetPos (GetDlgItem (hDlg, IDC_NEWGROUP_ID)); lstrcpy (pTask->Properties.szOwner, lpp->Advanced.szOwner); pTask->Properties.aaListStatus = lpp->Advanced.aaStatus; pTask->Properties.aaListGroupsOwned = lpp->Advanced.aaGroups; pTask->Properties.aaListMembers = lpp->Advanced.aaMembers; pTask->Properties.aaAddMember = lpp->Advanced.aaAdd; pTask->Properties.aaDeleteMember = lpp->Advanced.aaRemove; if (lpp->Advanced.pMembers) asc_AsidListCopy (&pTask->pMembers, &lpp->Advanced.pMembers); else pTask->pMembers = NULL; if (lpp->Advanced.pGroupsOwner) asc_AsidListCopy (&pTask->pGroupsOwner, &lpp->Advanced.pGroupsOwner); else pTask->pGroupsOwner = NULL; // Crack the specified list of user names into a multi-string // TCHAR szSeparators[ cchRESOURCE ]; GetString (szSeparators, IDS_SEPARATORS); lstrcat (szSeparators, TEXT(" \t")); LPTSTR pszNames = GetEditText (GetDlgItem (hDlg, IDC_NEWGROUP_NAME)); LPCTSTR pszStart = pszNames; while (lstrchr (szSeparators, *pszStart)) ++pszStart; while (*pszStart) { // Find the first non-name character // LPCTSTR pszEnd = pszStart; while (*pszEnd && !lstrchr(szSeparators, *pszEnd)) ++pszEnd; // Copy off this particular name // TCHAR szName[ cchNAME ]; lstrcpy (szName, pszStart); szName[ pszEnd - pszStart ] = TEXT('\0'); if (szName[0]) FormatMultiString (&pTask->mszNames, FALSE, TEXT("%1"), TEXT("%s"), szName); // Find the next valid-name character // pszStart = pszEnd; while (lstrchr(szSeparators, *pszStart)) ++pszStart; } FreeString (pszNames); // Do the real work of creating the user(s) // StartTask (taskGROUP_CREATE, NULL, pTask); // Store these creation parameters as the new defaults // memcpy (&gr.CreateGroup, &lpp->Advanced, sizeof(GROUPPROPINFO)); return TRUE; }
/*---------------------------------------------------------------------------- CheckSakuraFileMapping() ファイルマッピングオブジェクトの存在確認 ----------------------------------------------------------------------------*/ BOOL CheckSakuraFileMapping(HWND hParentWnd, vector<HWND>& vec) { HANDLE hFileMap; LPVOID lpBasePtr; LPSTR lpBuffer; LPSTR lpType1; LPSTR lpType2; CHAR szTemp[200]; DWORD dwSize; HWND hWnd = NULL; BOOL bRet; vec.clear(); // ファイルマップを開く hFileMap = OpenFileMapping(FILE_MAP_READ, FALSE, MY_EXIST_FILEMAP); if(hFileMap == NULL) { // 存在しない //MessageBox(hParentWnd, "ファイルマッピングオブジェクトが開けません。", "TestSSTP", MB_ICONSTOP); return FALSE; } // ベースアドレス取得 lpBasePtr = (LPVOID)MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0); if(lpBasePtr == NULL) { // 失敗 //MessageBox(hParentWnd, "ファイルマッピングオブジェクトが操作できません。", "TestSSTP", MB_ICONSTOP); CloseHandle(hFileMap); return FALSE; } lpBuffer = (LPSTR)lpBasePtr; // データ読み込み bRet = TRUE; try { CopyMemory(&dwSize, lpBuffer, sizeof(DWORD)); lpBuffer += sizeof(DWORD); while(*lpBuffer) { // エントリ解析 lpType1 = lstrchr(lpBuffer, '.'); lpType1++; lpType2 = lstrchr(lpType1, '\01'); lpType2++; lstrcpyn(szTemp, lpType1, lpType2 - lpType1); // エントリの種類ごとに分岐 if(lstrcmpi(szTemp, "hwnd") == 0) { // データ取得 lpType1 = lstrchr(lpType2, '\r'); lpType1++; lstrcpyn(szTemp, lpType2, lpType1 - lpType2); hWnd = (HWND)atoi(szTemp); vec.push_back(hWnd); } // \r\n まで1エントリ lpBuffer = lstrchr(lpBuffer, '\n'); if(lpBuffer) { lpBuffer++; } } bRet = vec.size() > 0 ? TRUE : FALSE; } catch(...) { bRet = FALSE; } UnmapViewOfFile(lpBasePtr); CloseHandle(hFileMap); return bRet; }
HINSTANCE TaLocale_LoadCorrespondingModuleByName (HINSTANCE hInstance, LPTSTR pszFilename, WORD wSearchPriority) { HINSTANCE hDLL = NULL; TCHAR szFilename[ MAX_PATH ]; if (lstrchr (pszFilename, TEXT('\\')) != NULL) lstrcpy (szFilename, pszFilename); else { GetModuleFileName (hInstance, szFilename, MAX_PATH); lstrcpy ((LPTSTR)FindBaseFileName (szFilename), pszFilename); } // If the caller was sloppy and didn't supply an instance handle, // assume we should find the module corresponding with the current .EXE. // if (hInstance == NULL) hInstance = GetModuleHandle(NULL); LPTSTR pchExtension; if ((pchExtension = (LPTSTR)FindExtension (szFilename)) != NULL) { // Find the filename associated with the specified module, remove its // extension, and append "_409.dll" (where the 409 is, naturally, the // current LANGID). Then try to load that library. // wsprintf (pchExtension, TEXT("_%lu.dll"), TaLocale_GetLanguage()); if ((hDLL = LoadLibrary (szFilename)) == NULL) hDLL = LoadLibrary (FindBaseFileName (szFilename)); // If we couldn't find the thing under that name, it's possible we // have a .DLL made for the proper language but not for the user's // specific sublanguage (say, a US English .DLL but we're running // in a Canadian English locale). Make an intelligent guess about // what the valid ID would be. // if (hDLL == NULL) { wsprintf (pchExtension, TEXT("_%lu.dll"), TaLocale_GuessBestLangID (TaLocale_GetLanguage())); if ((hDLL = LoadLibrary (szFilename)) == NULL) hDLL = LoadLibrary (FindBaseFileName (szFilename)); } // If we STILL couldn't find a corresponding resource library, // we'll take anything we can find; this should cover the case // where a Setup program asked the user what language to use, // and just installed that matching library. Look in the // appropriate directory for any .DLL that fits the naming convention. // if (hDLL == NULL) { wsprintf (pchExtension, TEXT("_*.dll")); WIN32_FIND_DATA wfd; memset (&wfd, 0x00, sizeof(wfd)); HANDLE hFind; if ((hFind = FindFirstFile (szFilename, &wfd)) != NULL) { if (wfd.cFileName[0]) { wsprintf ((LPTSTR)FindBaseFileName (szFilename), wfd.cFileName); hDLL = LoadLibrary (szFilename); } FindClose (hFind); } } // If we EVEN NOW couldn't find a corresponding resource library, // we may have done our wildcard search in the wrong directory. // Try to find the Common subdirectory of our AFS installation, // and look for any matching DLL there. // if (hDLL == NULL) { wsprintf (pchExtension, TEXT("_*.dll")); TCHAR szCommonPath[ MAX_PATH ]; if (FindAfsCommonPath (szCommonPath)) { lstrcat (szCommonPath, TEXT("\\")); lstrcat (szCommonPath, FindBaseFileName (szFilename)); WIN32_FIND_DATA wfd; memset (&wfd, 0x00, sizeof(wfd)); HANDLE hFind; if ((hFind = FindFirstFile (szCommonPath, &wfd)) != NULL) { if (wfd.cFileName[0]) { wsprintf ((LPTSTR)FindBaseFileName (szCommonPath), wfd.cFileName); hDLL = LoadLibrary (szCommonPath); } FindClose (hFind); } } } // If all else fails, we'll try to find the English library // somewhere on our path. // if (hDLL == NULL) { wsprintf (pchExtension, TEXT("_%lu.dll"), MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US)); if ((hDLL = LoadLibrary (szFilename)) == NULL) hDLL = LoadLibrary (FindBaseFileName (szFilename)); } // If we were successful in loading the resource library, add it // to our chain of modules-to-search // if (hDLL != NULL) { TaLocale_SpecifyModule (hDLL, wSearchPriority); } } return hDLL; }
BOOL WINPROC EXPORT DlgOpenProc( /************************************************************************/ HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL Bool; ITEMID id; WORD wMsg, wIndex; int i, ii, l, fp, hi, lo; FNAME szDriveNDir, szFileName, szExtension; HMENU hMenu; STRING szString; char cChar; BOOL bModifySaveName; static BOOL bDisableCancel; switch (msg) { case WM_INITDIALOG: SET_CLASS_HBRBACKGROUND(hDlg, ( HBRUSH )GetStockObject(LTGRAY_BRUSH)); CenterPopup( hDlg ); if ( !DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr) ) { lstrcpy( szFileSpec, lstrchr( szFileSpec, '*' ) ); DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr); } SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving); CheckComboItem( hDlg, IDC_FILETYPES, IDC_ART, IDC_BMP, IDC_ART + (idFileType-IDN_ART) ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_LIMITTEXT, MAX_FNAME_LEN-1, 0L); LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, NO ); CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath ); CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed ); for (i = IDC_ART; bImageOpen && i <= IDC_BMP; ++i) { ii = i-IDC_ART; if (lstrlen(Readers[ii].szDLL)) { lstrcpy(szString, Control.ProgHome); lstrcat(szString, Readers[ii].szDLL); if (!FileExists(szString)) { if ( GetPrivateProfileString( "Micrografx", "Libraries", "", szString, sizeof(STRING), "MGX.INI" ) > 2 ) FixPath( szString ); lstrcat(szString, Readers[ii].szDLL); if (!FileExists(szString)) { ControlEnable( hDlg, i, NO); continue; } } } if (fSaving) ControlEnable( hDlg, i, lpImage && Readers[ii].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))] ); else ControlEnable( hDlg, i, Readers[ii].bOpen ); } if ( bImageOpen && lpImage ) { idDataType = lpImage->DataType; for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i) ControlEnable( hDlg, i, Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]); CheckComboItem( hDlg, IDC_DATATYPES, IDC_SAVECT, IDC_SAVE24BITCOLOR, idDataType ); ControlEnable( hDlg, IDC_SAVECOMPRESS, Readers[idFileType-IDN_ART].bCompressed ); } SetFocus( GetDlgItem( hDlg, IDC_FNAME ) ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL, NULL, MAKELONG(0, 0x7fff)); bNavigated = NO; bDisableCancel = NO; return( FALSE ); case WM_PALETTECHANGED: break; case WM_MENUSELECT: lo = LOWORD(lParam); hi = HIWORD(lParam); if (hi == 0) break; if (lo == -1) break; if (lo & MF_SYSMENU) break; if (lo & MF_POPUP) { hMenu = (HMENU)wParam; while (GetSubMenu(hMenu, 0)) hMenu = GetSubMenu(hMenu, 0); id = GetMenuItemID(hMenu, 0); if (id <= 0) break; wParam = id - 1; } HintLine( wParam ); break; case WM_SETCURSOR: return( SetupCursor( wParam, lParam, idOpen ) ); case WM_CLOSE: AstralDlgEnd( hDlg, FALSE|2 ); break; case WM_MEASUREITEM: case WM_DRAWITEM: id = ((LPDRAWITEMSTRUCT)lParam)->CtlID; Bool = ( id == IDC_DRIVES || id == IDC_DIRS ); return( OwnerDraw( hDlg, msg, lParam, Bool ) ); // break; case WM_CTLCOLOR: return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam), HIWORD(lParam) ) ); case WM_COMMAND: if (wParam != IDCANCEL) bDisableCancel = NO; switch(wParam) { case IDC_FILETYPES: // case IDC_ART: // case IDC_TIFF: // case IDC_BMP: if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) ) break; idFileType = IDN_ART + (wParam-IDC_ART); if (bNavigated) { LookupExtension( idFileType, szFileSpec ); } else GetFileLocation( idFileType, szFileSpec ); for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i) ControlEnable( hDlg, i, Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]); ControlEnable( hDlg, IDC_SAVECOMPRESS, Readers[idFileType-IDN_ART].bCompressed ); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO ); SendMessage( hDlg, WM_COMMAND, IDOK, 0L ); break; case IDC_DATATYPES: // case IDC_SAVECT: // case IDC_SAVELA: // case IDC_SAVESP: // scatterprint // case IDC_SAVE8BITCOLOR: // case IDC_SAVE24BITCOLOR: if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) ) break; idDataType = wParam; break; case IDC_SAVEPATH: Save.OKtoSavePath = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVEPATH, BM_GETCHECK, 0, 0L); // Save.OKtoSavePath = !Save.OKtoSavePath; // CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath ); break; case IDC_SAVECOMPRESS: Save.Compressed = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVECOMPRESS, BM_GETCHECK, 0, 0L); // Save.Compressed = !Save.Compressed; // CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed ); break; case IDC_DRIVES: wMsg = HIWORD(lParam); if ( wMsg != CBN_SELCHANGE ) break; wIndex = SendDlgItemMessage( hDlg, wParam, CB_GETCURSEL, 0, 0L); SendDlgItemMessage( hDlg, wParam, CB_GETLBTEXT, wIndex, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if (CHDRIVE( *szDriveNDir - 'a' )) { LoadComboWithDrives(hDlg, IDC_DRIVES); break; } if (!CURRENTDIR(szString, sizeof(szString))) { GetDlgItemText(hDlg, IDC_FPATH, szString, sizeof(szString)); CHDRIVE(*szString - 'a'); LoadComboWithDrives(hDlg, IDC_DRIVES); } //12/15 SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO); DlgDirList( hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); SetDlgItemText( hDlg, IDC_DISKSPACE, DriveSize( *szDriveNDir - 'a', szString ) ); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); bNavigated = YES; break; case IDC_DIRS: wMsg = HIWORD(lParam); if ( wMsg == LBN_DBLCLK ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != LBN_SELCHANGE ) break; wIndex = SendDlgItemMessage( hDlg, wParam, LB_GETCURSEL, 0, 0L); // Figure out how to build the path name based on the selection SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, wIndex, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if ( id == IDC_PATHICON_OPEN ) i = 0; // Must start building the path from the root else if ( id == IDC_PATHICON_ACTIVE ) i = 9999; // Don't build any path - we're there else i = wIndex; // OK to build a relative path szFileName[0] = '\0'; for ( ; i<=wIndex; i++ ) { SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, i, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if ( id == IDC_PATHICON_CLOSED && i != wIndex ) continue; lstrcat( szFileName, SkipSpaces(szDriveNDir) ); if ( id != IDC_PATHICON_ROOT ) lstrcat( szFileName, "\\" ); } lstrcat( szFileName, szFileSpec ); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); bNavigated = YES; break; case IDC_FLIST: wMsg = HIWORD(lParam); if ( wMsg == LBN_DBLCLK ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != LBN_SELCHANGE ) break; /* If a directory is selected... */ if (DlgDirSelectEx(hDlg, szFileName, sizeof(szFileName), wParam)) lstrcat(szFileName, szFileSpec); // 1-2-92 - TMR - always use SetFileName for all FNAME sets // SetDlgItemText(hDlg, IDC_FNAME, szFileName); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL, NULL, MAKELONG(0, 0x7fff)); // SendDlgItemMessage(hDlg, IDC_FNAME, CB_SETEDITSEL, // NULL, MAKELONG(0, 0x7fff)); break; case IDC_FNAME: /* If the name is changed, disable OK if its length goes 0 */ if (HIWORD(lParam) != EN_CHANGE) // if (HIWORD(lParam) != CBN_EDITCHANGE) break; ControlEnable( hDlg, IDOK, (BOOL)SendDlgItemMessage( hDlg, wParam, WM_GETTEXTLENGTH, 0, 0L)); // 1-2-92 - TMR - make sure Edit Box has focus to make sure // that szSaveName only gets overwritten from user input // 1-3-92 - TMR - move this after ControlEnable if (GetFocus() != GetDlgItem(hDlg, IDC_FNAME)) break; if (fSaving) { GetDlgItemText(hDlg, IDC_FNAME, szSaveName, MAX_FNAME_LEN); fUntitled = NO; } break; case IDC_FPATH: wMsg = HIWORD(lParam); if ( wMsg == BN_DOUBLECLICKED ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != BN_CLICKED ) break; GetDlgItemText(hDlg, wParam, szFileName, sizeof(szFileName)); if ( !szFileName[0] ) break; FixPath( szFileName ); lstrcat( szFileName, szFileSpec ); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); bNavigated = YES; break; case IDOK: GetDlgItemText(hDlg, IDC_FNAME, szFileName,sizeof(szFileName)); bModifySaveName = fSaving && StringsEqual(szFileName, szSaveName); /* Strip off the drive and directory to make */ /* a DlgDirlist() call to switch over to them */ /* Loop backwards over the file name */ l = lstrlen(szFileName); while( --l >= 0 ) { cChar = szFileName[l]; /* If we find a wildcard, the next DlgDirList() takes */ /* care of drive and directory switching; so get out */ if ( cChar == '?' || cChar == '*' ) break; /* If we find a drive or directory, handle it and get out */ if ( cChar == '\\' || cChar == ':' ) { lstrcpy(szDriveNDir, szFileName); l++; szDriveNDir[l] = '\0'; lstrcat(szDriveNDir, szFileSpec); // 1-3-92 - TMR - Handle directory change error if (DlgDirList(hDlg, szDriveNDir, IDC_FLIST, IDC_FPATH, wFileAttr)) lstrcpy( szFileName, &szFileName[l] ); else { szDriveNDir[l] = '\0'; Message(IDS_EDIRECTORYCHANGE, Lowercase(szDriveNDir)); szFileName[0] = '\0'; } break; } } // 1-3-92 - TMR add extension if none present /* Check to see if the file has an extension... */ if ( !lstrchr( szFileName, '.' ) ) // if no extension... if ( LookupExtension( idFileType, szExtension ) ) { if (lstrlen(szFileName)) lstrcat( szFileName, extension(szExtension) ); else lstrcat( szFileName, szExtension); } if (bModifySaveName) lstrcpy(szSaveName, szFileName); /* Try to display a new list box */ if ( !szFileName[0] ) lstrcat(szFileName, szFileSpec); if (DlgDirList(hDlg, szFileName, IDC_FLIST, IDC_FPATH, wFileAttr)) { /* A wildcard was found and a new list displayed */ lstrcpy(szFileSpec, szFileName); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); break; } // If there is still a path or wildcards in the name, the // file specification must be invalid if (lstrchr(szFileName, '\\') || lstrchr(szFileName, ':') || lstrchr(szFileName, '?') || lstrchr(szFileName, '*')) { lstrcpy(szString, szFileName); stripfile(szString); Message(IDS_EDIRECTORYCHANGE, Lowercase(szString)); lstrcpy(szFileSpec, filename(szFileName)); lstrcpy(szFileName, szFileSpec); // is this needed? SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); break; } /* No wildcards, and the drive and dir have been changed */ LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); /* Check to see if the file has 8 characters or less... */ if ( fSaving ) RemoveWhiteSpace( szFileName ); FixFileName( szFileName ); /* Check to see if the file has an extension... */ if ( !lstrchr( szFileName, '.' ) ) // if no extension... if ( LookupExtension( idFileType, szExtension ) ) lstrcat( szFileName, extension(szExtension) ); // Build the fully qualified path name GetDlgItemText( hDlg, IDC_FPATH, szString, sizeof(szString) ); FixPath( szString ); lstrcat( szString, szFileName ); /* Check to see if the file exists... */ if ( (fp = _lopen( szString, OF_READ ) ) < 0 ) { /* The file does not exist */ if ( !fSaving ) { Message(IDS_EOPEN, Lowercase(szString)); break; } } else { _lclose( fp ); if ( fSaving ) { if ( !AstralAffirm( IDS_OVERWRITEIMAGE, Lowercase(szString) ) ) break; } } lstrcpy( szFileSpec, szString ); AstralDlgEnd(hDlg, TRUE|2); break; case IDC_CANCEL: case IDCANCEL: if ( bDisableCancel && !LOWORD(lParam) ) break; GetDlgItemText(hDlg, IDC_FPATH, szFileSpec,sizeof(szFileSpec)); AstralDlgEnd(hDlg, FALSE|2); break; default: return( FALSE ); } break; default: return( FALSE ); } return( TRUE ); }
BOOL HandleCommandLine( /***********************************************************************/ HWND hWindow, LPSTR lpszCmdLine, LPINT lpPrint) { FNAME szFileName; LPSTR lp; BOOL bPassedByClient, bGotImage; LPIMAGE lpImageDoc; HWND hWnd; int i; bPaintAppActive = TRUE; *lpPrint = NO; if ( !lpszCmdLine ) { // If no command line, bring up an empty image SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L ); if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) ) ShowWindow( hWnd, SW_SHOW ); return( TRUE ); } // Check if we have "[/ | -]embedding" and a possible filename. // usage: PP ["[-/]embedding"] file1 file2 ... // See if the command line is being passed by a client bPassedByClient = NO; if ( (lp = lstrfind( lpszCmdLine, "embedding" )) && (lp == lpszCmdLine || lp == (lpszCmdLine+1)) ) { // Command line passed by a client bPassedByClient = YES; lpszCmdLine = SkipSpaces( lp + 9 ); // skip over "embedding" } bGotImage = NO; while ( *lpszCmdLine ) { // Process any files and switches on the command line // Skip white space and see if we're done... lpszCmdLine = SkipSpaces( lpszCmdLine ); if ( !(*lpszCmdLine ) ) break; // If NULL get out // Check for any switches preceeding the file name: only /p for now while ( *lpszCmdLine == '/' ) { // a switch... lpszCmdLine++; // Skip over the slash if ( !*lpszCmdLine ) break; // If NULL get out if ( *lpszCmdLine == 'p' || *lpszCmdLine == 'P' ) *lpPrint = YES; lpszCmdLine++; // Skip the option character lpszCmdLine = SkipSpaces( lpszCmdLine ); } // Skip white space and see if we're done... lpszCmdLine = SkipSpaces( lpszCmdLine ); if ( !(*lpszCmdLine ) ) break; // If NULL get out // Try to zap the space after a single file name if ( (lp = lstrfind( lpszCmdLine, " " )) ) *lp = '\0'; // If we found a space, zap it // Copy the full path name into szFileName #ifdef _MAC lstrcpy( szFileName, lpszCmdLine ); #else if ( lstrchr( lpszCmdLine, '\\' ) ) lstrcpy( szFileName, lpszCmdLine ); else { // If not a full path name... GetCurrentDir( szFileName, sizeof(FNAME) ); FixPath( szFileName ); lstrcat( szFileName, lpszCmdLine ); } #endif // Now we're done with lpszCmdLine, so set it up for the next loop if ( lp ) // If we had found a space, there might be more file names lpszCmdLine = lp + 1; else lpszCmdLine += lstrlen(lpszCmdLine); // Point to nothing // Special handling of documents passed by a client ////if ( bPassedByClient ) //// { // Loop through documents to see if it's already open for ( i=0; i<NumDocs(); i++ ) { hWnd = GetDoc(i); if ( !(lpImageDoc = (LPIMAGE)GetWindowLong( hWnd, GWL_IMAGEPTR ))) continue; if ( !StringsEqual( lpImageDoc->CurFile, szFileName ) ) continue; // It's already open.... SendMessage( hClientAstral, WM_MDIACTIVATE, (WPARAM)hWnd, 0L ); if ( bPassedByClient ) lpImageDoc->fOwnedByClient = YES; szFileName[0] = '\0'; // Zap it bGotImage = YES; break; } //// } // If we have a file name, open it... if ( *szFileName ) { if ( AstralImageLoad( NULL, szFileName, MAYBE, YES ) ) bGotImage = YES; } // If the printing option was passed, print it and close it if ( *lpPrint && lpImage ) { SendMessage(hWndAstral, WM_COMMAND, IDM_PRINT, 0L ); CloseImage( NO, NULL ); } } if ( !bGotImage ) { if ( !idCurrentRoom ) { GoRoom (hInstAstral, -1, FALSE); return( FALSE ); } // If no image was opened via the command line, go to the opening screen SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L ); } if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) ) ShowWindow( hWnd, SW_SHOW ); return( TRUE ); }