Discussion:
Change the font
(too old to reply)
VKumar
2006-04-17 09:35:56 UTC
Permalink
hi,
I want to display a string in message box. The string is "My name is xyz".
The function is MessageBox(). I want to change the font of this string. I
want its size should be 20 and font "Times new roman".
Ajay Kalra
2006-04-17 14:34:50 UTC
Permalink
Instead of using MessageBox, use a CDialog and insert a CStatic in it.
Display the text in CStatic and change its font at run time using
SetFont. I dont think you can change the font of MessageBox controls.

---
Ajay
VKumar
2006-04-18 04:40:22 UTC
Permalink
I don't want to use the string on dialog box. I am sending this string from
exe to dll. My application is MFC application. This application use a dll. I
pass this string from application to dll in a function of dll. String is
displaying as garbage in dll. If i change the font of string in exe and pass
this to dll then the string will display correctly in dll function. I don't
have code of dll. I use dll by LoadLibrary.
Post by Ajay Kalra
Instead of using MessageBox, use a CDialog and insert a CStatic in it.
Display the text in CStatic and change its font at run time using
SetFont. I dont think you can change the font of MessageBox controls.
---
Ajay
Scott McPhillips [MVP]
2006-04-18 12:43:26 UTC
Permalink
Post by VKumar
I don't want to use the string on dialog box. I am sending this string from
exe to dll. My application is MFC application. This application use a dll. I
pass this string from application to dll in a function of dll. String is
displaying as garbage in dll. If i change the font of string in exe and pass
this to dll then the string will display correctly in dll function. I don't
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not have a
font. Can you explain what you mean by "change the font of string?"
--
Scott McPhillips [VC++ MVP]
VKumar
2006-04-18 13:10:20 UTC
Permalink
OK
What i am doing? I have a dll. This dll has a function which takes a string
as input and display it in a message box( or on a dialog box). I don't have
code of this dll. I use this dll by loadlibrary then i call that function of
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i call
function of dll and pass a string. This function display that string in a
message box.But i don't see correct string in message box which i passed, i
see some garbage value. I think this is the problem of font. If i change the
font of string in my MFC application and i pass it in dll function then the
dll function will display the correct string .

Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i passed. I took
this dll from an organization so i don't have code of this dll and i have
only this option to use the dll.
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this string from
exe to dll. My application is MFC application. This application use a dll. I
pass this string from application to dll in a function of dll. String is
displaying as garbage in dll. If i change the font of string in exe and pass
this to dll then the string will display correctly in dll function. I don't
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not have a
font. Can you explain what you mean by "change the font of string?"
--
Scott McPhillips [VC++ MVP]
VKumar
2006-04-18 13:15:09 UTC
Permalink
I don't pass unicode string in function of dll. I pass ANSI string.
I have also tried by taking a unicode string and converting it to ansi
string by Widechartomultibyte. but don't get success.
Post by VKumar
OK
What i am doing? I have a dll. This dll has a function which takes a string
as input and display it in a message box( or on a dialog box). I don't have
code of this dll. I use this dll by loadlibrary then i call that function of
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i call
function of dll and pass a string. This function display that string in a
message box.But i don't see correct string in message box which i passed, i
see some garbage value. I think this is the problem of font. If i change the
font of string in my MFC application and i pass it in dll function then the
dll function will display the correct string .
Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i passed. I took
this dll from an organization so i don't have code of this dll and i have
only this option to use the dll.
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this string
from
Post by Scott McPhillips [MVP]
Post by VKumar
exe to dll. My application is MFC application. This application use a
dll. I
Post by Scott McPhillips [MVP]
Post by VKumar
pass this string from application to dll in a function of dll. String is
displaying as garbage in dll. If i change the font of string in exe
and
Post by VKumar
pass
Post by Scott McPhillips [MVP]
Post by VKumar
this to dll then the string will display correctly in dll function. I
don't
Post by Scott McPhillips [MVP]
Post by VKumar
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not have a
font. Can you explain what you mean by "change the font of string?"
--
Scott McPhillips [VC++ MVP]
David Wilkinson
2006-04-18 14:30:24 UTC
Permalink
Post by VKumar
I don't pass unicode string in function of dll. I pass ANSI string.
I have also tried by taking a unicode string and converting it to ansi
string by Widechartomultibyte. but don't get success.
Post by VKumar
OK
What i am doing? I have a dll. This dll has a function which takes a
string
Post by VKumar
as input and display it in a message box( or on a dialog box). I don't
have
Post by VKumar
code of this dll. I use this dll by loadlibrary then i call that function
of
Post by VKumar
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i call
function of dll and pass a string. This function display that string in a
message box.But i don't see correct string in message box which i passed,
i
Post by VKumar
see some garbage value. I think this is the problem of font. If i change
the
Post by VKumar
font of string in my MFC application and i pass it in dll function then
the
Post by VKumar
dll function will display the correct string .
Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i passed. I took
this dll from an organization so i don't have code of this dll and i have
only this option to use the dll.
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this string
from
Post by Scott McPhillips [MVP]
Post by VKumar
exe to dll. My application is MFC application. This application use a
dll. I
Post by Scott McPhillips [MVP]
Post by VKumar
pass this string from application to dll in a function of dll. String
is
Post by VKumar
Post by Scott McPhillips [MVP]
Post by VKumar
displaying as garbage in dll. If i change the font of string in exe
and
Post by VKumar
pass
Post by Scott McPhillips [MVP]
Post by VKumar
this to dll then the string will display correctly in dll function. I
don't
Post by Scott McPhillips [MVP]
Post by VKumar
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not have a
font. Can you explain what you mean by "change the font of string?"
--
Scott McPhillips [VC++ MVP]
VKumar:

