|
Within a project work I have to print rich text files from a console program. Did anyone know a solution for this problem and can provide me a sample code or a library to do this or give me a link to an article that helps? It would really help, because I stepped to articles here on the site and since now didn't get the clue.
|
|
|
|
|
can anyone help me out in clearly understanding the concept of COPY CONSTRUCTORS and VIRTUAL DESTRUCTORS. I have gone through lots of books but still i am not much clear as why we go for COPY CONSTRUCTORS and VIRTUAL DESTRUCTORS.
Kindly help me out.
|
|
|
|
|
Virtual destructors have the same meaning of virtual methods.
Those are useful if you use a base class pointer to hold a derived class pointer.
if base class destructor is not virtual :
class A
{
public:
~A() { cout << "Class A destructor"; }
};
class B : public A
{
public:
~B() { cout << "Class B destructor"; }
};
B *Bobj = new B;
A *Aobj = Bobj;
delete Aobj;
Only the A destructor is invoked.
if you make A destructor Virtual, the destructors of derived class and base class (in this order) are invoked.
Copy constructors are used to copy an object, in these cases:
MyClass obj;
MyClass obj2(obj); // Copy constructor invoked
MyClass obj = obj2; // Copy construcotr invoked
obj = obj2, in this case the assignment operator is used ...
|
|
|
|
|
copy constructor have an explicit enough name ! it gets another instance of its class, and duplicate it into "this"...
imagine in one class, you have a pointer to an object. if you make a simple copy, you would duplicate actually the address, ,not the object pointed. a copy constructor allow you to make a deep copy...
virtual destructors is another topic, with no relation with the first one. in a general mean, you tell a destructor to be virtual if you think that you class can be derived.
|
|
|
|
|
Subramaniam s.V. wrote: COPY CONSTRUCTORS
A copy constructor is used to copy the contents of one object to another. A copy constructor unlike the assignment operator is also responsible for creating the object alongwith the initialization.
Ex:
class sample
{
public:
sample()
{
}
sample(sample &s)
{
cout<<"In Copy Constructor:"<<endl;
}
};
void main()
{
="" sample="" s;
="" *s1="s;" copy="" constructor="" is="" called
="" s2(s);="" called="" in="" this="" case="" also
="" s3;
="" s3="s;" overloaded="" assignment="" called
}
="" a="" differs="" from="" an="" operator="" terms="" of="" creation="" object="" alongwith="" the="" initialization="" variable="" class.in="" there="" piece="" meal="" copying="" contents.
when="" we="" are="" using="" creating="" deep="" object.="" create="" shallow="" object.
so="" use="" constructor.
<blockquote="" class="FQ">Subramaniam s.V. wrote: VIRTUAL DESTRUCTORS.
We need virtual destructors to perform memory cleanup from derived class to the base class.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
See here[^] and here[^] maybe it is some helpful to you
|
|
|
|
|
Hi all,
I would need to close a pop-up menu when the current session expires automatically in my application.
This pop-up menu is displayed by TrackPopupMenu() when the user presses the right button on a window. On the other hand, when a time-out occurs (OnTimer()) the current session expires, and I would like to close all possible pop-up menus.
Could anyone help me?
Thank you.
Ser.
|
|
|
|
|
seanru wrote: and I would like to close all possible pop-up menus.
May be you can send a WM_LBUTTONDOWN message to the main window.
|
|
|
|
|
Off the top of my head WM_CANCELMODE[^] is the way to go to cancel menus.
Iain.
|
|
|
|
|
Thanks for your answers.
Anyway, I think it doesn't work.
What I need to do also is to 'close' Start Menu when a timer expires in my application, because that application should go to foreground, and Start Menu should disappear.
I tried to send WM_KEYDOWN and WM_LBUTTONDOWN to Windows task bar, but it does not work.
How could I close that Menu??
Thanks.
|
|
|
|
|
Sadly, the start menu is only an imitation menu. It has a load of non-menu features, and varies from one operating system and service pack to another.
About the only thing I can think of is to find the window with the current focus, and send a WM_KEYUP / WM_KEYDOWN with VK_ESCAPE as a parameter.
Iain.
|
|
|
|
|
Hi,
I have a thirdy party OCX. There is a sample VB program which uses "On Error" to trap runtime errors when an OCX method is invoked.
I want to build my application using this OCX and VC++. How do I trap runtime errors ? Do I have to use exception handling ?
Thanks
|
|
|
|
|
Nyarlatotep wrote: Do I have to use exception handling ?
yes
use
try...catch
nave
|
|
|
|
|
Hello,
I'm using a print preview view to present the preview of a report in my program.
Things seem to be ok, but I don't like the default behavior that the view
will turn to empty when user press an Esc key and want to disable it.
How can I get this?
Thanks
Max
|
|
|
|
|
hi all,
as we can insert the text in an rich edit control with
SetWindowText(string) API
but is it possible to insert some character in between the existing string??
i mean if i know the caret position to insert that character and the actual character to insert then can i insert the characterwith this information??
e.g.
if current text in rich edit control is
love is in the air.
and if i want to insert the character after "in" as "in/" so how i can do that??
please let me know if someone know's how to do this!!
Thanks and Regards
Harshal shete
|
|
|
|
|
harsha_1234 wrote: love is in the air.
and if i want to insert the character after "in" as "in/" so how i can do that??
Like this:
You can use CString::Replace() to replace the text.
CString m_str;
m_richedit.GetWindowText(m_str);
m_str.Replace ("in","in/");
m_richedit.SetWindowText (m_str);
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
yes this is one way but in this way we need to call GetWindowText
and then after changing the text we will say SetWindowText
what i want to do is that
if i have a character and the caret position that is going to tell me where
to insert that character then i will do
SetCaretPos(point)
and now programmatically i want to insert that character ata that position
so how i can achieve that??
and thank's for replying
harshal shete
|
|
|
|
|
harsha_1234 wrote: what i want to do is that if i have a character and the caret position that is going to tell me where to insert that character then i will do
CPoint pt=m_richedit.GetCaretPos ();
int i=m_richedit.CharFromPos (pt);
CHARRANGE chRange;
chRange.cpMin =i;
chRange.cpMax =i;
m_richedit.SetSel (chRange);
m_richedit.ReplaceSel ("/");
I hope this helps and fits your requirement.
-- modified at 5:01 Thursday 14th September, 2006
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
yes thank's anshuman
actually i am doing multilevel undo redo
thanks and regards
Harshal
|
|
|
|
|
Another option is to use CRichEditCtrl::SetSel[^] to set the 'carret' position (in fact, the text which is selecetd in the control, if nStartChar is equal to nEndChar, then, you specify a carret position). You can then use CRichEditCtrl::ReplaceSel[^] to replace the text which is selected (ans thus, insert text also).
|
|
|
|
|
yes this is a good approach
actually i am doing multilevel undo/redo for richedit ctrl(CRichEditCtrl)
and when i searched on codeproject i didn't got any undo redo code for CRichEditCtrl.
so currently i am making dynamic stack in which i am storing the caret position and the character.in OnChar handler.
and i am thinking that when user will say undo i will pop one frame and will insert that character in the rich edit control at that position.
Is it a good approach??
and is there no other API that will just take the character and caret position o insert the character??
Thanks and regards
Harshal shete
|
|
|
|
|
CString m_str;
m_richedit.GetWindowText(m_str);
m_str.Insert( Index, "string to be inserted" );
m_richedit.SetWindowText (m_str);
akt
|
|
|
|
|
ooh sorry pls ignore the above reply
thanks
akt
|
|
|
|
|
Hi all,
I want to make a server with the use of turbo c 64 bit. I tried to search turbo c compiler but i did not. If you have any idea about it plz plz plz rply me as soon as possible its urgent.
Thank you in advance.
|
|
|
|
|