|
|
Thank you all for your advises..
I had changed wcscpy() to _tcscpy() to send the message from app1 to app2,
app2 seems like only got the first character of the message from app1 but as Davide Crow suggested, I wrote a function that checked every single character of the message and found out that message char was store in every other index in the array. for example, H0E0L0L0O
<br />
void App2::GetReqStr(TCHAR* str, DWORD bufSize)<br />
{<br />
TCHAR temp[BUFSIZE];<br />
int j=0;<br />
for (int i=0;i<bufSize;i++)<br />
{<br />
if(str[i] != 0)<br />
{<br />
temp[j]=str[i];<br />
j++;<br />
}<br />
}<br />
_tcscpy(str,temp);<br />
str[j]=NULL;<br />
}<br />
So App2 gets the message what app1 sent, but the problem is that app1 is not getting the same message what App2 sent back.
for example, App2 gets message "Hello" from app1 and app2 send "YES" to app1 back. however, using the following same methods, ReadFile() and WriteFile(), and app1 got junk messages from app2. Why is that??? it is driving me crazy. I cant' find the errors.. why I dont' get the same message that is sent by app2????????
<br />
CString msg = "HELLO";
<br />
TCHAR chBuf[BUFSIZE];<br />
_tcscpy(chBuf,msg);<br />
fSuccess = ReadFile( hPipe, chBuf,BUFSIZE,&cbRead, NULL);
<br />
fSuccess = WriteFile( hPipe,chBuf,_tcslen(chBuf)*sizeof(TCHAR*),&cbWritten,NULL);
<br />
|
|
|
|
|
If one program is UNICODE and the other is ANSI, then you have to decide on your protocol.
I see you have two choices:
1. App1 SENDS Unicode and App2 CONVERT the Unicode to ANSI. If App1 RECEIVES a message from App2, then App1 must conver the Ansi sent by App2 back to Unicode.
2. App1 CONVERTS Unicode to ANSI and sends ANSI to App2. If App1 RECEIVES a message from App2, then App1 must converts the Ansi back to Unicode.
You need to investigate WideCharToMultiByte (UNICODE to ANSI) and MuliByteToWideChar (ANSI to UNICODE) string conversion functions.
Also, you might want to SEND the NUL terminator along with your string, although it is not strivtly necessary as long as you add one at the receiving end.
fSuccess = WriteFile( hPipe, chBuf, (_tcslen(chBuf) + 1) * sizeof(TCHAR), &cbWritten, NULL);
|
|
|
|
|
i defined a windows message to detect the time that the user did not move the mouse and made any key press using hooks.
however the hook that i attached for the mouse callback function stops sending when the screen saver starts to work. both the mouse move and the keyboard hit send the same user defined message to the program, but the keyboard callback function keeps posting messages when the screensaver is working the mouse messages are stopped even when i turn on the screen saver property and apply it.
i want it to keep on tacking the user inputs until i tell it not to, not until the screensaver starts.
what can i do to prevent SC_SCREENSAVE to interfere with the mouse tracking? i thought of catching the SC_SCREENSAVE messages with a third hook and disabling the screen saver, or not letting the screen saver to receive the message, but i don't know how to. or is there a way to directly disable the screen saver?
i will be happy if someone can help me solve te problem...
|
|
|
|
|
Check the key in the registry at:
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]
Set this to 0
"ScreenSaveActive"="0"
Or set yourself as the screensaver
"SCRNSAVE.EXE"="logon.scr"
"ScreenSaverIsSecure"="1"
Or Set a really big timeout
"ScreenSaveTimeOut"="6000000"
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
thank you.
i still don't know how to reach the keys. can you give me a hint on how to write the code for doing that?
|
|
|
|
|
Check RegOpenKeyEx Family of API
you can also search CP for classes encapsulating registry access
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
I'm building a dll that is staticaly linked to MFC .
I'm trying to add an ActiveX control to a dialog in the dll.
After adding the ActiveX to the dll dialog I called the dll from an exe file. I always get an error for the create function (I use the following code to launch the dialog)
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CMainDialog *m_MainDialog;
m_MainDialog = new CMainDialog;
m_MainDialog->Create(IDD_DIALOG_MAIN,NULL);
m_MainDialog->ShowWindow(SW_SHOW);
If there is no ActiveX on the dialog this code works fine.
Please help.
Thanks.
avivhal
|
|
|
|
|
You probably forgot to put AfxEnableControlContainer into your DLLs InitInstance...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I was writing some code to export some data to an Excel chart.
Here's a snippet of the code that is intended to add Sheets to a workbook .
From my apps point of view everything is ok , But when I exit or leave Excel without saving this file I get a MessageBox with a Memory Error . I was wondering if u'd have some suggestions . I am including "excel8.h" in my code. Thanks
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
_Application app;
Workbooks books;
_Workbook book;
Worksheets sheets;
_Worksheet sheet;
Range range;
Font font;
Range cols;
CStatusDialog statusDialog;
Interior interior;
int sheetIndex = 0 ;
int cycleStepCount=0;
string data;
char *p;
char c[20];
statusDialog.Create(IDD_DIALOG6,(CWnd*)this);
statusDialog.ShowWindow(SW_SHOW);
statusDialog.CenterWindow();
if(cyclePt.cycleCount){
// Start Excel and get Application object.
if(!app.CreateDispatch("Excel.Application")) {
AfxMessageBox("Couldn't start Excel and get Application object.");
statusDialog.ShowWindow(SW_HIDE);
return;
}
//Get a new workbook.
books = app.GetWorkbooks();
book = books.Add(covOptional);
//Get the first sheet.
sheets =book.GetSheets();
int ct=0;
if(cyclePt.cycleCount<=3)
ct =0;
else
ct = cyclePt.cycleCount-3;
// Excel Does seem to crash when I do this
if(ct)
sheets.Add(covOptional,covOptional,COleVariant((long)ct),covOptional);
app.SetVisible(TRUE);
app.SetUserControl(TRUE);
return ;
|
|
|
|
|
During loading HTML page into HTMLDocument (IHTMLDocument2.write method), how could be launching of scripts in that page prevented?
|
|
|
|
|
I am using MFC (the CDatabase and CRecordset classes) to query a database which has some simple Chinese text stored. My code is built in unicode mode and everything works fine, except that all the chinese characters got converted to the ? character (ascii code 63).
This does not have anything to do with the database because I tried another .NET program with no problem (I was able to get chinese characters from the database). Any help is appreciated. Thanks.
My articles and software tools
|
|
|
|
|
The '?' implies that the Chinese character can't be mapped into the existing encoding (which defaults to Windows-1252). To properly support Unicode data, you should store your data in CString objects (which are UTF-16), or in UTF-8 char* strings. If you choose the latter, you'll need to explicitly transcode() the string using the correct target encoding (i.e. UTF-8).
FYI, I've found a bug in the default (no args) version of the Xerces (C++) transcode() method, which fails silently when it encounters a char that can't be mapped. Instead of replacing an unmapped char with '?' , the method inserts a '\0' , effectively truncating the returned string.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks for the info.
I traced into my source code, when I call the CRecordset::GetFieldValue method, a database field is supposed to be read into a CString variable. I checked the actual value, it is already 63s (question marks). That means something happened between the database and the MFC dll which converted the text into question marks.
I am 100% sure that I am building and debugging unicode version of my program.
My articles and software tools
|
|
|
|
|
I use the Classes by Carlos Antolini (ADO)
and have no problem storing and reading cyrilic
unicode strings.
|
|
|
|
|
|
Xiangyang Liu wrote:
That means something happened between the database and the MFC dll which converted the text into question marks.
Yes, or perhaps the app that loaded the database from a Unicode source performed an invalid transcode and stored question marks into the db? I recommend querying the db outside your app to find the culprit.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It turns out the MFC dll (6.0) does not support ODBC unicode data. The unicode string types SQL_C_WCHAR and SQL_C_WVARCHAR cannot be found from the source code.
The ODBC drivers I used may not support unicode either (version 3.5 or higher is required).
I will have to use ADO or .NET.
My articles and software tools
|
|
|
|
|
|
When you see ? it means a Unicode->ANSI conversion was done, but your current ANSI code page did not contain equivalent characters. WideCharToMultiByte() is the underlying API, and it inserts ? for unconvertible characters.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Four fonts walk into a bar. The bartender says "Hey - get out! We don't want your type in here."
|
|
|
|
|
Thanks, Mike. I read your article about testing unicode programs, it is very helpful.
I suspect this specific problem is in the ODBC driver, it may not support unicode properly or it is misconfigured. I will keep looking tomorrow.
My articles and software tools
|
|
|
|
|
It turns out the MFC dll (6.0) does not support ODBC unicode data. The unicode string types SQL_C_WCHAR and SQL_C_WVARCHAR cannot be found from the source code.
The ODBC drivers I used may not support unicode either (version 3.5 or higher is required).
I will have to use ADO or .NET.
My articles and software tools
|
|
|
|
|
Use the ADO if possible.
We converted from using ODBC to the ADO and it works fine for us - Japanese, Chinese, German, French, Spanish, and English. There may be other languages in use I am not aware, like Russian (Cyrillic text).
Also, I found that the ADO access to the database was much quicker.
|
|
|
|
|
I am trying to Write a Desktop application. I have used alot of char based Program compliers such as Basic, C, Fortran, Pascal, Cobol, Etc...
I am haveing a real tough time understanding the C++ Visual Layout and how it operated with Just writing the code...
Lots of screens and not much information on how or what.
Is there A training Module or is there a step through tutorial. Or maybe even someone that can step me through the basic operation.. Im sure once i grasp the concept and get the Rudementary questions answered I will be off and running...
I am working on a project that reequres me to use this and i need to complete this as quickly with out the cost of cutting corners to complete this project.
Thank you very much.
Rilliams
Rilliams2@cs.com
|
|
|
|
|
Download The PDF[^]
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|