Click here to Skip to main content
15,889,852 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: File writeing Pin
ThatsAlok26-May-06 1:39
ThatsAlok26-May-06 1:39 
AnswerRe: File writeing [modified] Pin
David Crow26-May-06 2:44
David Crow26-May-06 2:44 
AnswerRe: File writeing [modified] Pin
anwer_skk26-May-06 15:51
anwer_skk26-May-06 15:51 
QuestionDll C++ ==> Basic Pin
Russell'26-May-06 0:31
Russell'26-May-06 0:31 
AnswerRe: Dll C++ ==> Basic Pin
_AnsHUMAN_ 26-May-06 0:55
_AnsHUMAN_ 26-May-06 0:55 
GeneralRe: Dll C++ ==> Basic Pin
Russell'26-May-06 1:23
Russell'26-May-06 1:23 
AnswerRe: Dll C++ ==> Basic Pin
Eric Dahlvang26-May-06 4:39
Eric Dahlvang26-May-06 4:39 
QuestionProblem calling JavaScript from C++ [modified] Pin
alitokmen26-May-06 0:24
alitokmen26-May-06 0:24 
Hello. I'm currently working on a program which uses DHTML for user interface, and some elements of the interface need to be called on network events (so without the user clicking on anything). All samples on CodeProject use user clicks, and actually the other method fails! Let me explain.

I've actually created a new project to show the problem. You'll find it on http://temp.alishomepage.com/.RMI/JavaScript.zip. That project has been created to show the JavaScript call problem with the CHtmlView class: failure in the execScript method when called from a thread.

The project has been generated by Visual C++ 6 as a standard MFC project with CHtmlView as the view class. All changes in files are marked with the comment "JavaScript problem sample", and involve the JavaScriptView.h and .cpp files.

In JavaScriptView.h, there's an override of the OnDocumentComplete method.

In JavaScriptView.cpp, we add the two header files (atlbase.h and mshtml.h) as well as the the following function (headers are needed by the function):
<br />
    // Added for the JavaScript problem sample<br />
    DWORD WINAPI CallJScriptLater( LPVOID lpParam )<br />
    {<br />
        CComQIPtr<IHTMLDocument2> pHtmlDoc( ((CJavaScriptView*) lpParam)->GetHtmlDocument() );<br />
<br />
        CComPtr<IHTMLWindow2> pWnd;<br />
        pHtmlDoc->get_parentWindow( &pWnd );<br />
<br />
        CComBSTR bstrMember(CString("alert('boo')"));<br />
<br />
        // then simply execute it<br />
        CComBSTR vtlanguage(CString("javascript"));<br />
        VARIANT vresult;<br />
<br />
        pWnd->execScript(bstrMember,vtlanguage,&vresult);<br />
<br />
        return 0;<br />
    }<br />

And the added function is called on document complete:
<br />
    // Added for the JavaScript problem sample<br />
    void CJavaScriptView::OnDocumentComplete( LPCTSTR lpzsURL )<br />
    {<br />
        CHtmlView::OnDocumentComplete( lpzsURL );<br />
<br />
    #if 1<br />
        CallJScriptLater( this );<br />
    #else<br />
        CreateThread( NULL, 0, CallJScriptLater, this, 0, NULL);<br />
    #endif<br />
<br />
    }<br />

Finally, OnInitialUpdate has been changed:
<br />
    void CJavaScriptView::OnInitialUpdate()<br />
    {<br />
        CHtmlView::OnInitialUpdate();<br />
<br />
        // Changed for the JavaScript problem sample<br />
        Navigate2(_T("about:blank"),NULL,NULL);<br />
    }<br />

As a result, the program:

- On initializatio complete, loads about:blank
- When loading complete, calls executes the JavaScript: alert('boo')

That call may be in two ways:

- Directly (if the OnDocumentComplete has #if 1)
- Via a thread (if the OnDocumentComplete has #if 0)

PROBLEM: The direct call (JavaScript_directCall.exe) succeeds whereas the thread call (JavaScript_threadCall.exe) fails.

If anyone has a solution please let me know.

Thank you

S. Ali Tokmen
http://ali.tokmen.com
QuestionRe: Problem calling JavaScript from C++ [modified] Pin
Dennis Gourjii26-May-06 2:56
Dennis Gourjii26-May-06 2:56 
QuestionRe: Problem calling JavaScript from C++ [modified] Pin
alitokmen28-May-06 9:27
alitokmen28-May-06 9:27 
AnswerRe: Problem calling JavaScript from C++ [modified] Pin
alitokmen3-Jun-06 2:35
alitokmen3-Jun-06 2:35 
QuestionClient /Server architchture Pin
zahid_ash26-May-06 0:08
zahid_ash26-May-06 0:08 
AnswerRe: Client /Server architchture Pin
Renjith Ramachandran26-May-06 1:54
Renjith Ramachandran26-May-06 1:54 
AnswerRe: Client /Server architchture Pin
valikac26-May-06 6:36
valikac26-May-06 6:36 
Questionhow to convert CString to const WCHAR * Pin
NoName II25-May-06 23:59
NoName II25-May-06 23:59 
AnswerRe: how to convert CString to const WCHAR * Pin
VinayCool26-May-06 0:24
VinayCool26-May-06 0:24 
AnswerRe: how to convert CString to const WCHAR * Pin
Nibu babu thomas26-May-06 0:25
Nibu babu thomas26-May-06 0:25 
AnswerRe: how to convert CString to const WCHAR * Pin
Hamid_RT26-May-06 0:30
Hamid_RT26-May-06 0:30 
AnswerRe: how to convert CString to const WCHAR * Pin
ThatsAlok26-May-06 1:07
ThatsAlok26-May-06 1:07 
QuestionQuestions on CFileFind and CreateDirectory Pin
David L.S.25-May-06 23:57
David L.S.25-May-06 23:57 
AnswerRe: Questions on CFileFind and CreateDirectory Pin
ThatsAlok26-May-06 0:34
ThatsAlok26-May-06 0:34 
QuestionRe: Questions on CFileFind and CreateDirectory Pin
David Crow26-May-06 2:49
David Crow26-May-06 2:49 
AnswerRe: Questions on CFileFind and CreateDirectory [modified] Pin
David L.S.26-May-06 15:45
David L.S.26-May-06 15:45 
QuestionDialogbars event mapping Pin
ilgale25-May-06 23:54
ilgale25-May-06 23:54 
GeneralRe: Dialogbars event mapping Pin
Dennis Gourjii26-May-06 3:00
Dennis Gourjii26-May-06 3:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.