|
Cyrilix wrote: I'm pretty sure this will write the characters to file in ASCII, won't it?
Yes. Sorry about that!
I tested your code and it writes binary fine. Reloading worked too, tested as follows:
...
for (int i = 0; i < numOrds; ++i)
{
ordX[i] = 0;
ordY[i] = 0;
}
ifstream instream("C:\\file.dat", ios::in);
instream.read((char*)ordX, sizeof(int) * numOrds);
instream.read((char*)ordY, sizeof(int) * numOrds);
instream.close();
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks a lot for giving this a try -- I guess it was just a matter of me using get() instead of read().
|
|
|
|
|
The software I am coding uses AfxThrowArchiveException(CArchive::none) to undo changes made by partially loading a document into the program. However, another afx message stating "Failed to open document." pops up and the operator has to again click OK on the dialog. Is there anyway to override this second message box from popping up?
|
|
|
|
|
You could override CDocument::ReportSaveLoadException() in your document class
and do something more appropriate (like not calling AfxMessageBox(), logging the
error, etc).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I know there are numerous articles on this topic, but I haven't found a solution to my problem.
From my GUI app I launch a stub process which is supposed to give me real time feedback on the output of a third console. Basically I set up the pipes and handles from the GUI, launch the stub which inturn modifies it's screen buffer and launches the real console. All the handles are inherited correctly, until I modify the memory of the real console.
I coded the stub to start the new process with the CREATE_SUSPENDED flag set, it also returns the ID's back to the GUI. From there I modify the memory and call ResumeThread(). But, for some reason, the STD_OUTPUT_HANDLE which it should have inherited from the stub has been lost. I have verified that the real console is indeed running, though it has no 'visible' screen buffer to output it's contents to.
Through inheritance, I do get the screen contents, but not in real time and without any of the modifications that the stub was supposed to perform.
Any ideas as to how or why this might have happened? Is there any way I can reset the std_output handle after a call to CreateProcess() ?
|
|
|
|
|
I don't know how why where or what, but after 6 hours of debuging, editing, rearranging and shouting at the PC, I finaly got it to work. ( I think the shouting did it ).
I can now launch a console from the resources, without writing it to disk first, and redirect it's input/output in real time.
|
|
|
|
|
I love using SuspendLayout and ResumeLayout in .Net to avoid flicker, however, these don't seem to exist for an MFC Dialog.
Is there an equivalent to use on my MFC Dialog ?
|
|
|
|
|
Are you looking for SetRedraw() ?
"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
|
|
|
|
|
Thanks David, that sounds like the ideal method to use
|
|
|
|
|
The controls still flicker
my overall process is:
<br />
this->SetRedraw(FALSE);<br />
<br />
pDC = this->GetDC();<br />
targetDC.CreateCompatibleDC(pDC);<br />
pOldTargetBmp = targetDC.SelectObject(&m_BmpTarget);<br />
targetDC.PatBlt(X,Y,iWidth,iHeight,DSTINVERT);<br />
targetDC.SelectObject(pOldTargetBmp);<br />
targetDC.DeleteDC();<br />
ReleaseDC(pDC);<br />
m_DialogStaticImage.SetBitmap(HBITMAP(m_BmpTarget));<br />
<br />
m_staticText.RedrawWindow(NULL,NULL,RDW_UPDATENOW);<br />
m_editBox.RedrawWindow(NULL,NULL,RDW_FRAME+RDW_INVALIDATE+RDW_UPDATENOW);<br />
.<br />
. about 15 controls<br />
.<br />
<br />
this->SetRedraw(TRUE);<br />
<br />
this->Invalidate(FALSE);<br />
<br />
this->UpdateWindow();<br />
I was surprised that it would still flicker; I was hoping that all the graphics operations were done in memory, then simply shown when UpdateWindow was called - thus avoiding flicker.
|
|
|
|
|
I don't believe WM_SETREDRAW is supported by dialogs. You can try it on the individual controls though
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
abiemann wrote: I was surprised that it would still flicker; I was hoping that all the graphics operations were done in memory, then simply shown when UpdateWindow was called - thus avoiding flicker.
Nope. Looking more closely at your code, the only way you'll be able to prevent flicker
is to do the drawing offscreen yourself, then blt the whole thing to the dialog.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Indeed, I was hoping that SetRedraw would implement double-buffering easily... but I found a good CP link that I'm studying now:
http://www.codeproject.com/gdi/flicker_free_intro.asp
EDIT:
I've compiled the "flicker free" project under VS8 and I see that the "Draw Area" flickers.
|
|
|
|
|
abiemann wrote: //no need to erase background since SetBitmap covered everything up
this->Invalidate(FALSE);
You have a static control that is used to display a bitmap. Yes? Is it overlapping the other controls such that they are requiring this?
"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, I have a static bitmap covering the entire Dialog window. Other controls (Buttons, Edit boxes) are ontop of this bitmap.
|
|
|
|
|
So are you rendering this image in the dialog's OnEraseBkgnd() method?
"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
|
|
|
|
|
no I haven't touched the OnEraseBkgnd() or OnPaint methods.
The code above is processed whenever the user presses a key or lets go of a key.
(I haven't worked much with MFC, so I'm still learning)
|
|
|
|
|
abiemann wrote: no I haven't touched the OnEraseBkgnd()...
Put your bitmap-rendering code in there and note the difference.
"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
|
|
|
|
|
Hi David,
I've made the change and the background bitmap doesn't flicker at all, however, the controls ontop of the bitmap still flicker.
This is the change I've made:
KeyHandler now triggers OnEraseBkgnd instead of performing PatBlt
When the user presses a key, the key's number is stored in a private member variable of the Dialog.
To subsequently make it update the background image, the Dialogs' key handler performs :
this->Invalidate(TRUE);<br />
this->UpdateWindow();
OnEraseBkgnd now does the PatBlt of the static image behind the controls
Next, OnEraseBkgnd(CDC* pDC) is processed.
this handler first checks that a key was pressed, if so, it performs the targetDC.PatBlt (I just use the pDC that's passed in) then it returns TRUE.
If no key was pressed then I let this handler perform the default CDialog::OnEraseBkgnd(pDC)
After this change I noticed that the individual controls no longer need their RedrawWindow() called, however, they still flicker (but the background static image doesn't flicker at all now).
I've also removed the SetRedraw() calls
-- modified at 19:14 Thursday 6th September, 2007
|
|
|
|
|
Did you try adding the WS_CLIPCHILDREN style to the dialog as suggested by WalderMort?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In other words, it works but it doesn't work.
"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
|
|
|
|
|
Do you want to set some properties for a control?
|
|
|
|
|
No the properties won't change, but I'm calling quite a lot of RedrawWindow methods for the controls on the Dialog and I'm noticing that the bigger the controls, and the more there are, the more flicker I'm seeing.
|
|
|
|
|
did you try the WS_CLIP_CHILDREN flag? This alone would reduce a hell of a lot of flicker.
|
|
|
|
|
Good point! For whatever reason, when I see bitmap background code
I think skin, transparent controls, etc. For normal controls WS_CLIPCHILDREN
will work great!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|