As Scott says, DLL's and strings do not have fonts, so you cannot fix
this just by changing the string. But if your app is unicode and the DLL
isn't, you must certainly convert your string to the current ANSI code
page before sending it to the DLL, or you will not even be able to
display strings that contain ASCII characters only. Make sure you can do
this, at least.

If your DLL is ANSI, I don't think it is possible to display an
arbitrary string, but I think a message box should be able to display
any character in the local code page.

David Wilkinson

=========================
VKumar
2006-04-18 14:57:03 UTC
Permalink
My MFC application is unicode application. I pass ansi string to dll. First
i load a string from string table into TCHAR type array, then i change this
unicode string to ansi string by using widechartomultibyte where i pass
CP_ACP as code page. I know this way only.
you must certainly convert your string to the current >ANSI code page
before sending it to the DLL.

I am doing this by widechartomultibyte. While my string is written in
Japanese language and My MFC application is running on japanese OS.
Please tell the solution.
Post by VKumar
I don't pass unicode string in function of dll. I pass ANSI string.
I have also tried by taking a unicode string and converting it to ansi
string by Widechartomultibyte. but don't get success.
Post by VKumar
OK
What i am doing? I have a dll. This dll has a function which takes a
string
Post by VKumar
as input and display it in a message box( or on a dialog box). I don't
have
Post by VKumar
code of this dll. I use this dll by loadlibrary then i call that function
of
Post by VKumar
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i call
function of dll and pass a string. This function display that string in a
message box.But i don't see correct string in message box which i passed,
i
Post by VKumar
see some garbage value. I think this is the problem of font. If i change
the
Post by VKumar
font of string in my MFC application and i pass it in dll function then
the
Post by VKumar
dll function will display the correct string .
Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i passed. I took
this dll from an organization so i don't have code of this dll and i have
only this option to use the dll.
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this string
from
Post by Scott McPhillips [MVP]
Post by VKumar
exe to dll. My application is MFC application. This application use a
dll. I
Post by Scott McPhillips [MVP]
Post by VKumar
pass this string from application to dll in a function of dll. String
is
Post by VKumar
Post by Scott McPhillips [MVP]
Post by VKumar
displaying as garbage in dll. If i change the font of string in exe
and
Post by VKumar
pass
Post by Scott McPhillips [MVP]
Post by VKumar
this to dll then the string will display correctly in dll function. I
don't
Post by Scott McPhillips [MVP]
Post by VKumar
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not have a
font. Can you explain what you mean by "change the font of string?"
--
Scott McPhillips [VC++ MVP]
As Scott says, DLL's and strings do not have fonts, so you cannot fix
this just by changing the string. But if your app is unicode and the DLL
isn't, you must certainly convert your string to the current ANSI code
page before sending it to the DLL, or you will not even be able to
display strings that contain ASCII characters only. Make sure you can do
this, at least.
If your DLL is ANSI, I don't think it is possible to display an
arbitrary string, but I think a message box should be able to display
any character in the local code page.
David Wilkinson
=========================
David Wilkinson
2006-04-18 16:11:11 UTC
Permalink
Post by VKumar
My MFC application is unicode application. I pass ansi string to dll. First
i load a string from string table into TCHAR type array, then i change this
unicode string to ansi string by using widechartomultibyte where i pass
CP_ACP as code page. I know this way only.
you must certainly convert your string to the current >ANSI code page
before sending it to the DLL.
I am doing this by widechartomultibyte. While my string is written in
Japanese language and My MFC application is running on japanese OS.
Please tell the solution.
[snip]

