|
YaronNir wrote:
why does the OnOpenDocument method is not being called for the second time i am trying to open the same MRU?
Good question.
YaronNir wrote:
do i need to set a flag or something?
No.
Set a breakpoint on CWinApp::OnOpenRecentFile() and see what is going wrong. It calls OpenDocumentFile() ....
Hope that helps.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Ok,
i got into the core of the code. look at this:
CDocTemplate::Confidence CDocTemplate::MatchDocType(LPCTSTR lpszPathName,
CDocument*& rpDocMatch)
{
ASSERT(lpszPathName != NULL);
rpDocMatch = NULL;
POSITION pos = GetFirstDocPosition();
while (pos != NULL)
{
CDocument* pDoc = GetNextDoc(pos);
if (AfxComparePath(pDoc->GetPathName(), lpszPathName))
{
rpDocMatch = pDoc;
return <big>yesAlreadyOpen</big>;
}
}
CString strFilterExt;
if (GetDocString(strFilterExt, CDocTemplate::filterExt) &&
!strFilterExt.IsEmpty())
{
ASSERT(strFilterExt[0] == '.');
LPCTSTR lpszDot = _tcsrchr(lpszPathName, '.');
if (lpszDot != NULL && lstrcmpi(lpszDot, strFilterExt) == 0)
return yesAttemptNative;
}
return yesAttemptForeign;
}
this method returns (as i looked at the break point) "yesAlreadyOpen"
that is why nothing happens for me....
i still think i need to set a flag or something....
can u help ???
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Are you sure the document is actually being closed. It doesn't sound like it from what you're saying. Have a look at the pDoc that it is matching on. See if it has any views attached. I think there is a count you can see by looking at the CDocument. Or maybe you have other views besided the SDI view?
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
I think you are right,
but what am i missing in the close documents???
this is the code for the close request, i differ between 2 things
void CMyDoc::OnCloseDocument()
{
((CMainFrame*)AfxGetMainWnd())->OnFileClose();
if (((CMainFrame*)AfxGetMainWnd())->m_bCloseRequest)
CDocument::OnCloseDocument();
}
this is what i do in CMainFrame::OnFileClose() :
void CMainFrame::OnFileClose()
{
CMCEditorView* pView = (CMyView*)GetActiveView();
pView->ClearListCtrl();
SetWindowText(_T("My application - Untitiled"));
}
i differ between a closing application request and closing document request....the latter is just initializing the list control i have and set the title to be "untitled" and the first close the application.....
what am i missing?
thanks for all the help so far...
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Doesn't it simply come down to how: m_bCloseRequest is set. I don't think this is part of MFC, so it is a variable you are managing.
I certainly think that having CMyDoc know about and access CMainFrame is not good design. It should be the other way around. ie. Code in CMainFrame should call whatever CMyDoc etc. functions necesessary.
End of another long day of coding, so you won't hear any more from me until tommorrow.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
thanks for the design tip, i completely agree with you.
the m_bCloseRequest is something i manage.if i won't use a flag in the OnCloseDocument, then when i will choose from the menu 'File-->Close' the application will exit (i am using SDI).
that is why i needed that flag......
still i don't know how to solve my problem.....any other suggestions?
have a good night.....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi Yaron,
I'm a little confused about what the problem is now. I suggest you start a new thread, which outlines the problem as you now know it.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
I have an MFC application (VC6) which does not close correctly. Its an doc/view application. When I exit application the window was closed, but the process was not terminated. In debugger I have to stop debugging. In taskmanager I can see my application that should be closed.
I have set some breakpoints but they never arrived. E.g. I try ExitInstance.
Any idea where I can looking for?
|
|
|
|
|
First if you are using W98 etc. I'd restart Windows. Then set a breakpoint on CMainFrame::OnClose() and try again.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Thanx for answer.
I have Win2000. After restart I have same behaviour.
I set a breakpoint on CMainFrame::OnClose(). This breakpoint was reached. I set breakpoint on ~CMainFrame. This breakpoint was reached too.
After stopping debugger and stepping through code I went into CWinThread::PumpMessage(). I had to break the debugger to leave the application.
|
|
|
|
|
Would it be because there are still some of your process's thread running somewhere?
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thanx for answer.
There are threads. But what can I do?
|
|
|
|
|
Try to kill the threads by signaling a kill event (If you are using event to do multithread managemnent). But makesure you do not abort your main app thread before aborting the smaller one in order to do a proper clean up of your resources.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I was having the exact same problem. But, my application doesn't have threads. I ran into it because I commented out the following line from my document OnCloseDocument() function:
CDocument::OnCloseDocument();
Since the CDocument base class OnCloseDocument wasn't being called, the document was being left out there still open and my app couldn't terminate.
Mike Ellertson
|
|
|
|
|
Hi all, How can i tell if the cell contains the autodate?
I tried the following way and it didn't work..
<br />
CString cellPos;<br />
IndToStr(srIndex,scIndex,cellPos);<br />
Range aRange = asheet.GetRange(COleVariant((CString)cellPos),COleVariant((CString)cellPos));<br />
<br />
VARIANT va = aRange.GetValue();<br />
<br />
if(va.vt != VT_EMPTY )<br />
{<br />
CString valStr(va.bstrVal);<br />
if(va.vt == VT_DATE)<br />
{ <br />
MessageBox(valStr); <br />
} <br />
}<br />
|
|
|
|
|
Hi,
I've been developing MFC (HTMLView) applications for quite sometime now. In order to reference the images and javascript .js file I used the res://app.exe/ protocol and it works just fine. In my last project I need to use a java applet library .jar but no matter what I try it doesn't work unless the java applet is in a webserver. I have used the following approaches:
- codebase file://C:/dir/file.jar => failed
- archive file://C:/dir/file.jar => failed
- codebase res://app.exe/file.jar => failed
- archive res://app.exe/file.jar => failed
- codebase http://webserver/file.jar => success
- archive http://webserver/file.jar => success
The question is: How can I use a java applet in an MFC application without using a webserver?
Thanks a lot for any lights on this.
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Not sure exactly what you are trying to do, but an applet must run within Java, whether thats from the command line or within an HTML page. Look at http://www.juicystudio.com/tutorial/html/object.asp for information on how to embed in HTML, and you will need to use the 'codebase' attribute to specify the jar file.
|
|
|
|
|
Hi,
Thanks but I know how to embed the applet in my HTML page. As a matter of fact the problem only occurs when the applet is in the application resources like I can do with HTML pages, CSS files, GIF/JPG images, etc. Unfortunatelly it doesn't work with applets. Bellow you can see the part of the code I'm using to load the applet:
<applet code="SomeCtrl" width="350" height="250" name="myctrl"
="" archive="SomeCtrl.jar" viewastext="">
The thing is, if I use this code in a page in my webserver it works correctly since the jar is in the same directory as the page is. But I do wnat to load this applet from the application resources or externally using the file:///C:/folder/ protocol. I have tested the file:/// protocol and it works if the HTML page is on disk but in my case the HTML page is in the resource.
If it still not clear, please just let me know.
Thanks again,
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
I think there's a res: protocol for loading stuff from resources.
Steve S
|
|
|
|
|
I've already done that, and that's the problem it doesn't load the applet with the res:// protocol nor using the file:/// if the browser is embbeded in an MFC application. I could successfully write an html page to load in IE using both file:/// and http:// protocols but it comes to MFC application the only way to load the applet is using the http:// protocol, file:/// and res:// don't work.
Any suggestions.
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Sorry, didn't read the root message.
When you specify res://exe-name/resource, is the resource specified as HTML or JAR (or something else)..?
At the back of my mind is that there was some kind of problem with this on Win9x at some point.
Steve S
|
|
|
|
|
Hi Steve,
The jar file is specified as HTML, as it is the images and javascripts files. One funny thing is: I have just made a page in FrontPage using the file:/// protocol and the page works fine in the browser. If I use the same page in the application resources I got a Exception in the applet location in the page.
Thanks
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Short answer is: Sorry, can't be done.
When you start a Java applet, the browser passes the URL of the applet codebase to the Java Virtual Machine. The JVM is not going to understand a res: URL, and it is specifically prohibited from using a file: URL to load an applet because of all sorts of security problems.
What you should be able to do is run the applet as a regular Java application, in which case the JVM is free to access the local disk to find the Jar file. Often applets will also have a "main" function that lets you run them as a regular application; if yours does not you will have to write another Java class with a "main" function that creates a frame and starts the applet within it.
If your applet code needs tighter integration with your MFC app than running as a separate Java process will allow, you might have to look at the JNI (Java Native Interface), or whatever the equivalent is for Microsoft's brain-damaged JVM, to incorporate the Java runtime into your application.
|
|
|
|
|
Hi antlers,
That sounds amazingly harder than I thought. Would you think it would be a better idea to use ActiveX controls instead of applets? Would the use of ActiveX controls present the same kind (or maybe different) of problems?
Thanks a lot for your explanation. It helped me a lot to understand the process.
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
I guess ActiveX controls would work. You might need to have them installed along with the app on the machine instead of read from the resource file though.
Microsoft wrote some extensions to their JVM that allow Java stuff to be accessed as ActiveX controls, and I suspect that doing this would be the least work for you (unless recoding the applets is really easy). I haven't used Java this way myself, but check
http://www.codeguru.com/java/tij/tij0195.shtml
|
|
|
|