|
|
Sorry for the late of reply, actually I did include #include <iostream>, I forgot to convert the tag to the literal string, so the browser always treat the opening tag as html code. Ok but my problem has been solved when I changed the setting, Project > properties > C/C++ > Runtime Library > Multi-threaded Debug DLL (/MDd) . Does anybody knows why is it so ? I am using Visual Studio 2005 professional,
|
|
|
|
|
Hi I need to manage a progressBar into MyThread class(CWinThread derived) using a timer but I can use the ON_WM_TIMER Event message.
How can I do it? Using the SetTimer function but how?
Thanks
|
|
|
|
|
CDRAIN wrote: How can I do it? Using the SetTimer function but how?
They hide that information in the Documentation[^]
led mike
|
|
|
|
|
Sorry, I made an error on the description of my problem:
I can't use the ON_WM_TIMER message because my class MyThread isn't derived from the CWnd but from the CWinThread.
How can I do this?
|
|
|
|
|
CDRAIN wrote: Hi I need to manage a progressBar into MyThread class(CWinThread derived)...
Does the progress bar belong to a different thread than the one you are creating?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, the progress bar belong to the MainThread of my Application, and I need to manage it from my thread.
|
|
|
|
|
CDRAIN wrote: Yes, the progress bar belong to the MainThread of my Application, and I need to manage it from my thread.
Which is a sure-fire recipe for disaster.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
CDRAIN wrote: the progress bar belong to the MainThread of my Application, and I need to manage it from my thread.
in your first post you said
CDRAIN wrote: I need to manage a progressBar into MyThread class
I have no idea what to believe at this point. If your progress bar is in the main thread you DO NOT need to manage it from the worker thread. Instead you do something like this:
Progress Information Object
CWnd in main thread (Progress Bar or Window) has a reference to the Progress Information Object
CWinThread worker thread has a reference to the Progress Information Object and continuously updates the object to reflect the work in progress.
ProgressBar or Window sets a timer and on the timer event reads the progress information from the shared Progress Information Object and updates the ProgressBar state.
led mike
|
|
|
|
|
I developed a log parser in plain C in VS 2005. The essential for the parser is to take in buffer as much data for the processing as possible. I read file as a binary by using low level function “_read”. I discovered that the optimal size of the buffer is 100 kb. I need actually buffer approximately of 500kb. However when I increase the buffer’s size the processing time increases. It happens according to profile because the reading time increases. I would expect that reading larger portion of data should reduce reading time, but got opposite results. I assume it can depend on some compiler settings, but couldn’t find anything. I would appreciate any help in this matter.
Yefim
|
|
|
|
|
Hmm I don't know what I'm missing but reading 5 times as many bytes could take 5 times as long...
Are you accessing the file sequentially or randomly?
What flags are you specifying in the _open() call?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark thanks for fast respond.
I’m accessing this file sequently and here is the opening and reading part
iFin = _open(szSourceFile, _O_BINARY|_O_RDONLY);
szBufRead = 100000;
iGet=_read(iFin,szBufRead,iReadData);
Thanks again Yefim
|
|
|
|
|
Try _O_BINARY|_O_RDONLY|_O_SEQUENTIAL.
Internally, the CRT uses the Windows CreateFile() API to open the file when you call _open().
_O_SEQUENTIAL causes the FILE_FLAG_SEQUENTIAL_SCAN flag to be added to the dwFlagsAndAttributes
parameter passed to ::CreateFile(). Whether the system actually uses this flag, I don't know
That's the only place I can see to possibly optimize buffering, aside from disabling all system
buffering and handling it yourself.
Are you sure it's not just a matter of reading 5 times as many bytes at a time from a relatively
slow device?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The strcpy below throw 'Access Violation'. Can anybody show me how to do it correctly? Thanks.
char **pArrayLabel = NULL;
int size=12;
pArrayLabel = new char*[size];
CString szLabel0 = "Januari";
strcpy(pArrayLabel[0],(char *)szLabel0.GetBuffer(szLabel0.GetLength()));
|
|
|
|
|
You're copying into an uninitialized pointer. You need to allocate a char buffer for each of the 12 char* s
|
|
|
|
|
I would do this:
char *pArrayLabel = NULL;
int size=12;
pArrayLabel = new char[size];
CString szLabel0 = "Januari";
strcpy(pArrayLabel,(char *)szLabel0.GetBuffer(szLabel0.GetLength()));
And when you pass it to the other function, pass it as "&pArrayLabel"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
once again, somebody is using CString::GetBuffer() when it's definitely not needed.
Call GetBuffer() only if you need to modify the CString object directly by writing inside its internal buffer. and this call to GetBuffer() requires a call to ReleaseBuffer() (which you don't do here).
if you only need to get the string contained within the CString, then you must use the cast operator (LPCTSTR) and that's it.
and for your problem, as that's been stated, you're assigning a NULL pointer.
modify your code into this.
ans at last, as i'm on it, please be careful with your variables names (generally, a variable starting with sz or psz is declared being a C-Style string)
const int iSize = 12;
TCHAR *pArrayLabel = ::new TCHAR[iSize];
CString strLabel = _T("Januari");
::_tcscpy_s(pArrayLabel[0], (LPCTSTR)szLabel0);
|
|
|
|
|
toxcct wrote: once again, somebody is using CString::GetBuffer() when it's definitely not needed.
Yeah, they should charge a toll $$$ to use CString::GetBuffer() and
CWnd::PreTranslateMessage() to help people consider alternative solutions
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The (LPCTSTR) cast is superfluous there too, because the compiler will automatically call it when it sees that the _tcscpy() parameter is an LPCTSTR .
|
|
|
|
|
You already got enough information from other replies.
If you are using visual studio 2005, consider using secured version of these CRT function.
Refer Security enhancement to CRT[^].
Prasad
MS MVP - VC++
|
|
|
|
|
Hi,
Pls help anyone know how to control the brightness of avi. file??
Thanks in advance.
|
|
|
|
|
I dont know my answer wasnt enough or you like to ask again!
|
|
|
|
|
can anyone correct for me this:
CString strText;
CString strSQL;
CDaoDatabase db;
db.Open("D:\\copyktt.mdb");
m_cedit.GetWindowText(strText);
strSQL.Format("INSERT INTO Table6 SELECT * FROM Table3 IN 'C:\\ktt.mdb' WHERE MyField = %s",strText);
db.Execute(strSQL);
|
|
|
|
|
Not without specific error messages, but it looks like you are missing VALUES in your insert text... You need to also be sure that the DB you are connecting to can handle a subquery in the syntax you use.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I think if you read an article (read,write Access file) that I think I answered to you that link its better.
After read values of first database /*select * from Table3 that I dont think its good statement you must use Select with a Where maybe you have 200,000 records */ you can use like this code for example
CDaoDatabase database;
CDaoRecordset recordset(&database);
CString lpszFile = "d:\\copyktt.mdb";
database.Create(lpszFile);
CString lpszSQL = "CREATE TABLE MYTable
(Field1 VARCHAR(4),Field2 VARCHAR(4),Field3 VARCHAR(4),Field4 VARCHAR(4),MarketState VARCHAR(4))";
database.Execute(lpszSQL);
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM MyTable",0);
database.Execute("INSERT INTO MyTable values('1','2','3','a','b')");
recordset.AddNew();
recordset.Update();
|
|
|
|