Maybe you are not using WideCharToMultiByte correctly. Try a MessageBoxA
on the converted string to see if it displays correctly. If this works,
but your DLL still doesn't, then the DLL must be doing something to the
string.

David Wilkinson
VKumar
2006-04-19 13:20:49 UTC
Permalink
WideCharToMultiByte working correctly and messagebox display correct string.
I don't have code of DLL. Is there no other solution to solve this?
I think we should have facility to change the font of any string.
Post by David Wilkinson
Post by VKumar
My MFC application is unicode application. I pass ansi string to dll. First
i load a string from string table into TCHAR type array, then i change this
unicode string to ansi string by using widechartomultibyte where i pass
CP_ACP as code page. I know this way only.
you must certainly convert your string to the current >ANSI code page
before sending it to the DLL.
I am doing this by widechartomultibyte. While my string is written in
Japanese language and My MFC application is running on japanese OS.
Please tell the solution.
[snip]
Maybe you are not using WideCharToMultiByte correctly. Try a MessageBoxA
on the converted string to see if it displays correctly. If this works,
but your DLL still doesn't, then the DLL must be doing something to the
string.
David Wilkinson
David Wilkinson
2006-04-19 14:40:40 UTC
Permalink
Post by VKumar
WideCharToMultiByte working correctly and messagebox display correct string.
I don't have code of DLL. Is there no other solution to solve this?
I think we should have facility to change the font of any string.
VKumar:

One more time: strings don't have fonts; they have encodings. If you can
display the string using MessageBoxA in your application, then the DLL
must be doing something to the string.

1. Have you tried this with a pure ASCII string?

2. What is the signature of the function you call in the DLL?

But really, if you do not know anything about this DLL, you may not be
able to use it.

David Wilkinson
VKumar
2006-04-20 04:42:49 UTC
Permalink
Post by David Wilkinson
1. Have you tried this with a pure ASCII string?
Yes, MFC application display it correctly.
Post by David Wilkinson
2. What is the signature of the function you call in the DLL?
functionname(char *);
David Wilkinson
2006-04-20 12:58:16 UTC
Permalink
Post by VKumar
Post by David Wilkinson
1. Have you tried this with a pure ASCII string?
Yes, MFC application display it correctly.
Post by David Wilkinson
2. What is the signature of the function you call in the DLL?
functionname(char *);
I meant: can the DLL display a pure ASCII string correctly? Most (all?)
encodings agree on the ASCII characters.

functionname("David");

Can you not get information on what encoding the DLL expects the string
to be in? Doesn't it have any documentation? If not, you may be out of luck.

David Wilkinson

Ajay Kalra
2006-04-19 01:29:50 UTC
Permalink
When you debug, can you see the string correctly which has beeb converted to
ANSI.

Additionally, you should not mix and match MFC types (UNICODE and MBCS) in
the same process space. This would cause other headaches, such as NULL
mainwindow, app etc in a DLL.

