|
Hi guys!
I'd like to have MFC displaying an "OPEN FILE"-dialog with a filter for multiple file extensions, like:
"Images (*.bmp,*,pcx,*,jpg)"
and MFC should regard these as ONE document type
(i care about the different loading procedures myself ... after loading i just use the picture information an regard this as my "document type").
Is there any way to achieve this???????????
I know about the string in the string-table-resource specifying the file extension. But i didn't succeed in stating more then one. By the way, when using the W32-"GetOpenFileName" procedure, multiple extensions are possible.
Big THANKS for any help in advance!
nice greetings from Europe
Thomas (tombarthel@gmx.net)
|
|
|
|
|
See if you can make this fit in your app:
//-----------------------------------------------------------------------------/
BOOL CMyApp::DoFindFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags,
BOOL bOpenFileDialog, CDocTemplate* pTemplate)
{
CFileDialog dlgFile(bOpenFileDialog);
CString title;
VERIFY(title.LoadString(nIDSTitle));
dlgFile.m_ofn.Flags |= lFlags;
CString strFilter;
CString strDefault;
strFilter.Empty();
strDefault.Empty();
if (pTemplate != NULL)
{
ASSERT_VALID(pTemplate);
AppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, &strDefault);
}
strFilter += CString("My Files (*.vis)\0*.vis\0");
dlgFile.m_ofn.nMaxCustFilter++;
strFilter += CString("Your Files (*.bvd)\0*.bvd\0");
dlgFile.m_ofn.nMaxCustFilter++;
strFilter += CString("Their Files (*.dpw)\0*.dpw\0");
dlgFile.m_ofn.nMaxCustFilter++;
strFilter += CString("Nobody's Files (*.fac)\0*.fac\0");
dlgFile.m_ofn.nMaxCustFilter++;
dlgFile.m_ofn.lpstrFilter = strFilter;
dlgFile.m_ofn.hwndOwner = AfxGetMainWnd()->GetSafeHwnd();
dlgFile.m_ofn.lpstrTitle = title;
dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH);
fileName.ReleaseBuffer();
CString InitialDir = "C:\Program Files\";
int strlen = InitialDir.GetLength();
InitialDir.GetBufferSetLength(strlen-1);
InitialDir.ReleaseBuffer();
dlgFile.m_ofn.lpstrInitialDir = (const char *)InitialDir;
switch (nIDSTitle)
{
case AFX_IDS_OPENFILE :
dlgFile.m_ofn.lpstrTitle = "Open File";
break;
case AFX_IDS_SAVEFILE :
case AFX_IDS_SAVEFILECOPY :
dlgFile.m_ofn.lpstrTitle = "Save File";
break;
}
BOOL bSelected = FALSE;
BOOL status = dlgFile.DoModal();
switch (status)
{
case IDCANCEL :
break;
case IDOK :
{
bSelected = TRUE;
// handle the selected filename here
}
break;
default :
break;
}
return bSelected;
}
//-----------------------------------------------------------------------------/
void CMyApp::AppendFilterSuffix(CString& filter, OPENFILENAME& ofn,
CDocTemplate* pTemplate, CString* pstrDefaultExt)
{
ASSERT_VALID(pTemplate);
ASSERT(pTemplate->IsKindOf(RUNTIME_CLASS(CDocTemplate)));
CString strFilterExt, strFilterName;
if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) && !strFilterExt.IsEmpty() &&
pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) && !strFilterName.IsEmpty())
{
// a file based document template - add to filter list
ASSERT(strFilterExt[0] == '.');
if (pstrDefaultExt != NULL)
{
// set the default extension
*pstrDefaultExt = ((const char*)strFilterExt) + 1; // skip the '.'
ofn.lpstrDefExt = (LPSTR)(const char*)(*pstrDefaultExt);
ofn.nFilterIndex = ofn.nMaxCustFilter + 1;
}
// add to filter
filter += strFilterName;
ASSERT(!filter.IsEmpty()); // must have a file type name
filter += (char)'\0'; // next string please
filter += "*" + strFilterExt;
filter += (char)'\0'; // next string please
ofn.nMaxCustFilter++;
}
}
|
|
|
|
|
Out of several hundred installations, we have three customers getting this vague SQL error in a VC++ app.
When doing an ODBC trace it logs the following error when attempting to query an MS Access DB table record:
CTL ffe5d93b:ffe5db2b EXIT SQLExecute with return code -1 (SQL_ERROR)
HSTMT 0x008fe7a4
DIAG [22005] [Microsoft][ODBC Microsoft Access Driver] Internal OLE Automation error (-3030)
I know what the 22005 SQLSTATE refers to (Error in assignment) but the record it is trying to read can be read fine on hundreds of other installations. I haven't found any reference to the -3030 number. Can anyone shed some light on this for me?
|
|
|
|
|
I have problem of getting the mouse position!!!! I want to know how to get the mouse position when user move their mouse to anywhere, but not just inside my program!!!!
Anyone can help me???
|
|
|
|
|
Hi Sunny,
You may try with SetCapture(HWND) which directs mouse input to the specified window, but there are many actions the user may take that cause your application to loose the mouse capture (i.e. click on a menu). You could handle WM_CAPTURECHANGED messages, but even that wouldn't help much (refer to MSDN for details). Also, you should call ReleaseCapture() when you've finished using mouse input.
If you need mouse input to do short operations, this could be fine, otherwise you may install a hook with SetWindowsHookEx() (refer to MSDN to know how to use hooks).
Hope this helps,
Paolo.
|
|
|
|
|
HI,
This one may have been asked many times in the past. But
we all know how MS Word paints that squiggle line under misspelled words. We have a requirement to do the same. So how would go about it using CRichEdit?
I've seen some code where this was attempted in the OnPaint
method, this messed up Win2K however.
Any tips welcomed
Thanks.
|
|
|
|
|
When a listen server wants toaccept a connection, how do I make the new connection happen on a specific port?
I've tried using Bind() and Create() to set the port, but the Accept() function insists on setting the port itself.
Any help?
|
|
|
|
|
Hello,
can anyone tell me how to access a vc++ 6 function from vb 6 with maybe some example code or a good website ?
I looked through deja.com but found nothing good.
I am a newbie to the component stuff.
Thanx a lot.
|
|
|
|
|
Hi,
When I call GetAmbientUserMode( BOOL& bUserMode ) method of the CComControl class in my ATL class, the HRESULT is failure all the time..
And the value retrieved in bUserMode is always negative.
I called GetAmbientUserMode() in my ATL class constructor.
Why is this happening??
Thanx in Advance,
Aruna.
|
|
|
|
|
Hi,
When I call GetAmbientUserMode( BOOL& bUserMode ) method of the CComControl class in my ATL class, the HRESULT is failure all the time..
And the value retrieved in bUserMode is always negative.
I called GetAmbientUserMode() in my ATL class constructor.
Why is this happening??
Thanx in Advance,
Aruna.
|
|
|
|
|
Hello, codegurus around the world.
I posted the sample code of SDIDevStudio with ADO + DataGrid to
www.codeproject.com. But, my code post isn't shown up yet there (8/21 9:16 PM).
So, I uploaded the doucmentation, demo.zip and code.zip to my home page.
URL is http://pages.prodigy.net/masaaki
If you have questions, please post here.
Please, don't send me email about the questions.
Now, I'm looking for a full time VC++ developer job.
Regards.
-Masaaki Onishi-
|
|
|
|
|
Hello, codegurus around the world.
As Mr. Chris, the web master pointed out,
I need to ask the permission of the use of CJLibary
and SDIDevStudio sample code.
So, for a while, please enjoy my ugly image, and
my documentation without my code and demo.
Regards.
-Masaaki Onishi-
|
|
|
|
|
I have a class derived from CFileDialog. I am attempting to change the text on the "Save" button but have a strange problem. I do it the way I have always used for "Open" dialogs:
In OnInitDialog i do the following.
CWnd * wndCtrl = GetParent()->GetDlgItem(IDOK);
wndCtrl->SetWindowText("&Create");
Strange thing is, it works for the "Open" flavor of a CFileDialog but not the "Save". I definitely have the right control, I can change button's size for example, just not the text. Seems like maybe the text gets changed AFTER init dialog.
Any ideas???
|
|
|
|
|
can somebody point me in the right direction? i've been assigned to do an non-MFC ATL control that requires the use of the common Save As... dialog. i know it's easy to do with MFC, but like i said.. this is a non-MFC app.
any hints would be appreciated.
-c
|
|
|
|
|
Use the GetSaveFileName() API.
|
|
|
|
|
Here is a snippet of code where I am doing this
OPENFILENAME OpenFileName;
TCHAR szFile[MAX_PATH] = "\0";
strcpy( szFile, "");
// Fill in the OPENFILENAME structure to support a template
// and hook.
OpenFileName.lStructSize = sizeof(OPENFILENAME);
OpenFileName.hwndOwner = NULL;
OpenFileName.hInstance = NULL;
OpenFileName.lpstrFilter = "Data Files\0*.DAT\0";
OpenFileName.lpstrCustomFilter = NULL;
OpenFileName.nMaxCustFilter = 0;
OpenFileName.nFilterIndex = 0;
OpenFileName.lpstrFile = szFile;
OpenFileName.nMaxFile = sizeof(szFile);
OpenFileName.lpstrFileTitle = NULL;
OpenFileName.nMaxFileTitle = 0;
OpenFileName.lpstrInitialDir = "C:\\YourPath";
OpenFileName.lpstrTitle = "Select A File";
OpenFileName.nFileOffset = 0;
OpenFileName.nFileExtension = 0;
OpenFileName.lpstrDefExt = NULL;
OpenFileName.lCustData = NULL;
OpenFileName.lpfnHook = NULL;
OpenFileName.lpTemplateName = NULL;
OpenFileName.Flags = OFN_EXPLORER ;
// Call the common dialog function.
if (GetOpenFileName(&OpenFileName))
{
strcpy(chFileName,(LPCTSTR)OpenFileName.lpstrFile);
}
|
|
|
|
|
Hi All;
I am a rookie programmer with very limited VC++ experience, all my previous programming experience has been with VB or C++ 3.0 . Currently I am debugging a VC++ database application that connects via ODBC to a dB, but I am having trouble with this connection, the dialog box would not populate with the information from the DB. Is there anybody who's willing to give me hand with this proyect?
Tito
|
|
|
|
|
Hi every body,
Here's an example in Visual Basic to write directly code in VB code window
Dim lngStartLine As Long
Dim lngStartCol As Long
Dim lngEndLine As Long
Dim lngEndCol As Long
' determine current location in code window
VBInstance.ActiveCodePane.CodeModule.CodePane.GetSelection lngStartLine, lngStartCol, lngEndLine, lngEndCol
' insert ADO code at current position
VBInstance.ActiveCodePane.CodeModule.InsertLines lngStartLine, GenADOCode
.........
.........
I want to realize the same operation in Visual C++ 6.0 IDE
Can anybody help me ?
Thanks in advance
Excuse me for my poor english
|
|
|
|
|
Hi all,
i have problem with function
CHttpConnection::OpenRequest,
when i call this function with URL that is longer than 2048 char (one TCP/IP packet) the function crush down. Is the URL smaller everything work well!
My question: Is there any limit to URL size? How i solve this problem? Is there any other possibility?
Example:
URL: executeSQL?Datbase=....&User=... (more than 2048 char).
Thanks
Peter
|
|
|
|
|
HOw Can I add one animated icon(*.ani)into the resource of my project and show it in one dialog?
|
|
|
|
|
Hi,
If you want to use it as a cursor, I think you may add it to the resources just as any other cursor and use it like a 'static' cursor.
Otherwise, you may try to draw the animation yourself:
- install a timer with SetTimer()
- handle WM_TIMER messages and draw each frame with DrawIconEx() (istepIfAniCur is the frame index)
Good luck!
Paolo.
|
|
|
|
|
Can someone help me to solve this problem?
The flexGrid only accepts 999999 rows and not
any more. I tried to use the DBGrid and DataGrid which i
think can hold unlimited records but i did not manage to
pass my strings into the DBGrid.
If anyone can help me!
|
|
|
|
|
Hi everyone,
I need help with converting Text Files into Access table and hope you can help me out.
I have 2 TEXT FILES, first that contains the table name, and its attribues, and the SECOND file contains the values of the table.
So if the first TEXT FILE that has the following table values:
tablename
field1, integer
field2, string
field3, integer
field4, string
then another TEXT FILE will contains the values for the table:
1, john, 6, smith
2, steve, 7, clark
3, carrie, 8, wayne
4, dan, 9, chait
5, erin, 10, alan
what i need to do is to read the values from the FIRST TEXT FILE that contains the table attributes and create the table.
Then i need to read the SECOND TEXT FILE and plug in the values. so at the end, i'll have a Access table like:
field1 field2 field3 field4
1 john 6 smith
2 steve 7 clark
3 carrie 8 wayne
4 dan 9 chait
5 erin 10 alan
But i need the readings of BOTH TEXT FILES to be dynamic so it'll work if the TEXT FILE has x number of columns, and x number of rows.
and i also need the reading to be dynamic so it can read the values from the SECOND TEXT FILE no matter what kind of values it contains, ie, integer, string, char, etc...
If anyone can help me out, Please let me know.
Thanks in Advance.
Steve
|
|
|
|
|
Here is some code to read the files ... I don't know
anything about creating the access database though.
first in your header file, add the member function :
void get_field(void);
add to the top of your .CPP file :
#include <fstream.h>
Add the following to the top of your .CPP file (or add as
member variables in your .H file) :
#define MAX_CHAR 80 // maximum number of characters per input line
char field[MAX_CHAR];
char tmp[MAX_CHAR];
int start;
#define MAX_FIELDS 20 // maximum number of fields
int numFields;
CString tableName;
CString fieldName[MAX_FIELDS];
int fieldCode[MAX_FIELDS];
Here is the code to read the first file, and determine the number of
fields and the type of each field :
ifstream infile;
infile.open("test1.txt");
numFields = 0;
infile.getline(tmp,MAX_CHAR);
start = 0;
get_field();
tableName = field;
while (!infile.eof())
{
infile.getline(tmp,MAX_CHAR);
if (infile.eof()) break;
start = 0;
get_field();
fieldName[numFields] = field;
get_field();
CString fieldType;
fieldType = field;
fieldType.MakeLower();
fieldType.TrimLeft();
fieldType.TrimRight();
if (fieldType == "integer") fieldCode[numFields] = 0;
if (fieldType == "float") fieldCode[numFields] = 1;
if (fieldType == "string") fieldCode[numFields] = 2;
numFields++;
}
infile.close();
Here is the code to read the second file, and determines the value of
each field for each record. Write out to a third file to make sure
that everything is correct :
infile.open("test2.txt");
ofstream outfile;
outfile.open("test3.txt");
int num_records = 0;
while (!infile.eof())
{
infile.getline(tmp,MAX_CHAR);
if (infile.eof()) break;
outfile << "record number : " << num_records << "\n";
start = 0;
for (int i=0; i<numFields; i++)
{
get_field();
CString field_string;
field_string = field;
float value_float;
int value_int;
CString value_cstring;
if (fieldCode[i] == 0)
{
value_int = atoi(field_string);
outfile << " " << fieldName[i] << " : " << value_int << "\n";
}
if (fieldCode[i] == 1)
{
value_float = (float)atof(field_string);
outfile << " " << fieldName[i] << " : " << value_float << "\n";
}
if (fieldCode[i] == 2)
{
value_cstring = field_string;
outfile << " " << fieldName[i] << " : " << value_cstring << "\n";
}
}
num_records++;
}
infile.close();
outfile.close();
And finally, the helper function, get_field() :
void YOUR_CLASS::get_field()
{
int i;
for (i=0; i<MAX_CHAR; i++) field[i] = NULL;
int n = 0;
int s = start;
for (i=s; i<MAX_CHAR; i++)
{
if (tmp[i] == ',') break;
field[n] = tmp[i];
n++;
start++;
}
start++;
}
Note : make sure there is not a blank line at the
end of each file. This code does not look for one.
|
|
|
|
|
|