|
Yeah, I don't think the two options are identical, they are used for different things, but have similar effects.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
Hello,
I am trying to dynamically change the texts of the menu items of my main menu. The program should translate the menu items to the local language at runtime. I am using the BCMenu class:
UINT nItem = 0;
CString strItem;
CString strNew;
char *pszSrc = NULL;
while(1)
{
if(m_menu.GetMenuText(nItem, strItem, MF_BYPOSITION) == FALSE) break;
pszSrc = strItem.LockBuffer();
strNew = TRL(pszSrc);
strItem.UnlockBuffer();
if(m_menu.SetMenuText(nItem, strNew, MF_BYPOSITION) == FALSE) { ASSERT(FALSE); }
MessageBox(strItem + " -> " + strNew);
nItem++;
}
m_bMenu = SetMenu(&m_menu);
ASSERT(m_bMenu == TRUE);
The TRL function takes a char * as input and returns a char * to the translated string. This works very well as one can see in the dislayed message box (strItem+"->"+strNew).
The items are translated correctly, but the menu doesn't change. The menu items remain english, untranslated. But the SetMenuText function returns TRUE...
Any idea what is going on?
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
call DrawMenuBar() for the window. From MSDN:
Redraws the menu bar. If a menu bar is changed after Windows has created the window, call this function to draw the changed menu bar.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Nope, that doesn't help. I've changed my code now a bit:
UINT nItem = 0;
UINT nSub = 0;
CString strItem;
CString strNew;
char *pszSrc = NULL;
BCMenu *pSubMenu = &m_menu;
while(1)
{
nItem = 0;
while(1)
{
if(pSubMenu->GetMenuText(nItem, strItem, MF_BYPOSITION) == FALSE) break;
pszSrc = strItem.LockBuffer();
strNew = TRL(pszSrc);
strItem.UnlockBuffer();
if(pSubMenu->SetMenuText(nItem, strNew, MF_BYPOSITION) == FALSE) { ASSERT(FALSE); }
nItem++;
}
pSubMenu = (BCMenu *)m_menu.GetSubMenu(nSub);
nSub++;
if(pSubMenu == NULL) break;
}
m_bMenu = SetMenu(&m_menu);
ASSERT(m_bMenu == TRUE);
The items in the menu (so for example all items in "File", such as "Exit") are translated and shown correctly!
It's just the "main main" menu bar (so the one with "File", "Extras", "View", etc).
The code snippet above is called in OnInitDialog.
Any more idea?
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Hi!
I am using the DHTML editing control and I want to add a table so I want to add the code into the html code of the control myself? How can I do it?
Thank you very much for your future answers!
Well... I am a beginner ...
|
|
|
|
|
I/m new to VC++. I developed a program which receives a float value via a dialog box (derived from CDialog). This value is a Fahrenheit temparature. Next it performs some mathematics and successfully finds out Centigrade equivalent (a float again). I want this value displayed on the Windows Client Area. How can I? So far I have used CDC::TextOut(int,int," "); this shows a string message but doesn't show the variable's value. Even type casting hasn't helped.
LOOKING FOR YOUR GUIDANCE
|
|
|
|
|
To convert a float to a string, use
CString str;
str.Format(_T("%f"), (double)MyFloatValue); [edit]If this doesn't work, remove the (double) cast:
CString str;
str.Format(_T("%f"), MyFloatValue); [/edit]Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
You've mixed types there. %f is for floats, no need for the cast to double . In fact, the code will break because Format() will expect a float value on the stack, but it will see a double and generate an incorrect string.
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Manuder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Michael Dunn wrote:
%f is for floats
That's what I thought, but because I don't usually use float s, I checked MSDN, and the documentation for printf said %f expected a double. Perhaps the docs are wrong.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I'm grateful to u Ryan for your help. I hope this is going to work. I'll like to stay in touch with you in future and I'm going to rate your message # 1.
Bye Bye and Thanks again.
|
|
|
|
|
SheheerZahid wrote:
I'm going to rate your message # 1
Ummmm, perhaps you don't realise that 1 is the lowest rating and 5 is the highest
If it doesn't work remove the (double) cast (see Michael Dunn's message above).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I'm using dtpcustom to specify my own format od date and time display.(yyyy-mm-dd':'dddd)
English (US) is set as default language of my system.when the locale is set to English(US) the date time picker can show the dddd part as "saturday" in english correctly.when i change the locale to Chinese(PRC),some junk characters are displayed instead of displaying "saturday" in chinese characters. But if i change the default language of the system to Chinese(PRC) and reboot the machine,the date time picker can show chinese characters.
Thanx in advance
|
|
|
|
|
You need to change the dialog font to MS Shell Dlg, instead of MS Sans Serif which is the font generated by the resource editor. MS Sans Serif doesn't display double-byte characters. In VC 6 you need to open the .rc file as plain text and change the font. No idea how to do it in VC 7.
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Manuder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Hi,
Thanks for your suggestion.I use Arial 9 for my dialog.I tried changing the font to ms shell dlg.but this doesn't serve the purpose.Can you tell me how this is done in IE and other microsoft applications
|
|
|
|
|
Using MS Shell Dlg makes the OS use the "Default dialog font", which differs among languages. Setting it to Arial only works if the version of Arial you have on your system contains the DBCS characters. If you get only ||||| then the font doesn't have them.
As a last resort you can always set the font of just the control to SimSun or whatever font you want that can show DBCS chars.
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Manuder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Hi guys,
This is a question on Load Icon in VC 6.
I am giving the code snippet.
This code I have put in OnDraw() function
HICON hicon1;
CDC WordkDC;
HINSTANCE instance;
WorkDC.CreateCompatibleDC(pDC);
instance=AfxGetInstanceHandle();
hicon1=::LoadIcon(instance,MAKEINTRESOURCE(IDI_ICON3));
WorkDC.DrawIcon(100,200,hicon1);
pDC->BitBlt(0,0,1012,668,&WorkDC,0,0,SRCCOPY);
AfxMessageBox("In ondraw if condition");
I am seeing only the MessageBox but not the icon why ??
Instead of the WorkDC if I use pDC I could see the icon.
Can anybody tell what's wrong with my code.
Thanks
Satya
|
|
|
|
|
WorkDC is a memory device context - it's not associated with a display device. In order to be able to draw anything in it, it has to be associated with a bitmap for it to draw on. Using pDC works because the device context has somewhere to draw - the screen. To make this section of code work, you'll have to create a bitmap for it:
HICON hicon1;
CDC WordkDC;
HINSTANCE instance;
CBitmap bitmap;
CBitmap *pBitmap;
WorkDC.CreateCompatibleDC(pDC);
bitmap.CreateCompatibleBitmap(pDC, 1012, 668);
pBitmap = WorkDC.SelectObject(&bitmap);
instance=AfxGetInstanceHandle();
hicon1=::LoadIcon(instance,MAKEINTRESOURCE(IDI_ICON3));
WorkDC.DrawIcon(100,200,hicon1);
pDC->BitBlt(0,0,1012,668,&WorkDC,0,0,SRCCOPY);
WorkDC.SelectObject(pBitmap);
bitmap.DeleteObject();
AfxMessageBox("In ondraw if condition"); Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thanks Ryan,
It's working
Satya
|
|
|
|
|
You're welcome
BTW, instead of hardcoding the width/height of the bitmap, you might want to use GetClientRect() to get the dimensions of the client area, and specifiy the height and width from that instead.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I'm using dtpcustom to specify my own format od date and time display.(yyyy-mm-dd':'dddd)
English (US) is set as default language of my system.when the locale is set to English(US) the date time picker can show the dddd part as "saturday" in english correctly.when i change the locale to Chinese(PRC),some junk characters are displayed instead of displaying "saturday" in chinese.
|
|
|
|
|
Hi!~
The problem is:
in VC++, I created a dialog using the dialog editor, and add a CEdit to it.
From the main program, I want to call and DoModal() this dialog. Before I DoModal it, I want to hide the CEdit control. I am doing it like this:
dlg.m_cedit_control.ShowWindow(SW_HIDE);
if (dlg.DoModal()==IDOK)
{
......
};
However, the debug assert at the above ShowWIndow line.
Any one know by which way I can get what I want?
Thanks a lot and have a nice day.
(Actually, the dialog is created for multi purposes. So sometimes, before it is shown, I want to display the CEdit to the user so that user can input. But sometimes, I want to hide it.)
|
|
|
|
|
You can't call ShowWindow() until the edit control is created, ie. until DoModal() is called. Set a flag in the dialog box, and then show/hide the window in OnInitDialog() in the dialog:
dlg.m_bShowEditControl = FALSE;
dlg.DoModal();
...
CMyDialog::OnInitDialog()
{
...
if(!m_bShowEditControl)
m_cedit_control.ShowWindow(SW_HIDE);
...
} Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I created an MFC Extension DLL that when calls checks a file, and condictionally displays a dialog box and quits. It compiled fine.
But
When I went to create a sample app, I added the lib to the project and included the header file from the MFC Extension DLL.. Called teh function:
CPluginMessage mPIM;
mPIM.CheckForInformation("asdf.exe","ASDF","None");
But when I compile the app it throws a fit and says:
--------------------Configuration: asdf - Win32 Release--------------------
Compiling...
asdfDlg.cpp
Linking...
asdfDlg.obj : error LNK2001: unresolved external symbol "public: int __thiscall CPluginMessage::CheckForInformation(class CString,class CString,class CString)" (?CheckForInformation@CPluginMessage@@QAEHVCString@@00@Z)
asdfDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CPluginMessage::CPluginMessage(class CWnd *)" (??0CPluginMessage@@QAE@PAVCWnd@@@Z)
Release/asdf.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
asdf.exe - 3 error(s), 0 warning(s)
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
Compile the DLL using multithreaded DLL linking.
Kuphryn
|
|
|
|
|