--
Ajay Kalra [MVP - VC++]
Post by VKumar
My MFC application is unicode application. I pass ansi string to dll. First
i load a string from string table into TCHAR type array, then i change this
unicode string to ansi string by using widechartomultibyte where i pass
CP_ACP as code page. I know this way only.
you must certainly convert your string to the current >ANSI code page
before sending it to the DLL.
I am doing this by widechartomultibyte. While my string is written in
Japanese language and My MFC application is running on japanese OS.
Please tell the solution.
Post by VKumar
I don't pass unicode string in function of dll. I pass ANSI string.
I have also tried by taking a unicode string and converting it to ansi
string by Widechartomultibyte. but don't get success.
Post by VKumar
OK
What i am doing? I have a dll. This dll has a function which takes a
string
Post by VKumar
as input and display it in a message box( or on a dialog box). I don't
have
Post by VKumar
code of this dll. I use this dll by loadlibrary then i call that
function
Post by VKumar
of
Post by VKumar
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i call
function of dll and pass a string. This function display that string
in
Post by VKumar
a
Post by VKumar
Post by VKumar
message box.But i don't see correct string in message box which i
passed,
Post by VKumar
i
Post by VKumar
see some garbage value. I think this is the problem of font. If i change
the
Post by VKumar
font of string in my MFC application and i pass it in dll function then
the
Post by VKumar
dll function will display the correct string .
Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i passed. I
took
Post by VKumar
Post by VKumar
this dll from an organization so i don't have code of this dll and i
have
Post by VKumar
Post by VKumar
only this option to use the dll.
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this string
from
Post by Scott McPhillips [MVP]
Post by VKumar
exe to dll. My application is MFC application. This application use a
dll. I
Post by Scott McPhillips [MVP]
Post by VKumar
pass this string from application to dll in a function of dll. String
is
Post by VKumar
Post by Scott McPhillips [MVP]
Post by VKumar
displaying as garbage in dll. If i change the font of string in exe
and
Post by VKumar
pass
Post by Scott McPhillips [MVP]
Post by VKumar
this to dll then the string will display correctly in dll function. I
don't
Post by Scott McPhillips [MVP]
Post by VKumar
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not have a
font. Can you explain what you mean by "change the font of string?"
--
Scott McPhillips [VC++ MVP]
As Scott says, DLL's and strings do not have fonts, so you cannot fix
this just by changing the string. But if your app is unicode and the DLL
isn't, you must certainly convert your string to the current ANSI code
page before sending it to the DLL, or you will not even be able to
display strings that contain ASCII characters only. Make sure you can do
this, at least.
If your DLL is ANSI, I don't think it is possible to display an
arbitrary string, but I think a message box should be able to display
any character in the local code page.
David Wilkinson
=========================
VKumar
2006-04-19 13:26:37 UTC
Permalink
WideCharToMultiByte working correctly and messagebox in my exe is displaying
correct string.
I don't have code of DLL. Is there no other solution to solve this?
I think we should have facility to change the font of any string.
Post by Ajay Kalra
When you debug, can you see the string correctly which has beeb converted to
ANSI.
Additionally, you should not mix and match MFC types (UNICODE and MBCS) in
the same process space. This would cause other headaches, such as NULL
mainwindow, app etc in a DLL.
--
Ajay Kalra [MVP - VC++]
Post by VKumar
My MFC application is unicode application. I pass ansi string to dll.
First
Post by VKumar
i load a string from string table into TCHAR type array, then i change
this
Post by VKumar
unicode string to ansi string by using widechartomultibyte where i pass
CP_ACP as code page. I know this way only.
you must certainly convert your string to the current >ANSI code page
before sending it to the DLL.
I am doing this by widechartomultibyte. While my string is written in
Japanese language and My MFC application is running on japanese OS.
Please tell the solution.
Post by VKumar
I don't pass unicode string in function of dll. I pass ANSI string.
I have also tried by taking a unicode string and converting it to ansi
string by Widechartomultibyte. but don't get success.
Post by VKumar
OK
What i am doing? I have a dll. This dll has a function which takes a
string
Post by VKumar
as input and display it in a message box( or on a dialog box). I don't
have
Post by VKumar
code of this dll. I use this dll by loadlibrary then i call that
function
Post by VKumar
of
Post by VKumar
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i call
function of dll and pass a string. This function display that string
in
Post by VKumar
a
Post by VKumar
Post by VKumar
message box.But i don't see correct string in message box which i
passed,
Post by VKumar
i
Post by VKumar
see some garbage value. I think this is the problem of font. If i
change
Post by VKumar
Post by VKumar
the
Post by VKumar
font of string in my MFC application and i pass it in dll function
then
Post by VKumar
Post by VKumar
the
Post by VKumar
dll function will display the correct string .
Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i passed. I
took
Post by VKumar
Post by VKumar
this dll from an organization so i don't have code of this dll and i
have
Post by VKumar
Post by VKumar
only this option to use the dll.
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this
string
Post by VKumar
Post by VKumar
Post by VKumar
from
Post by Scott McPhillips [MVP]
Post by VKumar
exe to dll. My application is MFC application. This application
use
Post by Ajay Kalra
a
Post by VKumar
Post by VKumar
Post by VKumar
dll. I
Post by Scott McPhillips [MVP]
Post by VKumar
pass this string from application to dll in a function of dll.
String
Post by VKumar
Post by VKumar
is
Post by VKumar
Post by Scott McPhillips [MVP]
Post by VKumar
displaying as garbage in dll. If i change the font of string in exe
and
Post by VKumar
pass
Post by Scott McPhillips [MVP]
Post by VKumar
this to dll then the string will display correctly in dll
function.
Post by Ajay Kalra
I
Post by VKumar
Post by VKumar
Post by VKumar
don't
Post by Scott McPhillips [MVP]
Post by VKumar
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not have a
font. Can you explain what you mean by "change the font of string?"
--
Scott McPhillips [VC++ MVP]
As Scott says, DLL's and strings do not have fonts, so you cannot fix
this just by changing the string. But if your app is unicode and the DLL
isn't, you must certainly convert your string to the current ANSI code
page before sending it to the DLL, or you will not even be able to
display strings that contain ASCII characters only. Make sure you can do
this, at least.
If your DLL is ANSI, I don't think it is possible to display an
arbitrary string, but I think a message box should be able to display
any character in the local code page.
David Wilkinson
=========================
Ajay Kalra
2006-04-19 16:00:06 UTC
Permalink
Post by VKumar
WideCharToMultiByte working correctly and messagebox in my exe is displaying
correct string.
I don't have code of DLL. Is there no other solution to solve this?
I still dont know what your problem is. Is the module which is supposed to
show the string getting correct string? If yes, why are you not able to show
it. Just call AfxMessageBox and it should show exactly the way you get it.
You are responsible for converting it to UNICODE if the string is MBCS etc.
I suspect your convesion is an issue.
Post by VKumar
I think we should have facility to change the font of any string.
No. It does not make any sense to do this. Font is not an attribute of a
String, which is nothing but data.




