|
There's no need for the operators to be virtual. You just override whatever methods you want. The only time virtual comes into play is polymorphism - when you're accessing zofstream methods through a ofstream* variable and you need the zofstream version to be called. Folks don't usually use polymorphism with streams, so the ofstream methods aren't virtual.
The code is all in the "fstream" header I believe. Good luck understanding it, though, it's horribly obfuscated and impenetrable.
--Mike--
http://home.inreach.com/mdunn/
This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use.
your with and
|
|
|
|
|
The usual way to have user defined streams is not by deriving from ofstream or any other standard stream , but rather by deriving from streambuf , which is the holder of the virtual functions you're after. Only after this you can define your ozfstream as a derivation of ostream having a zstreambuf (or whaterever you decide to call it) as a member and attaching the base class to it. The details are a little convoluted, but the task if way simpler than your intended approach of overriding each and every ofstream method. Plus, you got some extra bonuses, like the possibility of having zipped streams of any kind, not just coming from files but from memory buffers or other sources.
Good luck with your project.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm having a hard time making a macro for my outputdebugstring function.
void CMyTrace::ODS(const CString& message, ...)
{
va_list args;
char textBuffer[1024];
va_start(args, message);
_vsnprintf(textBuffer, 1023, message, args);
va_end(args);
OutputDebugString(textBuffer);
}
I've tried something like this with no luck. I've searched and search to find a way. I know it can be done because micro$oft does it with ATLTRACE and TRACE but I'm not having any luck.
#ifdef _DEBUG
void ODS(const char* msg, ...) { .code. }
#define DEBUGOUT debugOut
#else
inline void ODS(const char* msg, ...) { /* empty */ }
#define DEBUGOUT 1 ? (void)0 : ODS
#endif
|
|
|
|
|
try this:
#ifdef _DEBUG
void ODS(const char* message, ...)
{
va_list args;
char textBuffer[1024];
va_start(args, message);
_vsnprintf(textBuffer, 1023, message, args);
va_end(args);
OutputDebugString(textBuffer);
}
#define DEBUGOUT debugOut
#else
inline void ODS(const char* msg, ...) { }
#define DEBUGOUT 1 ? (void)0 : ODS
#endif
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I know that is possible to draw a bitmap using SetROP2 in such a way that some of the bitmap's pixel to be transparent ( i.e. to be not copy onto screen ). But is there a way to draw a polygon onto screen and only pixels with some color to be touched ( i.e. changed ) by this operaion ?
|
|
|
|
|
Yes, you could just build the mask from the destination instead of the source bitmap. I *think* that would work. You could also turn it into a DIBSection if it isn't already and do it manually.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
How can I resize a view to be as big as a particular frame-window?
I have an app with multiple views in one frame-window. Off course, only one can be active. When I resize the window, all in-active views need to be resized as well. It does not happen automatically. How do I do that? I have pointer to all of them.
Thank You for your help,
XP
|
|
|
|
|
It seems to me that you could handle the WM_SIZE message in the frame class to capture when the window gets a new size. From there, you can resize the windows as you like by using MoveWindow on any views you wish to move or resize.
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
This works, but the view gets disconnected from the frame.
What I mean is, the view gets resized to the size of the frame, but it draws itself over the status bar of the frame. When I resize I can make parts of the status bar appear. The view seems detached form the frame although I called SetActiveView().
Any thought?
Thank you.
|
|
|
|
|
I'm working on an app that can change languages at run-time. It can be run in English, or Chinese (and many others, but for simplicity's sake I'll focus on those.)
Anyhow, this app works fine in English on an English system, and fine in English or Chinese on a Chinese system. Problem results when running in Chinese on an English system. The fonts are there, and IE can display them fine.
The problem is that most dialog controls (e.g., CStatic, CButton) will *not* display the Chinese text right, even if I select a Chinese-encoded font into the control. What I get are what appear to be the DBCS strings in ASCII or something. In spite of this, a CEdit with the same font in the same dialog will work just fine!
One more thing - if I make my own control derived from, say, CStatic, and override OnPaint to display text myself, it works.
Anybody know what gives? Will I have to override the default controls that don't happen to work (CStatic, CButton) with my own controls? Is this a problem with MFC, or the underlying Windows controls?
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
I worked with cirillycs Idiomas, Hebrew and Arabic with a application that changed from English to Portugesse or Spanish or hebrewm, or russia, etc.
For that I needed to work in a Hebrew operating system, The classes didn't work fine with these Idioms, I needed to work all in unicode, and when you tray to make a CWnd::SetWindoText, CString don't supports those characters. I needed to create every control with the Create function, etc....
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
Well, what seems odd, is that, let's say I derive a control from CStatic (or make a custom control.) In my OnPaint handler, I have the code below, and it works fine! So it's not a problem with CString or Set/GetWindowText, or TextOut. It does make me wonder what a CStatic (or Windows static) control could possibly be doing that is messing this up??
<br />
CPaintDC dc(this);<br />
<br />
CString str;<br />
CRect rect;<br />
<br />
GetWindowText(str);<br />
GetWindowRect(&rect);<br />
<br />
CSize textSize = dc.GetTextExtent(str);<br />
<br />
int x, y;<br />
x = rect.Width() / 2 - textSize.cx / 2;<br />
y = rect.Height() / 2 - textSize.cy / 2;<br />
<br />
dc.SetBkMode(TRANSPARENT);<br />
dc.SelectObject((CFont *)GetFont());<br />
dc.TextOut(x, y, str);<br />
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
Hi...
just few simple questions:
1. how do u call an application in your VC++ project? e.g. I want to call real player.exe in my project.. what's the command?
2. What's the command to copy one file? e.g. I wanna copy pic.bmp to c:/image/pic.bmp
3. How do I know what's my current working directory?
Thanks a LOT....
|
|
|
|
|
|
1- CreateProcess();
2- CopyFile()
3- GetCurrentDirectory();
Cheers
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
MSDN has all these functions, although these types of functions are typically Windows API, and not wrapped in any way by MFC.
For running a process, there are a couple others:
1. ShellExecute: it is nice if you have a program's date (e.g., a RealPlayer file) and want the system to find the app that handles it.
2. CreateProcess: if you want full control over creation, but it is probably the most complicated of the ways to run a program.
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
I have a property sheet, and one property page (CFirstPage). m_showInfo is a bool, and m_ctrShowInfo is the DDX control for the checkbox. I want to initialise the property page with the current settings.
In my implementation file;
CFirstPage::CFirstPage() : CPropertyPage(CFirstPage::IDD)
{
if(m_showInfo)
m_ctrShowInfo.SetCheck(1);
else
m_ctrShowInfo.SetCheck(0);
}
If i use SetState() instead, everything goes well. However, SetCheck() crashes at CButton::SetCheck. Any ideas why?
---
"Transmit in all known frequencies and in all known langauges, including Welsh."
|
|
|
|
|
because m_ctrShowInfo isn't a "window" yet, and SetCheck is sending a window message.
try setting this in your InitDialog
-c
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Argh! My head is hurting. All this MFC i've been doing has reduced my potential lifespan. I actually figured it out whilst watching neighbours, but thanks anyway.
---
"Transmit in all known frequencies and in all known langauges, including Welsh."
|
|
|
|
|
Look into the declaration of m_ctrShowInfo Is a CButton or another thing?
Best Regards!!!
Carlos Antollini.
Today is Fridad!!! for All!!!
|
|
|
|
|
Look into the declaration of m_ctrShowInfo Is a CButton or another thing?
But the problem is that you are in the contructor of your class, and the control have not HWND yet.....
Best Regards!!!
Carlos Antollini.
Today is Fridad!!! for All!!!
|
|
|
|
|
Try to do that in the InitDialog. In that instance the Hwnd exists
Best Regards!!!
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
The app that I am making has this sucken in look where all the controls are at. I tried changing the windows style in this function, but that didn't work. I am trying to get rid of the sunken in look and make the whole area where the controls are located raised up with the rest of the app.
I sure appreciate any help.
|
|
|
|
|
Two questions:
(1) Is your app MDI or SDI?
(2) What kind of view you are using to display controls?
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
The app is SDI and I am using IDD_MFC_FORM.
|
|
|
|