|
Before you do your heavy processing, pump the message queue.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Ah, I see what you're trying to do. I'd use this mechanism:- Your view's
OnInitialUpdate() simply displays the CLoading modal dialog.
CLoading does the actual initialization (by posting a custom WM_COMMAND to itself in it's OnInitDialog() .
- When the initialization completes (in the handler of your fake command),
CLoading simply exits (by calling CDialog::OnCancel() ) and control returns to your view. Imho, this is much easier than using a modeless dialog and having to pump the message queue.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Eh? I'm from Barcelona..........
The stuff I want in the lengthy initialization is all data owned by the view (I might not be understanding your suggestion correctly....). SO if I launch the modal dlg then send a messsage to the view to do the lengthy stuff, then call OnCancel once back in the modal dlg?
I anm trying this now, but not sure if thats what you maent...
Appreciate your help,
ns
|
|
|
|
|
I tried it...this time I dont even see a blank CDialog or anything!!!!
Appreciate your help,
ns
|
|
|
|
|
You know naathing? Sorry, I don't buy that!
You wrote:
SO if I launch the modal dlg then send a messsage to the view to do the lengthy stuff, then call OnCancel once back in the modal dlg?
Not quite. When you launch the modal dialog from the view, give it a pointer to the data that belongs to the view. That way it (the dialog) can happily do all the initialization and if you like, even display progress and allow the user to cancel.
When the initialization completes, the dialog ends itself (by calling CDialog::OnOK() ). If an error occured, it can end itself by calling CDialog::OnOK() . That way the view knows what happened.
It's possible that the view isn't completely setup until after it finishes executing OnInitialUpdate() . If this is the case, just have OnInitialUpdate() post a fake command (IDC_DO_INIT) to itself, and do the modal dialog thing in that command's handler. If the init fails, you can programmatically close the view after displaying an informational message.
Hope this helps.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Well,
The trick you suggested does one good thing. My main UI comes up fast now (blank) since the lengthy processing is delegated to the PosTMessage to itself. Its (the main UI)not active till that postMessage wraps up but at least the user can be reassured that somethings happening. It automatically hourglasses itself ---- so even though I STILL dont have the informing dialog, my purpose is quite well served. An inadvertent workaround.....
So....I guess I am okay with this........but still never saw the cdialog at all!!!
Whats really bizarre is that earlier in OnInitialUpdate I instantiate a vector of modeless bozes and show images in them >These show up fine, as the very first thing!!!!
So its happy to do that, but not to put text in my later CDialogs label.............
Appreciate your help,
ns
|
|
|
|
|
You wrote:
but still never saw the cdialog at all
Is the dialog defined within OnInitialUpdate() ? If so, you won't see it because it's destructed the moment it goes out of scope. You need to make it a member of the view.
What I've suggested is a pretty standard way of showing progress as a view opens up. I suspect you're doing sumpin' wrong.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I am doing
CLoading cLoading(this) in the PostMessage handler.
THe .h file doenst like me to say (this) to pass the parent in (when I make it a member). SO I guess I shall do a GetPArent or something.....
Right?
|
|
|
|
|
Yes, that seems right. Your handler should do something like this:
CLoading cLoading (this);
cLoading.setInitData (ptrToView'sData); // so that cLoading can do what it needs to do
long nStatus = cLoading.DoModal(); // display dialog - it will dismiss itself
if (nStatus == IDOK) // init completed successfully
....;
else { // init failed
AfxMessageBox ("Error!"):
close the view;
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Heres the rub:
I have not done ifndefs def in my .h files. my trView.h has loads of stuff #includes in it. If I include it in cLoading.h it screams bloody murder. So I tried putting it within the ifndef ....long string ....made by classwizard for the trView.h file. It compiles okay, but I guess it doesnt include it because CLoading says huh...whats CTRView*. However if I do GetParent I get a genereric CWnd* back and use that to post to the view to trigger the lengthy calc. Instead of doing parentPtr->LengthyFunc(); directly from the CDialog. A few e xtra steps...........
I have tried to ages to be able to do circular includes but have never succeeded.
Thanks so much for all the input though.......I know you're a busy guy...
Appreciate your help,
ns
|
|
|
|
|
Okay.....I did what you said I think and couldnt directly run the lengthyFUnc from the CDialog but POstMessaged the parent instead. Well------------now the UI comes up in flash!!!!!! Everything populated and calculation all finished and ready to go.
I dont know why.
HOwever.........since now even my biggest database loads in a flash, I never get to see the CDialog even if its being spawned. However with this instant flashing speed its unnecesary anymore. ITs amazing! But a really terrific outcome.
Thanks thanks thanks!
Appreciate your help,
ns
|
|
|
|
|
Last post on this...I promise. Why the lengthy calc took so little time with the REmote triggering became clear....It didnt do any calc!!!! No wonder. So I am going to avoid this strategy altogether .
So pls dont worry about it anymore. Just another mystery...every aspect of this problem. I tried Send as well as Post...just to be sure.
Appreciate your help,
ns
|
|
|
|
|
It seems like you need better (ideally complete) separation of your GUI and data. CLoading shouldn't know anything about the parent view's tree controls or other GUI elements. All you should pass back and forth is a pointer to a data structure.
I'll send you a sample FormView app with a progress dialog this weekend. It's probably easier to look at the code and compare it with your app than discuss it here!
It really is very simple. I promise!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have a VC++ Dialog Application and want to add a Excel component like the way one does it in MS word . I want to view the Excel chart as a component on my dialog . Can this be done ? If yes where should i get resources ? Thanks
|
|
|
|
|
You can use the MS-Chart ActiveX which is shipped with Visual C++.
François
|
|
|
|
|
As far as my preliminary search I can just plot a graph . I need the same functionality of a excel workbook where I can write data to a cell .My consideration is that I can use 3rd party grid's but I need to add a lot of data to one column . Is there any control that u might know that can take a lot of text(somehting like a log file in a cell !).
|
|
|
|
|
Here is my code
CStdioFile myfile,newFile;
CString inString = "";
char* fString="";
//char *pattern="((\\s*lmp\\s*))";
char *pattern="\\s*(LMP\\([0-9]+\\)).*)\\n";
//***********The line below when reached //causes abnormal termination,dont know /whats the problem Please help
RegEx exp(pattern,TRUE);
std::string wholeFileStr="";
CString wholeFileString = "",filname="c:\\test23.txt",nName="c:\\MunnaMunna.txt";
// Read entire file into a string.
try{
myfile.Open(filname,CFile::modeRead | CFile::typeText, NULL);
newFile.Open(nName,CFile::modeWrite , NULL);
}
catch (CFileException e)
{
MessageBox("The file " + filname + " could not be opened for reading", "File Open Failed", MB_ICONHAND|MB_ICONSTOP|MB_ICONERROR );
//return FALSE;
//myfile.Close();
//newFile.Close();
}
try{
while (myfile.ReadString(inString))
{//newFile.WriteString(inString);
//wholeFileString += inString;
wholeFileStr = inString.GetBuffer(2);
//
//const char *wholeFileStr=(LPCTSTR)inString;//.GetBuffer(10);
// RegEx exp("(\\*sLMP((0-9)+\)).*)\n$",TRUE);
// RegEx exp("(\s*LMP\([0-9]+\))",TRUE);
// RegEx exp("\s*LMP",TRUE);
if(exp.Search(wholeFileStr))
{
//strcpy(fString,exp[1].c_str());
CString sd(exp[1].c_str());
AfxMessageBox(sd);
}
else if(fString!="")
{ CString temp(fString);
//CString temp2(wholeFileStr);
temp+=inString;
temp+="\n";
//strcat(fString,wholeFileStr);
//strcat(fString,"\n");
newFile.WriteString(temp);
}
}
//***************************************************************
}
catch (CFileException e)
{
MessageBox("The file " + filname + " could not be opened for reading", "File Open Failed", MB_ICONHAND|MB_ICONSTOP|MB_ICONERROR );
//return FALSE;
//myfile.Close();
//newFile.Close();
}
newFile.Close();
myfile.Close();
|
|
|
|
|
My guess would be that RegExp is throwing an exception because the regular expression passed to it in the constructor is invalid (i'm not a regexp guru though, so am not able to verify that your regexp is correct). I suggest you check your expression, and also check the docs for RegExp - it may throw an exception that tells you exactly what is wrong. At the moment you are ignoring any such exceptions, and hence the program terminates.
Dave
|
|
|
|
|
DOCs say the 2nd parameter of the constructor of RegEx is a RegexOptions (A bitwise OR combination of RegexOption enumeration values) and not a BOOL.
|
|
|
|
|
I am using the CRegex class as am not good in using stl,i know now the pattern to be used for searching is not correct but dont know what the problem is ,basically what i am trying to do is look for lmp() in each line and remove new lines after all the lines that dont have a line wih lmp() beofre them,that way all the lines will start with lmp()
|
|
|
|
|
I am looking in the dev environment and cant find (vc6) the setting which lets it get past handled exceptions....
Appreciate your help,
ns
|
|
|
|
|
|
Ah! Thanks!
Appreciate your help,
ns
|
|
|
|
|
I've been doing COM/DCOM for several years now but not a lot with windowing
or controls. I want to create an executable that behaves as follows:
1. Singleton process that is a window (dialog would be fine) that can be
launched from another app (toolbar). Currently we use this paradigm with
VB components but want to do this one in C++.
2. This main window will contain a dynamic number of buttons that when
pressed will display a modeless dialog that contains some static data (i.e.
no user interaction other than close).
3. The buttons in the main window contain both text and a bitmap. These
buttons are updateable (i.e the text and bitmaps change) when certain
underlying statuses change.
Right now I have this prototyped in MFC with a main app window. The
buttons are subclassed CButtons and I create as many as I need when the app
starts. The buttons are ID'd so when the user presses it I know which type
of dialog to open. The real problem is how to wrapper all this in COM so
that this app can be created/started once via COM and then handle the
windowing/controls. I guess I'm more comfortable with MFC and not used to
CDialogImpl and the like. Anyone got any pointers or examples to start
from? Thanks!
|
|
|
|
|
(1)How can i use a dll in VC++ which is designed or written in VB ??
please help me as soon as possible.
it is very urgent for my project.
Thank- You
sukhdeep
|
|
|
|