|
I think calling delete will call the destructor. So no need to call delete while the object is already being destroyed.
I believe that in the destructor, you should close any open handles, deallocate any allocated memory etc.
this is this.
|
|
|
|
|
ita_cas wrote: If I have an empty destructer , does it automatcly calls to the delete() function ?
or should I include it within it
A Destructor is basically for giving your object a chance to perform any cleanup operation that is required. Like if it has allocated any memory then here it can do the necessary clean up. Closing all open handles etc.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Actually, delete is an operator, and destructors are called when an object is deleted. Here's an example:
class A {
public:
~A();
};
class B: public A {
~B();
};
class C: public B {
~C();
};
C *c;
delete c; When the line delete c; is executed, destructors are called in the following order: C::~C(); B::~B(); A::~()A; , and then the memory itself is freed. The same thing happens in this case:
{
C c;
} when execution passes the closing brace, the c object is deleted by falling out of scope, and the destructors are called in the same order as before.
Software Zen: delete this;
|
|
|
|
|
hi
after i use ShellExecute() to run exe file i coudn't close it from my program by non of th function that i no like fileclose()
so i need help to close exe file from my program
|
|
|
|
|
did you try CWnd::PostMessage(WM_CLOSE); ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: did you try CWnd::PostMessage(WM_CLOSE); ?
Humm... Nice .. But CWnd should be pointing to Other Window otherwise it will close it self!
Better option will be ::PostMessage(WINDOW TO CLOSE HANDLE,WM_QUIT,...)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
try createprocess and terminate process instead of ShellExecute. CreateProcess gives you the control over the created process.
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
you can try following
CWnd *cwnd = FindWindow(NULL,"WINDOW_TO_FIND");
cwnd->PostMessage(WM_CLOSE,0,0);
sanket patel
|
|
|
|
|
Hello,
I need to use a unsigned value with up to 48 bits (this is for a Bluetooth simulation program and this 48 bits represent a Bluetooth address). I need to make some computation on this Bluetooth address (really playing on the bits and then use the result of the computation as an unsigned value). So my problem here is that if I use a __int64, I will have problems when working at the bits level and the converting the value to a unsigned. Thus, I was wondering if the same as __int64 exists but for unsigned numbers ?
Or if somebody has another solution to this problem.
An exemple of what can be done with the address:
unsigned Value = ((m_BTAddress>>19) & 0x0F);
|
|
|
|
|
can't the following be used ?
struct TBTAddr {
unsigned _address:48;
};
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
The problem is that unsigned is 4 bytes thus 32 bits only. Otherwise that would work...
But, I think I've found the solution. From the MSDN[^], if you look at the conversion from unsigned long to long, the bit pattern is preserved so I suppose it will work from __int64 to unsigned long (except with a potential loss of data that will never occur).
|
|
|
|
|
Cedric Moonen wrote: The problem is that unsigned is 4 bytes thus 32 bits only. Otherwise that would work...
actually, that is true for unsigned , but not for unsigned:48 ; i could have written char:48 , the compiler would have behaved the same way...
but nevermind if you have a solution
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: actually, that is true for unsigned, but not for unsigned:48
Nope. unsigned is 32 bits and if you try to do unsigned:48 , you will have a compile error:
type of bit field too small for number of bits
|
|
|
|
|
Cedric Moonen wrote: you will have a compile error
ok
so i'm right when i say unsigned:48 will behave the same way as char:48
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
you did forget the __int64
struct TBTAddr{
unsigned __int64 _address:48;
};
This works like you intended
codito ergo sum
|
|
|
|
|
Cedric Moonen wrote: if the same as __int64 exists but for unsigned numbers
typedef unsigned __int64 ULONGLONG;
However, why not just use a bluetooth address ?
#include <ws2bth.h>
typedef ULONGLONG BTH_ADDR, *PBTH_ADDR;
typedef struct _SOCKADDR_BTH
{
USHORT addressFamily;
BTH_ADDR btAddr;
GUID serviceClassId;
ULONG port;
} SOCKADDR_BTH, *PSOCKADDR_BTH;
... i guess you mean you are modifying SOCKADDR_BTH::btAddr directly.
...cmk
Save the whales - collect the whole set
-- modified at 10:42 Thursday 24th November, 2005
|
|
|
|
|
Can we Implement Multiple Inheritance in vc++. If yes How.
infotechtata
|
|
|
|
|
|
Even for the class derived using Cobject it doesnt support
infotechtata
|
|
|
|
|
Cobject doenot not support multiple.So it's derived class cannot support multiple inheritance otherwise the previous line will contradict.
if want then go for non Cobject base class
|
|
|
|
|
don't ask for VC++ but for MC++ (managed C++) so...
as Visual C++ is standard complient, multiple inheritence is of course supported.
now, as C++/CLI target is the .NET framework, i think they limited this point to allow MC++ to coexist with other .NET languages.
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 4:22 Thursday 24th November, 2005
|
|
|
|
|
Hi,
when you resize a column in list control which event gets triggered?
|
|
|
|
|
OnBegintrack and OnEndtrack
|
|
|
|
|
How to add those event handlers?
|
|
|
|
|
<br />
BEGIN_MESSAGE_MAP(GridClass, CListCtrl)<br />
...<br />
<br />
ON_NOTIFY(HDN_BEGINTRACKA, 0, your_OnBegintrack)<br />
ON_NOTIFY(HDN_BEGINTRACKW, 0, your_OnBegintrack)<br />
ON_NOTIFY(HDN_ENDTRACKA, 0, your_OnEndtrack)<br />
ON_NOTIFY(HDN_ENDTRACKW, 0, your_OnEndtrack)<br />
<br />
END_MESSAGE_MAP()<br />
Note, that the control id of the CHeaderCtrl in CListCtrl is always zero;
thus, the second parameter (that is the control filter) in the ON_NOTIFYs is zero.
The "A" and "W" versions are for ANSI and UNICODE (Wide) environment;
in any given program run, only one or the other will become active.
Btw, OnBegintrack receives control, when the user grabs the right-side divider of a column with the mouse (starting resizing). OnEntrack receives control, when the user releases the divider.
The parameters are:
void yourClass::your_OnBegintrack(NMHEADER *nmheader, LRESULT* pResult)
void yourClass::your_OnBegintrack(NMHEADER *nmheader, LRESULT* pResult)
(*nmheader).iItem is the column index from zero.
*pResult should be set to TRUE if you don't allow resizing (TRUE indicates, that you processed the event completely), and FALSE, if you want MFC to finalize resizing.
|
|
|
|