|
Exactly what are you trying to do and what is the problem? You could always post a message from your worker thread to your main window (which is owned by your main thread) and do your strange IsMessageQueueEmpty() and FudgeForceRedrawOfMainWindow() thing there, but even without knowing the problem, I think your solution is questionable.
Edit: I was thinking about it, and i only managed to think up one classic mistake in which this would be necessary. Immediately after creating a worker thread, you wait for the worker thread to finish in the main thread which of course means that the main thread is unable to handle messages.
-- modified at 8:50 Wednesday 28th June, 2006
|
|
|
|
|
My Problem is that I have to use CDAO* MFC classes for an application nad they are not multithreaded. Using another library / collection is not an option (boo hoo!). Opening tables and querys using the dereived tables takes (sometimes) ages. During this time, the UI does not process the normal messages (WM_DRAW etc). To get around this, I am trying to create a worker thread that will "Force" the Main window (CMainFrame) to update it´self. Some functions within the CMainFrame have an iterationary style, therefore I can call my "FudgeForceRedrawOfMainWindow()" every n steps in the iteration. Unfortuntly, the DB functions are not, for example CDaoDatabase.Execute(...); That is why I am trying to call the "FudgeForceRedrawOfMainWindow()" from a worker thread, i.e. create the worker thread before calling the function (CDaoDatabase.Execute(...)) and then closing the thread once the function returns.
Trying to post a message from the worker thread to the main thread (Registerd windows message WM_USER+n) does not work as they are not processed. Until AFTER the CDao* function returns.
Hope this answers your question, and that is why I cannot do it any other way, and why I have posted my problem here...
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
You can't get your main thread to redraw as it has to wait for CDaoDatabase.Execute(...) to return.
You got the idea upside down. The worker thread is the one that should perform your lengthy processing ie. CDaoDatabase.Execute(...) should be in the worker thread and not the other way around. If you only wish to have one query execute at a time you can always disable the main window (and maybe pop up a progress bar window - one of those in which the progress just bounces left and right) before you start the thread. And re-enable the window (and kill the progress bar window) when the worker thread posts a message to the main thread that the execution has completed.
-- modified at 9:03 Wednesday 28th June, 2006
|
|
|
|
|
Yes I agree totally, that is how I would like to do it, but the MFC CDao classes do not allow the use with multiple threads and changing the library is not an option (even to the standard CDatabase, CRecord would be enough) As I am "only" "maintaining" this application. Only the main thread (CWinApp) can have access. It was just a thought...
Thanks anyway
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Did you call AfxDaoInit()/AfxDaoTerm() in the worker thread?
|
|
|
|
|
Of course, the problem is in the non existent multi-threading capabilities of the MCF DAO library. I´ll have to live with what I have and wait until I have the time to re-implement the whole DB access of the application (perhaps ADO, have to play around with that before I decide) Until then...
Thanks for the time and help you have given...
mfg
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Hi this is my first post in this forum. I am having problem with a portion of codes in C++. Hope you guys can help me solve this matter. Sorry if it's too long and also my terrible English. Thank you all in advance.
I have a function ValidateInvCtnReturn() which process the invoice inputted by user and return AE. The function is retriving few data from inv_lot table which are invoiceNo, cartonNo, ReturnStatus and few more.
Depending on the input, there are 4 posibilites of AE being returned which are:
- AE_NOINVOICE => The invoice is not found in the database
- AE_DUPLICATERC => The invoice has a RC status in ReturnStatus field
- AE_DUPLICATERA => The invoice has a RA status in ReturnStatus field
- AE_NOERROR => The invoice has passed all the checkings and no error
I have tried several attempts on retrieving the table.
___________________________________________________________
1. Input a non-existing invoice, existing invoice with RC status, existing invoice with RA status
Result: As expected, program returns AE_NOINVOICE, AE_DUPLICATERC, AE_DUPLICATERA in order successfuly.
2. Input an existing invoice with no returnstatus (returnStatus field is NULL in database)
Result: I am expecting the program to prompt me the "SUCCESS" message. Instead it prompts database error, which is a default error message whenever there is a problem with the database.
Following is the code calling ValidateInvCtnReturn() function:
if(ValidateInvCtnReturn(invoiceStr)!=AE_NOERROR){
DisplayMessage("No error");
}else{
DisplayMessage("SUCCESS");
}
//The ValidateInvCtnReturn() function
int ValidateInvCtnReturn(const char* invoiceNo)
{
//DisplayStatus("Validate Invoice");
char sourceStr[SRC_LEN+1];
int ae = AE_NOERROR;
HRESULT hr = S_OK;
ADODB::_RecordsetPtr Rs = NULL;
ostrstream osSrc(sourceStr,sizeof(sourceStr));
osSrc << "SELECT InvoiceNo, cartonNo, ReturnStatus FROM inv_lot "
<< "WHERE InvoiceNo='" << invoiceNo << "' AND "
//<< "CartonNo ='" << CartonNo << "' AND "
<< "DivCode='" << gDC << "' AND "
<< "FactCode='" << gFC << "'"
<< ends;
_bstr_t Connect( gConnectStr );
_bstr_t Source ( sourceStr );
try{
TESTHR(hr = Rs.CreateInstance( __uuidof( ADODB::Recordset )));
Rs->Open( Source, Connect, ADODB::adOpenForwardOnly, ADODB::adLockReadOnly, ADODB::adCmdText);
if (Rs->BOF){ // no records returned
DisplayMessage(GetAppError(ae = AE_NOINVOICE));
// ae = AE_NOINVOICE;
// DisplayMessage("No Invoice");
}
else if (stricmp(((char*)(_bstr_t)Rs->Fields->Item["ReturnStatus"]->Value),"RC") ==0){
DisplayMessage(GetAppError(ae = AE_DUPLICATERC));
// ae = AE_DUPLICATERC;
// DisplayMessage("Duplicate RC");
}
else if (stricmp(((char*)(_bstr_t)Rs->Fields->Item["ReturnStatus"]->Value),"RA") ==0){
DisplayMessage(GetAppError(ae = AE_DUPLICATERA));
// ae = AE_DUPLICATERA;
// DisplayMessage("Duplicate RA");
}
else if ((Rs->Fields->Item["ReturnStatus"]->Value.vt == VT_NULL) ==0){
DisplayMessage(GetAppError(ae = AE_NOERROR));
ae = AE_NOERROR;
DisplayMessage("NULLY");
}
Rs->Close();
Rs = NULL;
}
catch (_com_error &e )
{
ae=AE_DBERROR;
DisplayComError(e);
}
return ae;
}
|
|
|
|
|
alpha error LNK2019: riferimento al simbolo esterno "struct Gradient __cdecl gradient(double (* const)[3][3],double)" (?gradient@@YA?AUGradient@@QAY122NN@Z) non risolto nella funzione "void __cdecl Mogi(class ambient &,class source &)" (?Mogi@@YAXAAVambient@@AAVsource@@@Z)
alpha error LNK2019: riferimento al simbolo esterno "void __cdecl bound_x(double,double (* const)[3],double)" (?bound_x@@YAXNQAY02NN@Z) non risolto nella funzione "void __cdecl Mogi(class ambient &,class source &)" (?Mogi@@YAXAAVambient@@AAVsource@@@Z)
alpha error LNK2019: riferimento al simbolo esterno "void __cdecl bound_y(double,double (* const)[3],double)" (?bound_y@@YAXNQAY02NN@Z) non risolto nella funzione "void __cdecl Mogi(class ambient &,class source &)" (?Mogi@@YAXAAVambient@@AAVsource@@@Z)
alpha fatal error LNK1120: 3 esterni non risolti
Any idea ?
|
|
|
|
|
may be you are not linking to the directory whose fucntions you are calling. YOu need to mention the name of the library in the Additional Dependencies option.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Did you include the cpp files in which these functions or structs are defined (or the library) ?
BTW, it would be nice that you translate the error messages in english.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Either the cpp files contains the implementation should be included in you work space or provide the lib file in the linker->input (under project setting)
SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
My Blog | Understanding State Pattern in C++
|
|
|
|
|
I have a project with UI language is English. I have to support french language for my project. I have 1 problem and i think you can help me. UI has done.
I have a problem: MessageBox. Buttons on the my MessageBox are OK - Cancel but in the French are OK - Annuler.
I using MB_OKCANCEL.
I have not solution for this problem (from OK-Cancel to OK-Annuler). Example
Please help me soon!
Thank you very much
Papai's
And please say me about PleaMessageBoxIndirect. with sample.
Thanks and I sorry to inconvenience.
Software Engineer
|
|
|
|
|
These buttons depends on the language installed for windows. So it is not dependent of your application but rather of the language of windows. If you install your program on a french windows, the buttons will be in french.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Oneway to is to define two string table one is for french and another one in english
see the sample snippet
#define LANG_FRENCH
CMyDialog::OnInitDialog()
{
CString strText;
#ifdef LANG_FRENCH
LoadString(ID_OK_FRNCH);
#else LANG_FRENCH
LoadString(ID_OK_ENG);
SetDlgItemText(IDB_OK,strText
}
remove the definition, if you wanna support english
SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
My Blog | Understanding State Pattern in C++
|
|
|
|
|
try :-MessageBoxEx
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
Quick question:
Does anyone know how to invoke the Microsoft HTML Help workshop to compile a project from the command line? I feel like I'm being really dumb, but there seems to be a shortage of information on the subject.
Joel Holdsworth
-- modified at 8:31 Wednesday 28th June, 2006
|
|
|
|
|
|
Sorry yeah, but I actually want to compile a project from the command line, not just run the workshop
Joel Holdsworth
Want to give me a job this summer?
Take a look at my online CV
|
|
|
|
|
Joel Holdsworth wrote: Does anyone know how to invoke the Microsoft HTML Help workshop to compile a project from the command line?
I'm not sure if this is the only way, it is the only way I found that semi works.
Create help project using the worthless HMTL Help Work Shop,
Add all of the needed files to it.
Command line
Cd C:\Program Files\HTML Help Workshop>
C:\Program Files\HTML Help Workshop>hhc.exe <path to="" *.hhp="" file="">
The only option that I found was verbose output.
To compile a hhp file from VS 6
Add the hhp (HTML Help Project) file your VS workspace.
Click "Project"
Scrol down to "Project Settings"
Change "Settings" drop down box to "Win32 Release"
Locate the "*.hhp" file
Select Custom Build in the right hand tab, add the following to the "Commands" edit box
start hhc.exe hlp\$(InputName).hhp
if errorlevel 1 goto :Error
if not exist "hlp\$(InputName).chm" goto :Error
copy "hlp\$(InputName).chm" $(ProjDir)
copy "hlp\$(InputName).chm" $(OutDir)
goto :done
:Error
echo hpp\$(InputName).hhp(1) : error:
type "hhp\$(InputName).log"
:done
and this to the "Outputs" edit box
$(OutDir)\$(TargetName).chm
$(WkspDir)\$(TargetName).chm
Joel Holdsworth wrote: I feel like I'm being really dumb, but there seems to be a shortage of information on the subject.
Don't feel that way, there is an incredible lack of docos on this topic.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Hey thanks, that's really helpful!
Joel Holdsworth
|
|
|
|
|
Joel Holdsworth wrote: thanks
Your welcome.
Personally I compile my help files with the release builds. Save a few of my hairs from going gray (as a result of using HTML Work Shop Crap wear).
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
hi,
when i build my proj i got the error
playfile.obj : error LNK2001: unresolved external symbol _IID_IBasicVideo2
how to resolve this
regards,
gansjob
|
|
|
|
|
You hqve to link with the appropriate library in which this symbol is defined.
Go in the project settings, linker tab, input category and add the library name in the 'Additional Dependencies' option.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
but i don't know which lib to link
|
|
|
|
|