|
pankaj0dm wrote: Create() is also not getting called since its created dynamically.
How do you create a control dynamically then?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
how to kill ui thread. i have to kill the thread while cancelling the dialog how to do this
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
I would suggest that you avoid terminating a thread. Instead, have an event object shared between your dialog and the thread. When the user hits Cancel, signal the event indicating to the worker thread that it should exit. When the thread's handle becomes signaled, it has exited and you can continue (or you can wait with a timeout on the thread's handle, and terminate it if it does not exit normally within a certain amount of time).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
For a UI thread a more proper way is to exit the thread via its message pump rather than using events. Post a WM_QUIT message to the UI thread and it will exit itself. [Of course inside its message loop,the thread should expect WM_QUIT message].
--
=====
Arman
|
|
|
|
|
Yeah, but this does not sound like a UI thread, otherwise there would not really be a reason to kill it from another GUI element. (Because it would have its own cancel button )
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Really. Though the OP said it is;
how to kill ui thread.
--
=====
Arman
|
|
|
|
|
Doh! Missed it....!
That is what I get for applying the Reasonable Man Test...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
A "UI thread" is actually a misnomer. It's simply a thread with a message pump, whereas a "worker thread" is a thread without a message pump.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
the other post cover important details, like you should close a thread by the means its ment to be closed to avoid memory leaks and other nasty stuff.
but if you really want to do it...
i used these function is a app that had to close other applications regardless of memory leaks.
here it is.. should still work i hope.
<br />
DWORD lpProcessID, lpThreadID, lpExitCodeThread, lpExitCodeProcess;<br />
HWND WndHandle;<br />
<br />
#ifdef _DEBUG_MSGBOXS_<br />
AfxMessageBox(_T("Checking for Class"),MB_OK);<br />
#endif<br />
<br />
if(NameIsOfClass == TRUE)<br />
{<br />
WndHandle = ::FindWindow(AppName,NULL);
}<br />
else<br />
{<br />
WndHandle = ::FindWindow(NULL,AppName);<br />
}<br />
if(WndHandle != NULL)<br />
{<br />
#ifdef _DEBUG_MSGBOXS_<br />
AfxMessageBox(_T("Class found"),MB_OK);<br />
#endif<br />
<br />
lpThreadID=GetWindowThreadProcessId(WndHandle,&lpProcessID);
HANDLE ThreadHandle = OpenThread(THREAD_ALL_ACCESS,TRUE,lpThreadID);
HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS,TRUE,lpProcessID);
<br />
if(GetExitCodeProcess(ProcessHandle,&lpExitCodeProcess) == 0 )
{<br />
AfxMessageBox(_T("GetExitCodeProcess function Failed with Error:"), MB_OK);<br />
return FALSE;<br />
}<br />
<br />
if(GetExitCodeThread(ThreadHandle,&lpExitCodeThread) == 0)<br />
{<br />
AfxMessageBox(_T("GetExitCodeThread function Failed with Error:"), MB_OK);<br />
return FALSE;<br />
}<br />
<br />
TerminateThread(ThreadHandle,lpExitCodeThread);
TerminateProcess(ProcessHandle,lpExitCodeProcess);
}<br />
else<br />
{<br />
#ifdef _DEBUG_MSGBOXS_<br />
AfxMessageBox(_T("Failed: Class may not be running"),MB_OK);<br />
#endif<br />
}<br />
that has the key functions in and works.
or atleast it did when i made it a few years back.
hope that helps
p.s i'd dont use this for threads i created, if you created the thread you need to kill it safely in the onclose event or ondestroy etc
|
|
|
|
|
when i move a tab key the static control does not show the tab key movement.How to do that please help me?
i have placed the image on static control.
|
|
|
|
|
prathuraj wrote: when i move a tab key the static control does not show the tab key movement.How to do that please help me?
Make sure the control has the WS_TABSTOP style (it's off by default). Then you'll need to call DrawFocusRect() when the control gains focus, and again when the control loses focus.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
prathuraj wrote: when i move a tab key the static control does not show the tab key movement.
By design. The static control does not take input, so tabbing through the controls will never stop on a static control.
(I assume you mean static control, not button control?)
|
|
|
|
|
Hi,
I tried to build an MFC dll(originally written VC++ 6.0) to VC++2005. I am getting the folloing error Error error C2065: 'abuf' : undeclared identifier.
The code is as follows:
static void
free_biobuf(abuf)
biobuf *abuf;
{
if(abuf == NULL)
return;
free(abuf) ;
}
What should i do..
Regards, Eswari
|
|
|
|
|
this syntax is old C.
i advise you to change the header of your function into this :
static void free_biobuf(biobuf *abuf) {
}
by the way, you're probably getting the error because you moved the code from a .c file into a .cpp file, didn't you ?
|
|
|
|
|
I built the same dll in debug mode without any changes in the code. The same is not building in release mode. What could be the reason. Any help in this will be appreciated.
Regards, Eswari
|
|
|
|
|
have you made the code modification i gave you ?
how do you know it's not working in release mode ? getting an error ? when ? what is it ?
i cannot help if you don't provide infos, hey !
|
|
|
|
|
Sorry for not giving clear picture.
I made the code change as you suggested. It worked. I mean that compiler error is gone. But it is giving other compiler errors.
In debug mode i did not get any compilers which i am getting in release mode(including the one i posted yesterday. not a single compiler error). I am getting 996 errors in release mode.
What should i do.
|
|
|
|
|
so as i said, i cannot guess what's wrong unless you provide relevant infos...
what are the first errors ?
have you tried to do a rebuild all ?
|
|
|
|
|
Hi,
The first error is c2065 error (the one i posted). I made changes in the code as you said. It worked. But now i am getting C2079 error for the line
static struct xdr_ops xdrposix_ops;
and C2197 error for the line
return (XDR_PUTLONG(xdrs, (long *)fp));
Where XDR_PUTLONG definition is like this
#define XDR_PUTLONG(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
. Like this i am getting many error. I did a rebuild. Still it did not work.
The same is being built in debug more without any errors.
Regards, Eswari
|
|
|
|
|
hey man, are you stupid, or you just don't to get helped fast ?
if i tell you C2079 and C2197, do you know what error it is exactly ?
i doublt about it. for me, it's the same... and I won't look at the msdn just because you're too lazy to copy past the exact error message from the compiler output
|
|
|
|
|
Sorry.
This is what i am getting
error C2079: 'xdrposix_ops' uses undefined struct 'xdr_ops' for this line
static struct xdr_ops xdrposix_ops in the code.
|
|
|
|
|
Also i am getting the following error
error C2440: '=' : cannot convert from 'int (__cdecl *)(NC_string *)' to 'int (__cdecl *)(void)' for this line of coding in the file
xlen_funct = NC_xlen_string ;
where first one is function defined as int (*xlen_funct)() ;
second one is function defined as int NC_xlen_string(NC_string *cdfstr)
Any help is appreciated.
Regards, Eswari
|
|
|
|
|
subramanyeswari wrote: xlen_funct = NC_xlen_string ;
where first one is function defined as int (*xlen_funct)() ;
second one is function defined as int NC_xlen_string(NC_string *cdfstr)
then if the 2 propotypes are different, you cannot assign one to the other...
|
|
|
|
|
hi,
i am writting wrapper over C++ functions to call them in C. the problem is with return type const char*. it is compling properly. but it cant find dll entry point for the function.
the function in .h file is
const char* __declspec(dllimport) __stdcall myfunction(par1, par2);
i am using Visual Studio 2005 IDE. when i move mouse cursor over myfunction it shows return type as int.
what is the problem?
|
|
|
|
|
huuuuu, a wrapper on C++ functions for C ?
isn't it the opposite that we usually do ?
what kind of functions are you wrapping ?
moreover, you say that the dll entry point is not found. in what is this related to const char* ?
|
|
|
|