|
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.
|
|
|
|
|
Be my guest.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Cruel but too true. I hope I never have to fly in that Aeroplane.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Use the CreateThread function to initialize two HANDLE variables in your windows callback procedure. By default, the functions/objects associated with the handles will execute concurrently.
ralf.riedel@usm.edu
|
|
|
|
|
Create them both suspended, and then start them. Then ensure you are using whatever synchonization primitives are needed to get your threads working correctly. Go read Threads 101.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
When filling the BROWSEINFO struct, provide a callback function.
Use the following:
int CALLBACK MyBrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
if (uMsg == BFFM_INITIALIZED) {
LPCTSTR path = (LPCTSTR) lpData;
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) path);
}
return 0;
}
LPCTSTR path = "c:\\whatever\\you\\want";
BROWSEINFO binf;
...
binf.lpfn = MyBrowseCallbackProc;
binf.lParam = (LPARAM) path;
pidl = SHBrowseForFolder(&binf);
Happy coding
Peter
The cops still stand around and eat koeksisters - Paul Watson, The Lounge, 2002
|
|
|
|
|
Hi, the following code is in a function. I'm doing multithread. When my thread function call this function, i got error message and program terminate......what happened????? HELP!!!!!
{
cs.Lock(); //Critical Section Lock
std::vector <SCHEDULER_MESSAGE>::iterator Scheduler;
if (!Scheduler_MSG.empty())
{
for ( Scheduler = Scheduler_MSG.begin() ; Scheduler != Scheduler_MSG.end() ; Scheduler++ )
{
if (((*Scheduler).msg == ABORT_MSG) || ((*Scheduler).msg == COMMIT_MSG))
{
std::vector <WAITQUEUE_STRUCT>::iterator Iter;
for (int i=0; i<NumOfDBObject; i++)
{
if (LockTable[i].CurrentThread == (*Scheduler).pThread)
{
LockTable[i].CurrentThread = NULL;
LockTable[i].CurrentLock = CurrentNoLock;
}
if (!LockTable[i].WaitQueue.empty())
{
for ( Iter = LockTable[i].WaitQueue.begin() ; Iter != LockTable[i].WaitQueue.end() ; Iter++ )
{
if ((*Iter).pThread == (*Scheduler).pThread)
LockTable[i].WaitQueue.erase(Iter);
}
}
}
Scheduler_MSG.erase(Scheduler); //Finished and erase this message
}
}
}
cs.Unlock(); //Critical Section Lock
}
|
|
|
|
|
Using erase on a vector invalidates the iterators.
Maybe if you changed your loop to...
while (!(!Scheduler_MSG.empty())
{
Scheduler = Scheduler_MSG.begin();
.... the rest of the code
}
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?
|
|
|
|
|
So i change the code liked this:
while (!Scheduler_MSG.empty())
{
Scheduler = Scheduler_MSG.begin();
AfxMessageBox("Update start");
if (((*Scheduler).msg == ABORT_MSG) || ((*Scheduler).msg == COMMIT_MSG))
{
//AfxMessageBox("In the IF loop");
std::vector <WAITQUEUE_STRUCT>::iterator Iter;
for (int i=0; i<NumOfDBObject; i++)
{
if (LockTable[i].CurrentThread == (*Scheduler).pThread)
{
LockTable[i].CurrentThread = NULL;
LockTable[i].CurrentLock = CurrentNoLock;
}
if (!LockTable[i].WaitQueue.empty())
{
for ( Iter = LockTable[i].WaitQueue.begin() ; Iter != LockTable[i].WaitQueue.end() ; Iter++ )
{
if ((*Iter).pThread == (*Scheduler).pThread)
{
LockTable[i].WaitQueue.erase(Iter); <=====Something wrong here...
}
}
}
}
//AfxMessageBox("Before erase");
Scheduler_MSG.erase(Scheduler); //Finished and erase this message
//AfxMessageBox("After erase");
}
}
I found something wrong in the statement LockTable[i].WaitQueue.erase(Iter); (stated)... when i disable this line.....it's no terminate message.........how to change it?
Thanks!!!!!
|
|
|
|