|
I am trying to derive from CControlBar and am not having much success, but slowly understanding why things work the way they do so i'll figure it out soon. I hope.
Heres my problem...When creating a new class derived from CControlBar the way I see it I have 2 options in creating the class.
1) Derive from MFC CWnd and later change the class from CWnd to CControlBar
2) Generic, but then I have to add the special ClassWizard comments on my own and that all takes time.
To be fair I tried both methods and neither does what I need.
When you right click on a class to add virtual functions you would usually expect to get a list of all available functions. However it seems when deriving from CControlBar (which isn't complicated enough for me ) it virtual functions aren't available, only CWnd's are....
I have modified *.clw file but cannot for the life of me figure out if what i'm trying to do is even possible...???
Am I going to have to keep finding the afxext.h barcore.h (i think) files and copy pasting...or is there a more classwizard friendly way of doing things...?
This is driving or is that deriving...? me INSANE!!!
Any suggestions...?
Thanx in advance.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Firetruck the ClassWizard - you don't need a fancy dialog to add virtual function. ClassWizard does nothing magical that you couldn't do yourself.
Which virtuals are you overriding?
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Tomasz Sowinski wrote:
you don't need a fancy dialog to add virtual function.
Your right...I don't need it, but it's there for a reason and that reason i've kinda got attached to.
Tomasz Sowinski wrote:
Which virtuals are you overriding?
A while back when deriving from a custom class I wrote I noticed nothing was happening when the class was instantiated, when I (in the child class) did the following to all the virtuals stuff started happening.
virtual OnCreate(...){ return CParent::OnCreate(...); }
I never did figure out why this was so, but at that time I couldn't care...it worked.
I'm thinking my lack of success with derived CControlBar's might have something to do with preceding. I figure i'll override all the virtuals until something starts happening.
Overriding all the cirtuals by hand will be time consuming and annoying. I'm really not looking forward to copy/paste either. Even if I just make them all inline so I avoid having to go back and forth between h and cpp
's i'm lazy that way and would rather spend my time coding...
It's so frustrating...I can't even start programming what I want until the control bar is functioning.
Suggestions, ideas...?
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
OnCreate should not be virtual. It's a message handler for WM_CREATE and it's wired to API through the MFC message map.
You have to ensure that BEGIN_MESSAGE_MAP has the reference to real base class. This is easy to overlook when deriving from CWnd and changing base class to CControlBar.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Tomasz Sowinski wrote:
OnCreate should not be virtual
Sorry I meant Create(...)
BEGIN_MESSAGE_MAP(CToolbarEx, CControlBar)
I think i'm doing that properly. Still no luck on the CControlBar showing it's own virtuals.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
OK. There's one more thing you may find helpful. I've found that *sometimes* newly overriden virtual function doesn't get called - it's easy verifiable; just put the breakpoint into it. Rebuilding always fixes this problem.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Tomasz Sowinski wrote:
I've found that *sometimes* newly overriden virtual function doesn't get called
What exactly do you mean...?
I think you mean what I was saying earlier...
The last time I derived from a class I found I needed to call the virtual parent functions.
It just so happens this is the problem I am having with my current project also. I'm oging to have to re-write the virtual functions or atleast call the parent version. I'm thinking by doing this my grippers and such will start to show up slowly.
Tomasz Sowinski wrote:
it's easy verifiable; just put the breakpoint into it. Rebuilding always fixes this problem.
Verifiable...? Like as in verify this is happening...? I'm sorry my english stinks...I hated school.
I verified this was happening by placing AfxMessageBox() in the CControlBar::OnSizeParent() and other functions...they weren't getting called.
Rebuilding fixes this problem...?
Rebuild All...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
What exactly do you mean...?
I mean that behavior I've described happens from time to time, especially when I'm dealing with deep class hierarchies.
HockeyDude wrote:
The last time I derived from a class I found I needed to call the virtual parent functions.
Wait, wait, wait. 'Paren functions' are *not* called automatically. To make sure we're talking about the same thing, consider the following class hierarchy:
class B
{
public:
virtual void foo() { printf("In B::Foo\n"); }
};
class D : public B
{
public:
virtual void foo() { printf("In D::Foo\n"); }
};
B* pb = new D;
pb->foo();
You're going to see 'In D::Foo' only. If you want both strings to appear, you have to explicitly call B::Foo in D::Foo. The fact that function is virtual doesn't imply anything about parent class implementation being called (a'la C++ constructors/destructors).
So are we broadcasting on the same wavelength?
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
I'm no master with virtuals, but there isn't much to em' I think I get the gist of it.
I understand that inorder to get parent implementation you explicity call the parent functions.
In my my last experince with deriving from classes other than MFC supplied like CButton and such was that when I derived from anything else nothing was happening.
When I override the virtuals in the child class and either re-implemented or called the parent version I finally got some action.
I thought that overriding wasn't nessecary and default implementation would be fine, but it doesn't seem to be the case with my custom classes.
class Parent{
public:
virtual BOOL Fake1(){ return AfxMessageBox("Fake One"); }
virtual BOOL Fake2(){ return AfxMessageBox("Fake Two"); }
BOOL Fake3() { return AfxMessageBox("Fake Three"); }
};
class Child : public Parent{
public:
BOOL Fake4() { return Fake1(); }
virtual BOOL Fake1(){ return AfxMessageBox("Now it works"); }
};
int main(void)
{
Child tmpObject;
tmpObject.Fake4();
return 0;
}
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
No - you don't need to create Fake1 in Child class if all you want is implementation provided by Parent. If after removing Child::Fake1 you're not seeing any messagebox, you have found the compiler bug.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Tomasz Sowinski wrote:
No - you don't need to create Fake1 in Child class if all you want is implementation provided by Parent
Exactly...!
Tomasz Sowinski wrote:
If after removing Child::Fake1 you're not seeing any messagebox, you have found the compiler bug.
Thats all I needed to hear...i've been thinking that for a long time. I'm using a really old version of VC++ Learners edition 6.0 that shipped with a book and I swear it's a peice of shite.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I'm not sure if Service Packs can be applied to learning edition, but try to download and install SP5. Maybe it'll solve your problems.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
hI,
I need you guys' help!!!!
I'm writing a program at home and everything is fine. However, when i move my program back to my school to test it, it cannot run and have error message "fatal error LNK1102: out of memory"...........
What happened!!!!! My demo is tomorrow.!!!!!!!!
Thanks
p.s.: i just tried it again...seems liked ok....but i don't know....I need advise....PLEASE...PLEASE
|
|
|
|
|
You're compiling the program at school and linker barfs? Or you have .exe compiled at home and it crashes at runtime?
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Tomasz Sowinski wrote:
You're compiling the program at school and linker barfs? Or you have .exe compiled at home and it crashes at runtime?
I just copy all files except those in DEBUG directory from home to school. Then I rebuild all files in school and run it.
Now seems OK.....but I just worry that it will happen again tomorrow during demo.
So...what happened???
|
|
|
|
|
It seems you're compiling on a machine with about 8 megabytes of RAM
Linker just tells you that there's not enough memory to perform link.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Hahahahaaha,
Maybe my home computer is too powerful (AMD900, 512Mb RAM....), but my school's computer just has 256Mb RAM.....
So, basically, I can do nothing except asking the school to replace those computer????
Thank you very much~~~~~~
|
|
|
|
|
ChiYung wrote:
but my school's computer just has 256Mb RAM.....
It's more than enough - I don't believe your project is *that* complex. VC installation may be screwed somehow - if it fails on one machine, try with another. Your teacher(s) should be smart enough to get where the problem is.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Here's what the MSDN says about that error...
-------------------------------------------
Linker Tools Error LNK1102
out of memory
There was not enough memory for the tool to run. Probably the paging file exceeded available disk space.
If a shortage of disk space is not the cause, note the circumstances of the error, try to isolate the problem and create a reproducible test case, then consult the technical-support help file or the technical-support section in one of your manuals.
----------------------------------------------------
so check the disk space on your computer.
|
|
|
|
|
Hi,
My base dialog(CMyDlg) have 3 buttons and 2 childs windows. Which are delived from CPropertyPage and each have 2 buttons and edit control. My question is how to route focus when user press "TAB". Route focus from 1. after to 2. after to 3. button in CMyDlg and next route it to first childs windows. After when focus has last control (in first child w.) and user press TAB route focus to second child windows and so on ... As you have only 1 base dialog which have all control.
::SendMessage(pWndParent->m_hWnd, WM_NEXTDLGCTL,0,0); I use this but its only for control with WS_TABSTOP ( not for windows.
Could you suggest some link ? or how to do it ??
Thanks very much
Wiizi
|
|
|
|
|
Make sure the property page/child windows have WS_EX_CONTROLPARENT extended style set. You can force this on during initialization.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I need to create two threads at the same time - meaning I cannot wait for one thread to complete before I create the second because they both have continuous loops inside their functions.
What do I need to do in order to create and run both threads? Could you give me some sample code or direct me to the correct function(s)?
Thanks in advanced.
Hiep Dang
|
|
|
|
|
You just create the two threads in sequence. Creating the second thread won't wait for the first to finish.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I can see the splash panel for that app now -
"Ladies and gentlemen, thank you for purchasing this program. Please sit back and relax, and try to ignore the sound of buckling metal as we initialize our threading model."
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote:
Ladies and gentlemen, thank you for purchasing this program. Please sit back and relax, and try to ignore the sound of buckling metal as we initialize our threading model."
Hhahahahahaha
Can I steal that for a new sig please?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|