1)On p.370 of Ivor Horton's Beginning Visual C++ 6, it says you can add operator
functions to the class by clicking on the down arrow to the right of the
Wizard bar and selecting Add Member Function. I tried that, and after I
entered the first operator function, the declaration was added to the
class in the .h file, and a skeleton function definition was added to
the .cpp file. So far, so good. Then, when I tried to add a second
operator function, it only added a skeleton function definition to
the .cpp file and would not add the declaration to the .h file. How can I
get it to do that?
2)A little later in the chapter on p. 374, it says that instead of typing
in preprocessor functions into the header file, you can use a macro in
VC++6 that will do it for you. The book says to click on Tools/Macro and
select OneTimeInclude from the macros list in the Macro dialog box that
pops up. My macros list is blank in the dialog box. I tried typing in
OneTimeInclude, but I got an error that said I had to choose a macro from
the list--what list, it's blank?!
1. Burn the wizard, learn to do it yourself. You obviously know where things need to go, so put them there. Wizards are good to help you get started, but you should always move beyond them and learn to use the language more than the IDE.
2. I've never used this because macros are evil. The one time include should be present anyhow, when the class is generated by the wizard. Apart from this you should not use macros unless you really need them, i.e. where a const variable or inline function will not do the trick. In the real world, that generally means when you're writing debugging/tracing tools.
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
1)I would rather save myself the hassle of having to type the function header twice: once in the class definition and once in the function definition. For some reason the wizard has a problem with operator functions in the class definition: it doesn't seem to recognize that operator+() is different than operator*(), but it does in the class implementation file because it adds a new skeleton function definition there.
2)I don't really understand your explanation here. As far as I can determine, the macro I'm supposed to run adds the preprocessor directives to my .h file--not a macro--so that once again it will save me the hassle of typing them in myself.
Do you use VC++ 6? If so, could you click on Tools/Macro and tell me if OneTimeInclude is in the list of macros?
Christian Graus wrote: If so, could you click on Tools/Macro and tell me if OneTimeInclude is in the list of macros?
It's empty, as I would expect. I'd expect this to include macros as in UI sequences I recorded, not macros as in #define BLAH blah
After several days of messing around with this macro deal, I finally figured it out. If you're interested, with no files open in VC++6 click on Tools\Macro, then click on Options/Loaded Files, and the "Add ins and Macro files" tab should be selected(if not select it). There is a macro called Sample which you should enable by clicking on the check box. Then click on Close. From then on when the Macro dialog box appears after you click on Tools\Macros, you can select Sample as the "Macro file:", and from the list you can choose OneTimeInclude. When you click on Run, the macro will add your preprocessor directives for you. There are also other sample macros that are probably useful.
I have derived a dialog from CPropertyPage, then I have included a Groupbox control. Inside that control I have placed three Radio Buttons. I have enabled the GROUP option for the first one and leave the rest two as is. Now I want to to set and get the values of those Radio Buttons on runtime. For this I am reading some values from a File and setting the Radio Buttons based on those values.
The problem which I am getting is that, I could not find how to set the values of those remaining two Radio Buttons which were not set as GROUP. Because ClassWizard only maps the variable for the Radio Button for which I have set the GROUP option.
Anybody knows how to solve this and where I am lacking.
when DDX goes to get the value for you, it will scan from the start of the Group to the control before the next control with the group flag set. so, only one radio button in a group needs the group flag set (and it must be the first button). so, even though they aren't included in the DDX statement, the DDX code will include them when it does its processing.
When history comes, it always takes you by surprise.
I'm programming some years, but I just started with the MFC. So I downloaded the Undo/Redo Demo, which helped me a lot. Now I tried to implement Scroll Bars. The vertical one does exactly what it should, but the horizontal one, em
In debug Mode (VC++ 6.0) the following happens:
At first everything works fine, both scroll bars work. When I try to create a new, or to open an existing document I get an "Debug Assertion Failed!" Error for File: wincore.cpp Line: 628
If I compile this as release I am able to create a new, or to open an existing document, but the horizontal scroll bar gets invisible.
I know its there; when I drag it it is visible. When I resize the window it gets visible,too. But after the next repaint of the window it disappears. The code for the vertical and the horizontal bar is exactly the same, but one bar works and the other...
I used the following code:
8< out of my View class definition
Jakob Bysewski wrote: When I try to create a new, or to open an existing document I get an "Debug Assertion Failed!" Error for File: wincore.cpp Line: 628
// from wincore.cppvoid AFXAPI AfxHookWindowCreate(CWnd* pWnd)
<font color="009900">628=></font> ASSERT(pWnd->m_hWnd == NULL); // only do once
This tells you that you are trying to recreate a window that already exists. The reason it appears to work, and then not work, in release builds is because a release build does not do any of the ASSERT() checks. It just continues on it's merry way assuming everything is valid.
It may be alot easier for you if you use a CScrollView derived view class. CScrollView has all the scrolling functionality already built in.
I'm new to VC and I was wondering if you can draw a CEdit control wich at first would be disabled, until the user pushes a button. I know I can set the disable state when I draw the control in the dialog, but after this how can i undisable it in, say a fuction OnButton1, considering there is no such member function in the CEdit class? Can it be done same way for a button?
I've already read a few times on this board the the MFC CSocket is bad and should not be used. Why is that so? I used it a few times in some smaller client/server apps and had no problems with it. And if it's really bad, what should I use instead? I am not familiar with pure Berkeley sockets
The easiest solution would probably be to draw the text into a memory DC, then use StretchBlt() to copy it to the screen and stretch it as tall as you want. The result probably won't look too pretty, though.
--Mike-- PROCRASTINATION: Hard work often pays off after time, but laziness always pays off now.