|
From the SDK: 'FILECORE.CPP'
BOOL CFile::Open(LPCTSTR lpszFileName, UINT nOpenFlags,
CFileException* pException)
{
ASSERT_VALID(this);
ASSERT(AfxIsValidString(lpszFileName));
ASSERT(pException == NULL ||
AfxIsValidAddress(pException, sizeof(CFileException)));
ASSERT((nOpenFlags & typeText) == 0); // text mode not supported
// CFile objects are always binary and CreateFile does not need flag
nOpenFlags &= ~(UINT)typeBinary;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Okay. That helps a lot.
Thanks,
ns
|
|
|
|
|
Does anyone have any info on the Excel file format? I have large datasets Ineed to output to Excel, but when using ODBC or the CSpreadSheet class (I think this uses ODBC also), my sql statements get too big for a CString... Anyway, is there a better/faster way for Excel IO? Any input is appreciated (as always).
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Searched CP before posting ?
Excel generator[^]
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
StephaneRodriguez wrote:
Searched CP before posting ?
Um...
Thanks Stephane
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Have you looked at DTS at all? It can output to Excel without you having to write a bunch of code. You can load DTS packages in your EXE and run them from there, since DTS is really just a collection of COM objects.
If that is too much of a burden, or your data doesn't already exist in some other database for easy export, then take a look at the MSDN sample COMEXCEL. It shows how to use the Excel.Application.8 COM object, which gives you direct access to Excel and all its glory. Okay, maybe not all, but a bunch of stuff. You can create new workbooks, spreadsheets, data ranges, etc. and you can write out all of your data. Just note in this case, you'd need to have Excel installed on the same machine where your code will run.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
According to MSDN for CString GetPAthNAme() :
If m_ofn.Flags has the OFN_ALLOWMULTISELECT flag set, this string contains a sequence of null-teminated strings, with the first string being the directory path of the file group selected, followed by the names of all files selected by the user.
Now if I assign the result of calling GetPathName(), the CString I assign it to only reads in upto the first null. So how to I get a hold of the complete list of files returned by getPAthNAme()?
CString a = dlg1.GetPAthName(); and its multiselect....
Thanks,
ns
|
|
|
|
|
Use GetStartPosition() and GetNextPathName() to iterate thru the list of names.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Read about:
GetStartPosition and GetNextPathName
hint: u get a position from the first, u put it into the other!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
You have to use GetStartPosition() and GetNextPathName() to iterate through the list of files.
If a train station is where the train stops, what's a workstation...?
|
|
|
|
|
I got misled by MSDN (my fault)....thanks for pointing me in the right direction...
Thanks,
ns
|
|
|
|
|
i need to show text in my status bar to show a process working and what is happening.
the problem is i have no idle time to update the status bar.
how can i update the status bar without stopping my code?. (or can i?)
|
|
|
|
|
If you have no time to update your status bar, you have a more underlying problem with cpu usage. your app is going to be totally unresponsive. If someone obscures it with another window, and then hides that window, your app is not going to redraw.
This creates a poor user experience and they'll think your app has crashed.
Consider putting your intensive code in a worker thread, and leave the main thread free to pump messages, and update the UI.
Signature space for rent. Apply by email to....
|
|
|
|
|
my program imports or scans images and preforms icr on the image and archives that image to a drive or cd.
i can also do all this in less that 1 sec.
my program does lots in little time. some scan session will scan over 5000 documents without crashes.
all i need to know if a statusbar can be forced to update.
|
|
|
|
|
In short, no, you can't update the status bar. To update the status bar, at the end of the day, involves sending a message to the status bar itself. There will be no cpu timeslice for that to happen if your one and only thread is blocked.
That is the perfect case for a worker thread. If your user was doing a batch of 5,000 documents each taking 1s, he's going to be waiting a long time. you need to give him a cancel button- and you can't handle the click of the button if your main thread is busy doing scanning.
someone else please back me up on this! or point me out if i'm wrong.
Signature space for rent. Apply by email to....
|
|
|
|
|
actually i have 2 threads. one for scanning or importing and the other for icr and saving.
as thread 1 scans the other processes the prev image (if still in the buffer).
i have a window for the scanner that pops up and there is a cancel button. it all works great the scanner will usally have to process the log that is ready to scan before it stops but i do not have any idle time to have the status bar update when ever.
|
|
|
|
|
Cant u do it from the working thread??
(but be sure to synchronize)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
if ( MFC )
if ( u have a CStatusBar object )
CStatusBar::SetPaneText
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi
Does anyone know how to make an open file dialog with different types of lpstrFilters. I think you have to do something with nFilterIndex...
tx
|
|
|
|
|
MSDN:
Filters
The information in this section applies to both Explorer-style and old style Open and Save As dialog boxes.
You can provide filename filters to assist the user in limiting the filenames that the dialog box displays. A filename filter consists of a pair of null-terminated strings, a description and a pattern, one concatenated to the other. The dialog box displays the description to let the user pick which filter to use; and it uses the pattern to select the files to display.
To specify the filters, set the lpstrFilter member of the OPENFILENAME structure to point to a buffer that contains an array of filter string pairs. The last string in the array must be followed by an extra null character.
A pattern string can be a combination of valid filename characters and the asterisk (*). The asterisk is a wildcard that represents any combination of valid filename characters. The dialog box displays only those files that match the pattern. To specify multiple patterns for the same description, you must use a semicolon (;) to separate the patterns. Note that space characters in the pattern string can produce unexpected results.
The following code fragment specifies two filters. The filter with the "Source" description has two patterns. If the user selects this filter, the dialog box displays only files that have the .C and .CXX extensions.
OPENFILENAME ofn; // common dialog box structure
ofn.lpstrFilter = "Source\0*.C;*.CXX\0All\0*.*\0"
ofn.nFilterIndex = 1;
The nFilterIndex member of the OPENFILENAME structure specifies an index that indicates which filter the dialog box initially uses. The first filter in the buffer has index 1, the second 2, and so on. If the user changes the filter while using the dialog box, the nFilterIndex member is set to the index of the selected filter on return.
You can create a custom filter by setting the lpstrCustomFilter member to the address of a buffer that contains a single filter, and by setting the nMaxCustFilter member to the size of the buffer, in characters or bytes. The dialog box always places the custom filter at the beginning of the list of filters and, on return, always updates the pattern part of the filter with the pattern from the filter selected by the user.
For Explorer-style dialog boxes, the default extension may change if the user selects a different filter. If the user selects a filter whose first pattern is of the form *.xxx (that is, the extension does not include a wildcard character), the dialog box uses xxx as the default extension. This occurs only if you specified a default extension in the lpstrDefExt member of the OPENFILENAME structure. For example, if the user selects the "Source\0*.C;*.CXX\0" filter, the default extension changes to "C". However, if you had defined the filter as "Source\0*.C*\0", the default extension would not change because the extension includes a wildcard.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
thanks a lot
|
|
|
|
|
Do we have to have a return within a catch block. If yes, and my execution goes into the catch below, will my function return a -1?
catch(CFileException e)
{
CString temp;
temp.Format("Error opening file : %d", e.m_cause);
AfxMessageBox(temp);
return -1;
}
Thanks,
ns
|
|
|
|
|
no, and yes.
-c
All you have to do is tell the people they are being attacked, and denounce the opposition for lack of patriotism and exposing the country to danger.
-- Herman Goering, on how to control the public
|
|
|
|
|
Thank you. SO with no return in the catch, the function just normally exits, if there are no statements after the catch, right?
Appreciate it,
ns
|
|
|
|
|
more specifically, execution will proceed into the catch, executing all statements there, then will proceed onto any statements aftern the catch. it doesn't necessarily exit - it just continues onto whatever comes next.
-c
All you have to do is tell the people they are being attacked, and denounce the opposition for lack of patriotism and exposing the country to danger.
-- Herman Goering, on how to control the public
|
|
|
|