|
Hard to find indeed, even with the "raster" key word. The Internet is full of 3D Gouraud shading,... luckily one day I intend to do some 3D programming and I'll probably find my algo that time
It doesn't matter, I'll do it myself.
Thanks
Yarp
http://www.senosoft.com/
|
|
|
|
|
In Chris Maunder datagrid,does anybody know how can I overriden EndEdit() for a cell in my class?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
why don't you post this question on the grid article?
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
More people see it here.I post it there too.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I have a Dialog based MFC program, and in CMyDialogDlg::OnCreate I start my worker thread like this:
m_bThreadRun = TRUE;
HANDLE hThread = AfxBeginThread(MyWorkerThread, this);
if ( hThread == NULL )
MessageBox("Cannot start worker thread.");
While in my worker thread, I check for the flag from parent:
UINT MyWorkerThread(LPVOID pParam)
{
CMyDialogDlg * pDlg = (CMyDialogDlg *)pParam;
while ( pDlg->m_bThreadRun)
{
}
TRACE("exit from the worker thread");
return 0;
}
In order to terminate this worker thread, I did this:
CMyDialogDlg::OnClose()
{
m_bThreadRun = FALSE;
CDialog::OnClose();
}
But what troubles me is:
1. The trace line of my worker thread function "exit from the worker thread" was never printed.
2. When the program ended, this will appear in my Visual studio debug window:
etected memory leaks!
Dumping objects ->
thrdcore.cpp(166) : {54} client block at 0x017B4558, subtype 0, 112 bytes long.
a CWinThread object at $017B4558, 112 bytes long
Object dump complete.
what I am missing here? How can I terminate this worker thread gracefully?
Thanks a lot for your help!
|
|
|
|
|
You should WaitForSingleObject after setting m_bThreadRun to FALSE. Also, add 'volatile' modifier to m_bThreadRun.
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
I add the following modifications:
OnCreate()
{
m_hMyThread = AfxBeginThread(...);
}
OnClose()
{
m_bThreadRun = FALSE;
WaitForSingleObject(m_hMyThread, 1000);
}
but WaitForSingleObject will fail and the reason is "The handle is invalid. ". why?
FYI, I have added the volatile specifier to my worker thread checking.
|
|
|
|
|
When the worker thread terminates, the Object (CWinThread) will clean up and deallocate any resources associated with it, including itself. So after termination, the CWinThread variable will be invalid as stated.
To avoid this you will need to tell the class not to automatically delete itself on termination.
try this:
OnClose()
{
m_hMyThread.m_bAutoDelete = FALSE;
m_bThreadRun = FALSE;
WaitForSingleObject(m_hMyThread, 1000);
delete m_hMyThread;
m_hMyThread = NULL;
}
|
|
|
|
|
I see. Thank you very much!
|
|
|
|
|
when i do this, i usually have a loop in the parent thread that's checking for a flag from the worker thread.
worker:
1.do something
2.check the bCancel flag, if it's set, set the bDone flag
2.set a bDone flag when done
parent:
1.launch thread
2.if the worker thread's bDone flag is set, kill the thread, else do something else and check the bDone flag again, later.
3.if i need to kill the worker thread, set a bCancel flag, wait for it's bDone flag.
-c
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
one thing I am confused here:
is it possible for the worker thread to do a "return" when it finds that bCancel flag is set? It seems it is a lot more easier.
|
|
|
|
|
the worker still has to set "bDone", so that the parent will know that the thread is really done. just setting bCancel isn't enough, since the worker might still be busy.
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
|
I get back from a query the result that the number of records found is 0.
Immediately after I process commands with this rs. It crashes. So I want to put in an exit like
if(rs has zero records)
{
do this
return
}
However I dont know how to state 'rs has zero records'....in ADO. I dont see an isEmpty type function in the docs.
I am using ADO.
Thanks,
ns
|
|
|
|
|
GetRows() perhaps? (I don't know ADO).
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Or maybe you could check its EOF property? (Sorry, just guessing.)
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
When the Recordset is empty, both the BOF and EOF flags are set,
so...
if (rs.IsBOF() && rs.IsEOF())
{
do this
return
}
should be what you want....
Blade[DMS]
|
|
|
|
|
This didnt pass the compiler: IsEOF is a dao thing, EOF is not an ADO thing either. getting close though....
Thanks for the responses,
ns
OOPS! I think I need ->EOF not .EOF....I'm trying it now.
DArn! That wasnt it.
|
|
|
|
|
|
guess what - I tried that too....I really did.
Compiling...
Train1View.cpp
C:\Train1View.cpp(2473) : error C2059: syntax error : '('
C:\Train1View.cpp(2474) : error C2143: syntax error : missing ';' before '{'
C:\Train1View.cpp(2475) : error C2039: 'AfxMessageBox' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
C:\Train1View.cpp(2488) : error C2039: 'm_photoDb' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
C:\Train1View.cpp(2488) : error C2039: 'GetPhotoBuffer' : is not a member of '_Recordset'
c:\trainer\a_tr series\tr8b\release\msado15.tlh(1696) : see declaration of '_Recordset'
Error executing cl.exe.
|
|
|
|
|
Mail me Train1View.cpp . Looks like you got a misplaced -> .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I think it depends how you import the ADO code, but in my version "EOF" is renamed to "adoEOF" because of the conflict with the C EOF define for end of file returned by fgetc etc...
try...
if ((m_photoDb.m_pRecordsetPhoto->BOF == TRUE)
&& (m_photoDb.m_pRecordsetPhoto->adoEOF == TRUE))
{
AfxMessageBox ("empty rs");
return;
}
Blade[DMS]
|
|
|
|
|
I checked for the recordcount and used that instead. SO the original mystery is unsolved, but I have a workaround..
|
|
|
|
|
I would be careful on how you use the recordcount method. I think this is just a water mark of the number of records you have iterated through.
The count that it returns is only correct if you have iterated through the whole recordset.
You have to use EOF and BOF to work out if you have any records.
When you Import the ADO object you usually rename EOF to what ever you want
|
|
|
|
|
If you are using namespaces then you may need to say something like ADODB::EOF or ADODB::adEOF etc. Check the .tlh file and see what the constant is.
|
|
|
|