|
I am giving full method that I written
<br />
<br />
BOOL CEtmenApp::InitInstance()<br />
{<br />
<br />
if (!AfxSocketInit())<br />
{<br />
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);<br />
return FALSE;<br />
}<br />
<br />
#ifdef _AFXDLL<br />
Enable3dControls();
#else<br />
Enable3dControlsStatic();
#endif<br />
<br />
<br />
<br />
if (instanceChecker.PreviousInstanceRunning())<br />
{<br />
AfxMessageBox(_T("Previous version detected, will now restore it"), <br />
MB_OK);<br />
instanceChecker.ActivatePreviousInstance();<br />
return FALSE;<br />
}<br />
<br />
<br />
<br />
CEtmenDlg dlg;<br />
m_pMainWnd = &dlg;<br />
<br />
<br />
if (!instanceChecker.PreviousInstanceRunning())<br />
instanceChecker.TrackFirstInstanceRunning();<br />
<br />
<br />
<br />
CString cmdLine = m_lpCmdLine;<br />
CString token = GetNextCmdLineToken(cmdLine);<br />
while (!token.IsEmpty())<br />
{<br />
if (token == '-')<br />
{<br />
token = GetNextCmdLineToken(cmdLine);<br />
if (!token.CompareNoCase("arazi"))<br />
{<br />
dlg.m_araziDizini = GetNextCmdLineToken(cmdLine);<br />
} else if (!token.CompareNoCase("coklu_calisma"))<br />
{<br />
dlg.m_bCokluCalisma = true;<br />
} else if (!token.CompareNoCase("kostur"))<br />
{<br />
dlg.m_bKostur = true;<br />
} else if (!token.CompareNoCase("cc_sunucusu"))<br />
{<br />
m_strCCServer = GetNextCmdLineToken(cmdLine);<br />
}<br />
} else dlg.m_senaryoDosyasi = token;<br />
token = GetNextCmdLineToken(cmdLine);<br />
}<br />
<br />
<br />
int nResponse = dlg.DoModal();<br />
if (nResponse == IDOK)<br />
{<br />
}<br />
else if (nResponse == IDCANCEL)<br />
{<br />
}<br />
<br />
return FALSE;<br />
}<br />
<br />
<br />
|
|
|
|
|
This is not working for your dialog-based application because at the time you call
PreviousInstanceRunning() you do not have a valid window handle for your application.
I suggest you find a mechanism to plug the window handle of your dialog, during OnInitDialog , into the hMainWnd member of the CWindowInstance class. Then it will probably work for you.
Because inside the ActivatePreviousInstance is the call like this:
HWND hWindow = pInstanceData->hMainWnd;<br />
if (hWindow)
And if you understood the code and had single stepped through it, you would find that this handle is probably always NULL (0) and the IsWindow call will fail every time.
|
|
|
|
|
Greetings,
A few friends and I have recieved funding for a project that we are working on. We're still in the planning stages but we've hit a stone wall. We've ordered 2 new IBM eServers that arrive in a few months to experiment on. Only problem is, none of us have experience writing server applications that need to ultilise more than 1 server. I was wondering if anyone might be able to recommend any good books on the subject?
Any help will be greatly appreciated,
Thank you,
Gordon R. Speirs
|
|
|
|
|
Dear Sir/Maddam,
I am kumar studying MCA from Bangalore University.
I'm in 3Sem, in this sem i've to do a project on Encryption using
C/C++.
So please can u guide me on going further.
Waiting for response.
(kumar)
|
|
|
|
|
|
Hi all ,
If I have an empty destructer , does it automatcly calls to the delete() function ?
or should I include it within it ?
thanks very much
|
|
|
|
|
why should it call delete ? to destry you object instance ? no, because the destructor is not there to destroy the object but to free the possible memory it could have alocated from its construction to the moment the destructor is called.
basically, if you allocate some memory dynamically from within the object methods (sonctructor included), free the memory at last in the destructor. if you don't, then let it empty. you could also use it to reset the fields to their default values...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
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
|
|
|
|
|