|
hi...
can u pls tell me how to get the handle of DLG from a totally different class???
i have a class that does some function and then at tat point i need to access my main dialog....actually i need to access a static control of that dialog...
can anyone pls tell me a solution???
tks a lot
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
can anyone gimme an answer??
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
When your dialog is created, store its class instance in a static member variable in the dialog class. Create a static function that returns that instance.
So, if your dialog class was named CDlg, then to get the dialog, you could do:
CDlg* dialog;
dialog=Dlg.GetMainDialog();
HTH
"To know what is right and not do it is the worst cowardice." -- Confucius
FLUID UI Toolkit
|
|
|
|
|
my dialog and my class are far far away...
my dlg calls a class by returning ans int to ir(this class is not a dlg)
then this class has to call another class..
this another class needs to access the dilog...
now can i pass the dlg to the class as the class is created by returning a valu..
and C++ only allows returning one param...
I HAVE TO USE RETURNING to to create the class...
so i cant substitute it with anything else
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Joseph R. Thomas wrote:
my dialog and my class are far far away...
The method I showed you works as long as the other class is in the same process as the dialog class.
The other thing you can do is pass the class in the method:
Dialog calls class, passing instance of itself to the class.
Class calls class 2, passing the dialog instance that was passed to it.
Class 2 calls the dialog instance that was passed to it.
"Love does not delight in evil but rejoices with the truth." -- 1 Corinthians 13:6
FLUID UI Toolkit
|
|
|
|
|
Dialog calls class, passing instance of itself to the class.
Class calls class 2, passing the dialog instance that was passed to it.
Class 2 calls the dialog instance that was passed to it.
can u gimme a example of thow to do that???
tks
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Suppose the method you wanted to call in the first class was called DoSomething(CDlg dialog), the method you wanted to call in the second class was DoSomething2(CDlg dialog), and the method to be called in the dialog was called CallDialogMethod. The code below would do what you wanted:
class1.DoSomething(this);
class2.DoSomething2(dialog);
dialog.CallDialogMethod();
You might consider buying some books on programming in C++. They'll help you with this type of thing.
""It is impossible to rightly govern the world without God and the Bible." -- George Washington
FLUID UI Toolkit
|
|
|
|
|
NVM...
u get get my meaning....
all you re telling me to do is stuff i know already...
that means if i posting this here...
its definetly not the kiddy stuff....
you are telling me the basics....
but then...
maybe i never phrased my qestion properly...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
OK, maybe you can try to explain it better - give me more details - and then maybe I can help you.
"Going to church doesn't make you a Christian any more than going to the garage makes you a car." -- Laurence J. Peter
FLUID UI Toolkit
|
|
|
|
|
Dear All
It would be great if anyone could tell me how to print using cximage?
How do i go about incorporating it?
Thanks
|
|
|
|
|
Dear all
I am desperately trying to print a jpeg/bmp image in vc++.
It prints it on the top left corner of the page ina very small size.
I used the mm_loenglish mapping mode.
It would be great if you could help me to fix this.
Thankyou very much for your time.
|
|
|
|
|
I have an abstract base class CFoo that contains a pure virtual method void setDefault() as well as a public static method void doSomething() , like so:
class CFoo {
public:
CFoo()
{ setDefault(); }
virtual ~CFoo()
{}
virtual void setDefault() = 0;
static void doSomething() {
int x = 0;
x = 32;
}
}
One of CFoo 's clients does this:
CFoo::doSomething();
which causes VC6's linker to complain that CFoo::setDefault() is not implemented. It's as if the compiler wants to construct a CFoo object (which makes no sense since it's an abstract base class).
Is it me or VC6? (It's probably me, but I can't figure out what I'm doing wrong).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I think it is VC6. Both VC7.1 and Comeau compiled it just fine.
The results I get from Comeau,
MODE:strict errors C++
"ComeauTest.c", line 7: warning: call of pure virtual function
setDefault();
^
"ComeauTest.c", line 16: warning: variable "x" was set but never used
int x = 0;
^
In strict mode, with -tused, Compile succeeded (but remember, the Comeau online compiler does not link).
http://www.comeaucomputing.com/tryitout/[^]
|
|
|
|
|
Thanks.
What's weird is, I went ahead and implemented CFoo::setDefault() keeping the pure virtual specifier, and guess what - VC6 didn't complain! Eeek! (Nor did the problem go away.)
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
If no one actually attempts to instantiate a CFoo object, then it won't complain.
If you just do:
CFoo fred;
it will.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Actually, you can never instantiate a CFoo , since it's an abstract class.
The problem has to do with the fact that CFoo's static (factory) method was constructing a derived class which caused the linker to want to resolve CFoo::setDefault() . This is sorta hokey, but what I was doing was wrong, since the derived class's vtable has not been initialized in the base class' constructor.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It's giving an error because you're calling CFoo::setDefault() directly, and that method is not implemented. Remember the virtual only kicks in if you call the method through a pointer. You need to call plain setDefault() to get the polymorphism that I think you are expecting.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
Actually I'm calling CFoo::setDefault() indirectly - I neglected to mention that doSomething() is actually a factory method that serves up a specialization of a CFoo , which causes CFoo 's constructor to be called, which causes a call to a method in a derived class, which is just plain wrong!
But I still think the compiler should have caught the error.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
which causes CFoo's constructor to be called, which causes a call to a method in a derived class
er, you aren't calling a virtual function in the CFoo ctor, are you? The vtbl isn't initialized yet so that will probably crash at runtime with a pure virtual function call.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
Quite right, Mike. VC6 catches that link time, presumably because the vtable entry for setDefault() is NULL.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Michael is right (almost) - you don't have "virtuality" in the constructor. Your doSomething should Create the object, and then call setDefault explicitely.
(almost: IIRC the VTable is initialized to the one ofthe base class, and you have a virtual call not only through a pointer but also in all member functions and the destructor)
"Vierteile den, der sie Hure schimpft mit einem türkischen Säbel."
sighist | Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
Your doSomething should Create the object, and then call setDefault explicitely.
Yes, that's exactly the tack I took. Thanks for your reply!
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
While writing some code for a class, wich also contains oveloads for the assignment operator ( = ), VC++ keeps giving C2801 errors. According to MSDN, C2801 means that assignment, class member access, subscripting or function call operators must be a non-static class member.
This is my code:
class Foo<br />
{<br />
private:<br />
CString m_String;<br />
public:<br />
Foo();<br />
Foo(CString);<br />
~Foo();<br />
friend Foo& operator= (const class Bar);<br />
}<br />
<br />
Foo::Foo (CString string)<br />
{<br />
m_String = string;<br />
}<br />
<br />
Foo& operator= (const class Bar BarInstance)<br />
{<br />
return Foo (BarInstance.m_String);<br />
}<br />
<br />
class Bar<br />
{<br />
private:<br />
CString m_String;<br />
public:<br />
Bar();<br />
~Bar();<br />
}
But that's not the whole story; the code
char* yourName = "DaFrawg";<br />
MessageBox("Hello there, %s", yourName);
will generate a messagebox with the prompt "Hello there, %s" and the caption "DaFrawg". What I want is, of course, to have the message "Hello there, DaFrawg" displayed.
Can somebody help me, please?
//Please don't mind my bad English
|
|
|
|
|
DaFrawg wrote:
But that's not the whole story; the code
char* yourName = "DaFrawg";
MessageBox("Hello there, %s", yourName);
will generate a messagebox with the prompt "Hello there, %s" and the caption "DaFrawg". What I want is, of course, to have the message "Hello there, DaFrawg" displayed.
Can somebody help me, please?
CString strMessage;<br />
<br />
strMessage.Format("Hello there, %s", yourName);<br />
MessageBox(strMessage);
Michael
'Logic, my dear Zoe, merely enables one to be wrong with authority.' - The Doctor: The Wheel in Space
|
|
|
|
|
Then why doesn't TRACE1("Hello %s", name) fail?
---QUOTE---
"ERROR: Keyboard not present - Press F1 to continue" - Most BOIS chips
|
|
|
|