|
Can you try doing a reinterpret_cast for changing the type of the buttons at runtime. Your requirement is not clear but you may however create variables for CButton and use dynamic casting to change the behavior of buttons to what you want.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Try hooking the CreateWindow/CreateWindowEx API
|
|
|
|
|
Hi,
I am trying to display a wide char string to an Edit box. My prject setting is MBCS. Is it possible to display Wchar string in non-unicode project?
If so Please let me know.
For setting unicode font :
CDC *pDC = GetDC();<br />
<br />
LOGFONT lf;<br />
memset(&lf, 0, sizeof(lf)); <br />
lf.lfHeight = MulDiv(12, ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72);<br />
lf.lfWeight = FW_NORMAL;<br />
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;<br />
_tcscpy(lf.lfFaceName, _T("Lucida Sans Unicode")); <br />
m_font.CreateFontIndirect(&lf);<br />
<br />
m_edit.SetFont(&m_font);
For Displaying text :
wchar_t str[10];<br />
str[0]=0x41;<br />
str[1]=0x42;<br />
str[2]=0x284;<br />
str[3]=0x44;<br />
str[4]=0x45;<br />
str[5]=0x46;<br />
str[6]=0x47;<br />
str[7]=0x48;<br />
str[8]=0x49;<br />
str[9]=0x00;<br />
<br />
::SetWindowTextW(m_edit.m_hWnd,(LPCWSTR)str);
Plz help.
Thanks.
|
|
|
|
|
Yes its possible. but now your trying to set the unciode text in some edit box placed in the resource isnt it. Instead of that use the CreateWindowExW() directly to create the edit box.
wchar_t str[10];
str[0]=0x41;
str[1]=0x42;
str[2]=0x284;
str[3]=0x44;
str[4]=0x45;
str[5]=0x46;
str[6]=0x47;
str[7]=0x48;
str[8]=0x49;
str[9]=0x00;
HWND hEdit = CreateWindowExW( 0, L"Edit", str, WS_CHILD|WS_VISIBLE|WS_BORDER, 0,0, 300,300, m_hWnd, 0, AfxGetInstanceHandle(), 0 );
|
|
|
|
|
Hi Nave,
Thanks for the reply.
I have created the EditBox using the CreateWindowExW() but still desired character is not getting displayed in place of 'C'.
Is there any special setting or style that we need to specify?
Regards,
Nilesh.
|
|
|
|
|
No I didnt do any thing special.
see my preprocessor definition
WIN32,_DEBUG,_WINDOWS,_AFXDLL,_MBCS
And this is the text that I got when I run the program
ABʄDEFGHI
Isnt this text correct?
|
|
|
|
|
Hi,
Thanks for the reply.
But the text displayed is not correct.
In Lucida san Unicode font instead of square box. it should display the char combinition of
'J' + 'f' + '='. that is unicode value of 0x284. You can refer to Character map in Programs=>Accessories=>system tools=>Character map. select font as Lucida san Unicode. and check character for U+0284 .
I am trying to display that character in my string.It displays the same perfectly if your project setting is _UNICODE.
Is my approach wronge? please let me know.
Regards,
Nilesh.
|
|
|
|
|
Ya.. previously I didnt set the font to "Lucida san Unicode" After i set that too the text came as you said
But I dont understand what wrong with your settings... I started a dialog based application a put the below code in the oninitdialog function
wchar_t str[10];<br />
str[0]=0x41;<br />
str[1]=0x42;<br />
str[2]=0x284;<br />
str[3]=0x44;<br />
str[4]=0x45;<br />
str[5]=0x46;<br />
str[6]=0x47;<br />
str[7]=0x48;<br />
str[8]=0x49;<br />
str[9]=0x00;<br />
CClientDC dc(this);<br />
LOGFONT lf;<br />
memset(&lf, 0, sizeof(lf)); <br />
lf.lfHeight = MulDiv(12, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72);<br />
lf.lfWeight = FW_NORMAL;<br />
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;<br />
_tcscpy(lf.lfFaceName, _T("Lucida Sans Unicode")); <br />
static CFont m_font;<br />
m_font.CreateFontIndirect(&lf);<br />
HWND hEdit = CreateWindowExW( 0, L"Edit", str, WS_CHILD|WS_VISIBLE|WS_BORDER, 0,0, 300,50, m_hWnd, 0, AfxGetInstanceHandle(), 0 );<br />
::SendMessage( hEdit, WM_SETFONT, (WPARAM)m_font.m_hObject, (LPARAM)TRUE );
|
|
|
|
|
Hi Naveen,
It's working fine in my app too. Thanks a lot.
For setting the font to EditBox I was trying :
SelectObject(::GetDC(hEdit),m_font.m_hObject);
But after using your code. My application was displaying that char.
::SendMessage( hEdit, WM_SETFONT, (WPARAM)m_font.m_hObject, (LPARAM)TRUE );
again thanks a lot. And keep up good work....
Regards,
Nilesh.
|
|
|
|
|
Hi Naveen,
Just a question?
Is it possible to do the same with EditBox created by resource file?
Regards,
Nilesh.
|
|
|
|
|
nilesh.gawade wrote: Is it possible to do the same with EditBox created by resource file?
Sorry that I dont know.
|
|
|
|
|
Hi,
I am able to display the unicode string in EditBox only after creating the EditBox using CreateWindowExW() API.
Now I want to display the same string in EditBox Created using Resource Editor.
May be While creating EditBox through rc file. It might call API in following sequence.
CEdit::Create() => CWnd::Create() => CWnd::CreateWindow() => ::CreateWindow() or ::CreateWindowEx()
Can we modify this flow so that ultimately last call will be ::CreateWindowW() or ::CreateWindowExW()?
Plz Help...
__________________
Regards,
Nilesh Gawade
|
|
|
|
|
nilesh.gawade wrote: CEdit::Create() => CWnd::Create() => CWnd::CreateWindow() => ::CreateWindow() or ::CreateWindowEx()
No this is not correct. The dialog is created using the createdialog() API. inside this api it creats all the controls inside it internally. So the creation of edit control using ::CreateWindow() is done inside the createdialog itself. and it doesnt call the CWnd::Create() at all. After creating all the controls, it subclasses each control if you have made a control variable for it. For this purpose it uses the SubClassWindow() function. So thats how your edit control becomes an object of CEdit.
|
|
|
|
|
nilesh.gawade wrote: Can we modify this flow so that ultimately last call will be ::CreateWindowW() or ::CreateWindowExW()?
Some thing that you can do is create the dialog by your self using the CreateDialogW() function.
|
|
|
|
|
Hi Nave,
Thanks buddy.
I will work on the same.
Regards,
Nilesh.
|
|
|
|
|
For a runtime error to my IVRS application , i found a solution as 'increase the application buffer allocated by the OS' in the internet. I want to know whether there is a way to increase the buffer size of the application?
Thank you
KIRAN PINJARLA
|
|
|
|
|
What buffer are you referring to? Stack space, perhaps?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes.I thing so. I was told that for every application running, a defult memory is allocated by the os. Is it like that?
KIRAN PINJARLA
|
|
|
|
|
The default stack size for a VS6 application is 1MB. I'm not sure if that has been changed in VS200x.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks everybody, but I solved it by doing ... nothing. After a while staring at the code, I hit ... Rebuild, and it worked like a charm. Ahhh VC++6 and templates Sorry for the hassle, thanks again for your answers.
-> Orignial post:
Here is my code:
for(int i=0;i<3;i++)
{
BYTE *pbMessage= new BYTE[12];
st.push(pbMessage);
}
BYTE *pbTest;
while(st.getSize()>0)
{
pbTest=st.pop();
printf("%s\n",pbTest);
delete[] pbTest;
st is a sort of stack (which works). The push function saves the pointer, the pop function returns the pointer. How can I make the compiler understand that the pbTest points on 12 elements ?
BYTE pbTest[12];
pbTest=st.pop();
Note that delete pbTest does not work either in the first example.
Thanks,
-- modified at 9:55 Tuesday 16th October, 2007
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Do not feed the troll ! - Common proverb
|
|
|
|
|
pbTest is allocated as a BYTE *pbTest (not an array) so why would you free it using delete[] pbTest
|
|
|
|
|
toxcct wrote: ...why would you free it using delete[] pbTest
Because it points to an array?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
isn't delete[] useful only when the memory is allocated with new[] and simple delete useful when simple new used ?
|
|
|
|
|
toxcct wrote: isn't delete[] useful only when the memory is allocated with new[]
Yes, and that's what he has here:
BYTE *pbMessage= new BYTE[12];
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Rage wrote: Note that delete pbTest does not work either in the first example.
Is it throwing exception right from the first element in the loop while deleting? Are you sure pop is working correctly?
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|