--
Ajay Kalra [MVP - VC++]
Post by VKumar
WideCharToMultiByte working correctly and messagebox in my exe is displaying
correct string.
I don't have code of DLL. Is there no other solution to solve this?
Post by Ajay Kalra
When you debug, can you see the string correctly which has beeb
converted
Post by VKumar
to
Post by Ajay Kalra
ANSI.
Additionally, you should not mix and match MFC types (UNICODE and MBCS) in
the same process space. This would cause other headaches, such as NULL
mainwindow, app etc in a DLL.
--
Ajay Kalra [MVP - VC++]
Post by VKumar
My MFC application is unicode application. I pass ansi string to dll.
First
Post by VKumar
i load a string from string table into TCHAR type array, then i change
this
Post by VKumar
unicode string to ansi string by using widechartomultibyte where i pass
CP_ACP as code page. I know this way only.
you must certainly convert your string to the current >ANSI code page
before sending it to the DLL.
I am doing this by widechartomultibyte. While my string is written in
Japanese language and My MFC application is running on japanese OS.
Please tell the solution.
Post by VKumar
I don't pass unicode string in function of dll. I pass ANSI string.
I have also tried by taking a unicode string and converting it to
ansi
Post by Ajay Kalra
Post by VKumar
Post by VKumar
string by Widechartomultibyte. but don't get success.
Post by VKumar
OK
What i am doing? I have a dll. This dll has a function which takes a
string
Post by VKumar
as input and display it in a message box( or on a dialog box). I
don't
Post by Ajay Kalra
Post by VKumar
Post by VKumar
have
Post by VKumar
code of this dll. I use this dll by loadlibrary then i call that
function
Post by VKumar
of
Post by VKumar
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i
call
Post by Ajay Kalra
Post by VKumar
Post by VKumar
Post by VKumar
function of dll and pass a string. This function display that string
in
Post by VKumar
a
Post by VKumar
Post by VKumar
message box.But i don't see correct string in message box which i
passed,
Post by VKumar
i
Post by VKumar
see some garbage value. I think this is the problem of font. If i
change
Post by VKumar
Post by VKumar
the
Post by VKumar
font of string in my MFC application and i pass it in dll function
then
Post by VKumar
Post by VKumar
the
Post by VKumar
dll function will display the correct string .
Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i
passed.
Post by VKumar
I
Post by Ajay Kalra
Post by VKumar
took
Post by VKumar
Post by VKumar
this dll from an organization so i don't have code of this dll and i
have
Post by VKumar
Post by VKumar
only this option to use the dll.
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this
string
Post by VKumar
Post by VKumar
Post by VKumar
from
Post by Scott McPhillips [MVP]
Post by VKumar
exe to dll. My application is MFC application. This application
use
Post by Ajay Kalra
a
Post by VKumar
Post by VKumar
Post by VKumar
dll. I
Post by Scott McPhillips [MVP]
Post by VKumar
pass this string from application to dll in a function of dll.
String
Post by VKumar
Post by VKumar
is
Post by VKumar
Post by Scott McPhillips [MVP]
Post by VKumar
displaying as garbage in dll. If i change the font of string in
exe
Post by Ajay Kalra
Post by VKumar
Post by VKumar
and
Post by VKumar
pass
Post by Scott McPhillips [MVP]
Post by VKumar
this to dll then the string will display correctly in dll
function.
Post by Ajay Kalra
I
Post by VKumar
Post by VKumar
Post by VKumar
don't
Post by Scott McPhillips [MVP]
Post by VKumar
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not
have
Post by VKumar
a
Post by Ajay Kalra
Post by VKumar
Post by VKumar
Post by VKumar
Post by Scott McPhillips [MVP]
font. Can you explain what you mean by "change the font of
string?"
Post by Ajay Kalra
Post by VKumar
Post by VKumar
Post by VKumar
Post by Scott McPhillips [MVP]
--
Scott McPhillips [VC++ MVP]
As Scott says, DLL's and strings do not have fonts, so you cannot fix
this just by changing the string. But if your app is unicode and the
DLL
Post by Ajay Kalra
Post by VKumar
isn't, you must certainly convert your string to the current ANSI code
page before sending it to the DLL, or you will not even be able to
display strings that contain ASCII characters only. Make sure you
can
Post by VKumar
do
Post by Ajay Kalra
Post by VKumar
this, at least.
If your DLL is ANSI, I don't think it is possible to display an
arbitrary string, but I think a message box should be able to display
any character in the local code page.
David Wilkinson
=========================
VKumar
2006-04-20 04:41:09 UTC
Permalink
In my MFC application, i took a unicode string(WCHAR*) and convert it to
ansi string(char*), then i display this string in message box which display
correct string. then i pass this string in a function of dll. this dll
function also display this string which is display as garbage. MY MFC
application is unicode application and dll is ansi(MBCS). I am again saying
i don't have code of dll. The string is written in Japanese language. MY MFC
application is running on Japanese OS.
Post by VKumar
Post by VKumar
WideCharToMultiByte working correctly and messagebox in my exe is
displaying
Post by VKumar
correct string.
I don't have code of DLL. Is there no other solution to solve this?
I still dont know what your problem is. Is the module which is supposed to
show the string getting correct string? If yes, why are you not able to show
it. Just call AfxMessageBox and it should show exactly the way you get it.
You are responsible for converting it to UNICODE if the string is MBCS etc.
I suspect your convesion is an issue.
Post by VKumar
I think we should have facility to change the font of any string.
No. It does not make any sense to do this. Font is not an attribute of a
String, which is nothing but data.
--
Ajay Kalra [MVP - VC++]
Post by VKumar
WideCharToMultiByte working correctly and messagebox in my exe is
displaying
Post by VKumar
correct string.
I don't have code of DLL. Is there no other solution to solve this?
Post by Ajay Kalra
When you debug, can you see the string correctly which has beeb
converted
Post by VKumar
to
Post by Ajay Kalra
ANSI.
Additionally, you should not mix and match MFC types (UNICODE and
MBCS)
Post by VKumar
in
Post by VKumar
Post by Ajay Kalra
the same process space. This would cause other headaches, such as NULL
mainwindow, app etc in a DLL.
--
Ajay Kalra [MVP - VC++]
Post by VKumar
My MFC application is unicode application. I pass ansi string to dll.
First
Post by VKumar
i load a string from string table into TCHAR type array, then i change
this
Post by VKumar
unicode string to ansi string by using widechartomultibyte where i
pass
Post by VKumar
Post by Ajay Kalra
Post by VKumar
CP_ACP as code page. I know this way only.
you must certainly convert your string to the current >ANSI code
page
Post by VKumar
Post by Ajay Kalra
Post by VKumar
before sending it to the DLL.
I am doing this by widechartomultibyte. While my string is written in
Japanese language and My MFC application is running on japanese OS.
Please tell the solution.
Post by VKumar
I don't pass unicode string in function of dll. I pass ANSI
string.
Post by VKumar
Post by Ajay Kalra
Post by VKumar
Post by VKumar
I have also tried by taking a unicode string and converting it to
ansi
Post by Ajay Kalra
Post by VKumar
Post by VKumar
string by Widechartomultibyte. but don't get success.
Post by VKumar
OK
What i am doing? I have a dll. This dll has a function which
takes
Post by VKumar
a
Post by VKumar
Post by Ajay Kalra
Post by VKumar
Post by VKumar
string
Post by VKumar
as input and display it in a message box( or on a dialog box). I
don't
Post by Ajay Kalra
Post by VKumar
Post by VKumar
have
Post by VKumar
code of this dll. I use this dll by loadlibrary then i call that
function
Post by VKumar
of
Post by VKumar
dll which takes string as input.
In my MFC application, first i load the dll by loadlibrary then i
call
Post by Ajay Kalra
Post by VKumar
Post by VKumar
Post by VKumar
function of dll and pass a string. This function display that
string
Post by VKumar
Post by Ajay Kalra
in
Post by VKumar
a
Post by VKumar
Post by VKumar
message box.But i don't see correct string in message box which i
passed,
Post by VKumar
i
Post by VKumar
see some garbage value. I think this is the problem of font. If i
change
Post by VKumar
Post by VKumar
the
Post by VKumar
font of string in my MFC application and i pass it in dll function
then
Post by VKumar
Post by VKumar
the
Post by VKumar
dll function will display the correct string .
Actually my MFC application is Unicode application and dll is ANSI
application. So i need to change the font of string which i
passed.
Post by VKumar
I
Post by Ajay Kalra
Post by VKumar
took
Post by VKumar
Post by VKumar
this dll from an organization so i don't have code of this dll
and
Post by VKumar
i
Post by VKumar
Post by Ajay Kalra
Post by VKumar
have
Post by VKumar
Post by VKumar
only this option to use the dll.
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in
Post by Scott McPhillips [MVP]
Post by VKumar
I don't want to use the string on dialog box. I am sending this
string
Post by VKumar
Post by VKumar
Post by VKumar
from
Post by Scott McPhillips [MVP]
Post by VKumar
exe to dll. My application is MFC application. This application
use
Post by Ajay Kalra
a
Post by VKumar
Post by VKumar
Post by VKumar
dll. I
Post by Scott McPhillips [MVP]
Post by VKumar
pass this string from application to dll in a function of dll.
String
Post by VKumar
Post by VKumar
is
Post by VKumar
Post by Scott McPhillips [MVP]
Post by VKumar
displaying as garbage in dll. If i change the font of string in
exe
Post by Ajay Kalra
Post by VKumar
Post by VKumar
and
Post by VKumar
pass
Post by Scott McPhillips [MVP]
Post by VKumar
this to dll then the string will display correctly in dll
function.
Post by Ajay Kalra
I
Post by VKumar
Post by VKumar
Post by VKumar
don't
Post by Scott McPhillips [MVP]
Post by VKumar
have code of dll. I use dll by LoadLibrary.
This a not clear. DLLs do not have a font, and strings do not
have
Post by VKumar
a
Post by Ajay Kalra
Post by VKumar
Post by VKumar
Post by VKumar
Post by Scott McPhillips [MVP]
font. Can you explain what you mean by "change the font of
string?"
Post by Ajay Kalra
Post by VKumar
Post by VKumar
Post by VKumar
Post by Scott McPhillips [MVP]
--
Scott McPhillips [VC++ MVP]
As Scott says, DLL's and strings do not have fonts, so you cannot
fix
Post by VKumar
Post by Ajay Kalra
Post by VKumar
this just by changing the string. But if your app is unicode and the
DLL
Post by Ajay Kalra
Post by VKumar
isn't, you must certainly convert your string to the current ANSI
code
Post by VKumar
Post by Ajay Kalra
Post by VKumar
page before sending it to the DLL, or you will not even be able to
display strings that contain ASCII characters only. Make sure you
can
Post by VKumar
do
Post by Ajay Kalra
Post by VKumar
this, at least.
If your DLL is ANSI, I don't think it is possible to display an
arbitrary string, but I think a message box should be able to
display
Post by VKumar
Post by Ajay Kalra
Post by VKumar
any character in the local code page.
David Wilkinson
=========================
Loading...