|
Now that's really odd...
Have you tried creating the thread with AfxBeginThread?
I'm asking because Microsoft claims the other methods aren't MFC-safe.
|
|
|
|
|
Hello, HAND
Thank you for your reply. Using AfxBeginThread instead of the CreateThread function doesn't unfortunately solve the problem... If you want to see the exact project, please look at http://temp.alishomepage.com/.RMI/JavaScript.zip
I think the issue is due to the fact that the one of those objects there (CHtmlView, presumably) is created in mono-thread mode and does not accept script calls from other threads. Even worse, if the host has Internet Explorer 5 installed (default Windows 2000 SP4 configuration) the script call makes the program crash! See http://support.microsoft.com/kb/318426
I'm starting to have a solution idea, thought: creating the entire HTML output using the IHtmlDocument2::write method and then calling JavaScript from there. It seems to work, but has a majot disadvantage: every JavaScript call adds at least one line to the source code!
Another idea would be JavaScript to "ping" the C++ at regular intervals and C++ to catch that and respond using a JavaScript call.
Thank you for your reply.
S. Ali Tokmen
http://ali.tokmen.com
|
|
|
|
|
Hello, everyone
First of all, I would like to thank everyone who has helped identifying the cause of this issue and, of course, proposed ideas of solution.
The problem seems to be that the scripting object of the IHtmlDocument interface (in its current -Windows XP SP2- implementation) has some protection against access to its inner elements from external threads. As a result, calls from other threads to function that get the content of an HTML document or call scripts on it is prohibited.
There's a solution, thought: create a class which would try to call a script using standard methods and on failure queue the request. That class should of course also have a method to execute all queued calls (you can use CList for that queue).
Then, you have to find a method to get in the same thread as the CHtmlDocument interface... Which is not that hard: first, put the setInterval("window.navigate('refreshjs:')",1000) line in your HTML document as a JavaScript. This will, every second, try to navigate to refreshjs:
Second, you have to modify the OnBeforeNavigate method of CHtmlView to make it call the queue execution method if a navigation to refreshjs: is requested (note that you can also stop navigation at that point -refreshjs: is not a valid protocol anyway!)
Using this method, JavaScript calls that fail will be re-executed at most one second later... And shall now not fail, except if you've really called a function that doesn't exist!
S. Ali Tokmen
http://ali.tokmen.com
|
|
|
|
|
Hi,
I am using CSocket class to transfer a file.
I am creating 2 socket at server side that are listening, one is doing normal communication with client to send and recevie normal information , 2nd on is used when file is transfer, so there will be no intruption when file and normal information is transfered,
Is it a better approach to have 2 sockets as i have in my application?
Regards.
|
|
|
|
|
zahid_ash wrote: one is doing normal communication with client to send and recevie normal information , 2nd on is used when file is transfer
What you meant by Normal communication and File Transfer? in both case you are send/rcving data?
Loka Samastha Sukhino Bhavanthu..!!!
( May all beings be happy and free )
|
|
|
|
|
|
|
Hi Noname,
this will help u
http://www.codeproject.com/cpp/data_conversions.asp
Regards,
Vinay Charan.
|
|
|
|
|
CString::GetBuffer(...);
CString csStr = _T( "Somestring" );
LPCTSTR szBuff = (LPCTSTR)csStr;
LPTSTR szBuff1 = csStr.GetBuffer();
LPTSTR and LPCTSTR are WCHAR* and CONST WCHAR* type respectively.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
wchar_t *pwsz1=NULL;
CString str;
str="Hi";
pwsz1=str.AllocSysString();
-------------------------------------
WCHAR pwsz[1024];
CString Test2="Hi";
MultiByteToWideChar( CP_ACP,0,Test2,-1,pwsz,sizeof( pwsz));
------------------------------------
WCHAR* pwsz2;
CString Test3="Hi";
pwsz2=new (WCHAR);
MultiByteToWideChar( CP_ACP, 0, Test3,-1, pwsz2, sizeof( pwsz2 ) );
whitesky
|
|
|
|
|
NoName II wrote: how to convert CString to const WCHAR *
mbstowcs
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
SupportCRY- Child Relief and You
|
|
|
|
|
Hi, there,
I would like to realize a function that can create a folder called "data" in a directory if it doesn't exist. Here is my code:
CString strPath ="D:\\temp";
SetCurrentDirectory(strPath);
CFileFind ff;
BOOL btmp1 = ff.FindFile("data");
if(btmp1)
{
BOOL btmp2 = ff.FindNextFile();
if(!ff.IsDirectory())
{ //*************************//
if(!CreateDirectory(LPCTSTR(strPath+"\\data"), NULL))
{
ff.Close();
return FALSE;
}
}
}
else
{
if(!CreateDirectory(LPCTSTR(strPath+"\\data"), NULL))
{
ff.Close();
return FALSE;
}
}
ff.Close();
return TRUE;
Then I noticed a strange thing. If there is a file in "D:\\temp" named data, the CreateDirectory function after //***// part always fails. Please note that the existing data is a file without extension, not a folder. So I added a line to the //***// part:
CFile::Rename(strPath+"\\data", strPath+"\\data.bak");
then the CreateDirectory function can succeed and the folder data is created. Sadly, I won't be able to change the file data.bak to data anymore because there is a folder with the same name.
How could this happen? Or is it because I missed anything ? Your help will be greatly appreciated.
David
|
|
|
|
|
David L.S. wrote: I would like to realize a function that can create a folder called "data" in a directory if it doesn't exist. Here is my code:
Instead of CFIleFind for Checking existence of Folder or File, why not you use Direct api PathFileExists()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
SupportCRY- Child Relief and You
|
|
|
|
|
So what are you expecting CreateDirectory() to do when a file named c:\temp\data already exists?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi,
Thanks for your answers. I now know the reason I couldn't do that. Thanks anyway.
David
-- modified at 22:04 Friday 26th May, 2006
|
|
|
|
|
I've developed a single document application and I use Dialog bars.
I've derived a class from CDialogBar in order to map OnCtlColor and
I use that class as base class.
Then I've derived a class (from my base class)for any dialog bar and
I use its instances in CMainFrame instead of default CDialogBar instance
created by Visual Studio.
I've written a specific class for any dialog bar in order to manage
its events in that class instead of in CMainFrame class.
(Otherwise, having many dialog bars CMainframe class becomes a very
big and complex class).
My problem is the following:
Visual Studio allows me to create methods for any event of my dialog
bar in the specific class but at runtime that methods are never called.
It seems that there is no real association between UI controls and methods
written in my class (and added with class wizard).
All works if I copy that methods and the related MESSAGE_MAP code
in CMainframe class.
Why my classes doesn't catch dialog bars event while CMainframe do it ??
Thanks a lot.
|
|
|
|
|
Visual Studio 7.0 I presume? It's full of such bugs and once in a while I think of rolling back to my favorite 6.0.
|
|
|
|
|
Is there a way for me to post a windows authentication/login dialog -- get the user to enter his username and password?
I don't want access to this information, I would just like him to re-authenticate himself to me.
I would like to use this to block access to part of my application unless he completes this re-authentication.
Where would I look for this?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
Hi
I liked your way of thinking
and tried a little
tye this
system("C:\\WINNT\\system32\\rundll32.exe user32.dll,LockWorkStation");
Regards
Anil
|
|
|
|
|
Peter Weyzen wrote: ...I would just like him to re-authenticate himself to me.
Do you really think this is a good idea? Users typicaly don't like to repeat themselves. I think it would be a better design if your application checked the security level/group membership of the logged-in user to determine what features to turn on/off.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Well, David -- thanks for your concern...
But, I'd like to find out how to do this.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
-- modified at 14:13 Friday 26th May, 2006
|
|
|
|
|
Then I suggest you look into LogonUser() . It validates the user name and password and returns True if they are valid.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Thanks for the clue.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
I need to debug a function defined in a statically linked library attaching to a process compiled with that library. I have two .bsc's, one for the library and one for the .exe. I have tried changing the name of the .lib bsc to the exe .bsc, but doing this way I can't set breakpoints in the function of the library that I need to debug.
|
|
|
|
|
.bsc doesn't have anything to do with debugging. this is the browse information for symbols which Visual studio uses for locating symbol defenitions inside the source code.
To debug what u need is the .pdf file. you have to compile both the library and exe. if the pdb file time stamp is same that of lib, then you can break into the code.
you can chk whther the symbol files loaded correctly by pressing ctrl + alt + u inthe debug mode.
cheers...milton kb
|
|
|
|