|
useless!
fgets() compiled under cygwin interprets it as usual string!
9ine
|
|
|
|
|
I am getting an assert occasionally in the following
void CFile::Write(const void* lpBuf, UINT nCount)
{
ASSERT_VALID(this);
ASSERT(m_hFile != (UINT)hFileNull);
Basically This call is from another thread (worker thread)(thread B) to write to a file and this thread does not initially create the File Object . The file object is created by the main thread (thread A ).
The above assertion happens when B tries to write to the file after A has created the file .
I have tried to put a critical section where the common function to write to the file is called but still I see the assert .
Could this be because of my thread not being able to access MFC cFile Object correctly
Also this happens occasionally 2out of 10 times .
I also see that the file is finally getting written with contents for both thread A and B but this ASSERT is worrying me .
Any ideas ?
Engineering is the effort !
|
|
|
|
|
act_x wrote: I also see that the file is finally getting written with contents for both thread A and B...
If the possibility exists that both threads are wanting to access the file, I think you might need to wrap the read/write calls in a critical section (i.e., CCriticalSection ).
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
It's likely that thread A had not yet actually opened the file, or at least assigned m_hFile to the file handle, before thread B runs. Since there is an OS call, it is very likely the open operation is triggering a sleep operation which, in turn, is causing thread B to run if it has been created by that point.
I suggest not creating thread B until thread A has opened the file. An alternative is to have thread B wait on an event that will be signalled once thread A has opened the file.
A critical section should be used for read/write/close operations, but are a potential problem here since thread B could get it's time slice before thread A even enters its critical section to open the file.
Another option to look at is for thread B to open and close the file.
Also note that when you close the file, thread B must either be terminated (wait on it's handle, then close the file) or should check if the file handle is valid before performing the operation.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I will change an the content of a node in a XML-File. It is no problem, to get the specific node and its content. But to change the content of the Node I have to use the function "InsertData" from the class IXMLDOMText. Therefor I have to initialize the IXMLDOMTextPtr. But every time I try this, I get the error message, that the left part of ->"Query Interface" has to point to a class... So what's wrong with that?
Below the pasted code to make it a little bit more understandable.
Thanks, Hanno
CString fileName;
CFileFind find;
BOOL findFile;
IXMLDOMDocument m_iDocPtr;
IXMLDOMNodePtr m_iNodePtr;
IXMLDOMTextPtr m_iTextPtr;
findFile = (find.FindFile(strPath+"\\"+"*.xml",0));
while(findFile != 0) {
fileName = find.GetFilePath();
m_iDocPtr->Load((_bstr_t)fileName);
m_iFr = m_iDocPtr->createDocumentFragment();
m_iNodePtr = m_iDocPtr->selectSingleNode("//HI");
m_iNodePtr = m_iNodePtr->selectSingleNode("//Hello");
_bstr_t hello= m_iNodePtr->text;
if (atoi(hello) == 0) {
m_iTextPtr = m_iDocPtr->createTextNode("something");
m_iTextPtr->insertData(2,"something");
}
}
|
|
|
|
|
I'm looking for some clarity here. I register two MultiDocTemplates. The only important difference between the two templates is different views.
I don't want the initial dialog that asks me to pick a template before the main window is displayed. I have an initial view already set to run.
Here's some code from my InitInstance()
// InitInstance()
m_pDocTemplate = new CMultiDocTemplate(
IDR_2DVIEW,
RUNTIME_CLASS(CCdataMFCdisplayDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(C2DView));
AddDocTemplate(m_pDocTemplate);
m_pDocTemplate = new CMultiDocTemplate(
IDR_OPENGL_VIEW,
RUNTIME_CLASS(CCdataMFCdisplayDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(COpenGLView));
AddDocTemplate(m_pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
// Make a starter document
NewDocument();
// Create a default View
CChildFrame *pFrame = new CChildFrame();
CCreateContext context;
CCdataMFCdisplayView *pview = NULL;
context.m_pCurrentDoc = theApp.GetDocument();
context.m_pNewViewClass = RUNTIME_CLASS(C2DView);
context.m_pNewDocTemplate = theApp.m_pDocTemplate;
context.m_pLastView = NULL;
context.m_pCurrentFrame = ((CMainFrame*)AfxGetMainWnd())->GetActiveFrame();
if (pFrame->LoadFrame(IDR_2DVIEW,WS_CHILD | WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE | WS_VISIBLE, theApp.m_pMainWnd, &context))
pFrame->InitialUpdateFrame((CMyDoc*)theApp.GetDocument(),TRUE);
// nothing pertinent follows
|
|
|
|
|
I found my answer. For those interested parties, I have to handle the ON_FILE_NEW message.
|
|
|
|
|
hi,
i want to make a login application(like windows login) that blocks all other processes/windows including the task manager. the application should be a simple dialog
can anyone help plz?
thanks
|
|
|
|
|
The DS_SYSMODAL style, which was for 16-bit Windows, has been "replaced" with the WS_EX_TOPMOST style.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I would want to load an image from a fixed path. This image changes every time, so I thought not include it like as a static resource. any idea?
Bye Daniel
|
|
|
|
|
LoadImage//For Load File
CImage //Class For Load File
|
|
|
|
|
thanks for the answer!!
But how can show it now ?
bye
|
|
|
|
|
Your question is a bit unclear. Are you wanting to load a .bmp file from disk at runtime, or are you wanting to embed a .bmp file in your application at compile time?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Ya !!
I'll try to explane the problem! I have two application:
- the first saves a .bmp, overwriting hold file, into a directory every about
5min, the image comes from a camera.
- the second must shows that image (something like a "refresh") pushing a button.
I tried but the image loaded doesn't change.
Can you halp me with a council?
thanks !!
|
|
|
|
|
Put a static control on your window/dialog, and associate a CStatic member variable with it using ClassWizard. Use SetTimer() to create a timer event every 300000ms (five minutes). In the event handler for the timer, call LoadImage() to load the .bmp file from disk. Using the returned handle, then call CStatic::SetBitmap() to associate the new bitmap with the static control. Make sense?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
GREAT !!!
Now the application work perfectly !!
thanks for ALL DAVID!!
bye
|
|
|
|
|
hi all
i had made the class in VC++.NET which contain the API's now i want to use
this class in the C#.NET how to do that whether make the cllas library(DLL) of that class and
then use of simple only use the class.
i had not used those api's in the C# bcos it is difficult to get the help of
those api.
ddd
|
|
|
|
|
Hi!
is it possible, to make a castType from _bstr_t to "int"?
Thanks, hanno
|
|
|
|
|
Can't you just use atoi() ?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Don't know what you like to achieve, but if you are up to put a integer value into a string a type cast is the wrong way. Use atoi() to convert character arrays to integers.
Hope this helped you out.
Walter
|
|
|
|
|
Yes, that did it! Thanks.
|
|
|
|
|
I just know sub window need ID to call some function.
does the main window need a ID? and where does the ID come to play?
|
|
|
|
|
What exactly are you asking here?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Is IDR_MAINFRAME represented main window? does operation on main window need the parameter IDR_MAINFRAME?
|
|
|
|
|
derek7 wrote:
Is IDR_MAINFRAME represented main window?
Main window of what?
derek7 wrote: does operation on main window need the parameter IDR_MAINFRAME?
What operation?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|