Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing the String table - IDR_MAINFRAME

Status
Not open for further replies.

gjcsot

Programmer
Oct 16, 2002
9
GB
How do I add list items to the open file window using the
IDR_MAINFRAME String. At present it looks like this

Programme name\n\nProgramme\text Files (*.txt)
\n.txt\ntext\ntext Files

Which gives me a list containing:
text Files (*.txt)
All File (*.*)

I need to add more item (for example log file (*.log))

How do I do this?

Thanks for any help
 
You have to manipulate the dialog oject for that. It can't be done by editing the resource file.

Here's some code, directly copied from an app, so not all will be necessary for you:

CFileDialog dlg(TRUE, "jpg", NULL, OFN_ENABLESIZING, "Bitmap Image (*.bmp)|*.bmp|GIF File (*.gif)|*.gif|JPG File (*.jpg)|*.jpg||", (CWnd*)g_pMainWnd);
int nFilterIndex = g_pApp->GetProfileInt("Settings", "Default Extension", 1); //This is the most recently used filetype.
char pszTitle[30];
sprintf(pszTitle, "Select a picture for label %d:", nIndex);
dlg.m_ofn.lpstrTitle = pszTitle;
dlg.m_ofn.nFilterIndex = nFilterIndex; //Default to the most recently used filetype.
if(dlg.DoModal() != IDOK) return;

g_pApp->WriteProfileInt("Settings", "Default Extension", dlg.m_ofn.nFilterIndex);
CString sExt(dlg.GetFileExt());
sExt.MakeLower();
if(sExt != "jpg" && sExt != "gif" && sExt != "bmp") {
g_pMainWnd->MessageBox("Invalid file type !", NULL, MB_OK|MB_ICONSTOP);
return;
}

m_pPaper->SetLabelPicture(nIndex - 1, (LPCTSTR)dlg.GetPathName());
UpdateAllViews(NULL);




And here's something similar, in case you prefer to not work in MFC:

//Initialize OPENFILENAME structure:
pFile->lStructSize = sizeof(OPENFILENAME);
pFile->hwndOwner = hwdnOwner;
pFile->lpstrFile = pszFile;
pFile->nMaxFile = MAX_PATH;
pFile->lpstrFilter = "Executables (*.EXE)\0*.EXE\0";
pFile->nFilterIndex = 1;
pFile->lpstrTitle = pszTitle;
pFile->lpstrInitialDir = "C:\\";
pFile->lpstrCustomFilter = NULL;
pFile->nMaxCustFilter = 0;
pFile->lpstrFileTitle = NULL;
pFile->nMaxFileTitle = 0;
pFile->nFileOffset = 0;
pFile->nFileExtension = 0;
pFile->lpstrDefExt = NULL;
pFile->lCustData = 0;
pFile->lpfnHook = 0;
pFile->lpTemplateName = 0;
pFile->Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;

while(TRUE) {
if(!GetOpenFileName(pFile)) return FALSE;
if(_stricmp(&pszFile[pFile->nFileExtension], "exe") != 0)
MessageBox(hwdnOwner, "Please select an executable.", "Ignite:", MB_OK);
else break;
}

return TRUE;

Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top