|
Hey everybody
I have the following code:
wstring curlocale1(::_wsetlocale(LC_ALL, NULL));
printf("+++ current locale: %s", curlocale1.c_str());
::_wsetlocale(LC_ALL, L"en_us");
wstring curlocale2(::_wsetlocale(LC_ALL, NULL));
printf("+++ current locale: %s", curlocale2.c_str());
and the output is:
+++ current locale: C
+++ current locale: C
I can't understand why my locale does not change, what am I doing wrong?
Thanks a lot!
|
|
|
|
|
Used correctly it works fine:
wstring curlocale1(::_wsetlocale(LC_ALL, NULL));
printf("+++ current locale: %S\n", curlocale1.c_str());
::_wsetlocale(LC_ALL, L"English");
wstring curlocale2(::_wsetlocale(LC_ALL, NULL));
printf("+++ current locale: %S\n", curlocale2.c_str());
It's time for a new signature.
|
|
|
|
|
Hey, thanks
But "English" doesn't return "English (United States)", but generic English.
Anyway, I found this GREAT article in codeproject that sort some things out, so I'm sitting on that
Windows SetThreadLocale and CRT setlocale[^]
|
|
|
|
|
Green Fuze wrote: But "English" doesn't return "English (United States)"
Try "English_US". I know locales sometimes seem far more complicated than necessary but there are many different combinations to account for.
It's time for a new signature.
|
|
|
|
|
It seems that "american_US" in ::setlocale and 1033 for ::SetThreadLocale() done the trick .
It is far too complicated than it should've been!
Thanks again!
|
|
|
|
|
Green Fuze wrote: Thanks again!
Thank you for leading me down yet another path of learning.
It's time for a new signature.
|
|
|
|
|
Locales are platform dependent. They're the most irritating bit of the C++ standard as they leave the likes of Redmond and the Penguin crowd to make the decisions. And they're usually different.
I'm not surprised that your code is going horribly wrong on another level - using printf %s with a wide character string is a recipe for printing the first character out if I've ever seen one.
Cheers,
Ash
|
|
|
|
|
I have an MFC program using CMFCToolBars. The toolbar settings are getting saved and read from the registry fine. However when I make changes to the toolbar, re-compile and run the program, it doesn't see these new changes unless I go into the registry and delete the HKEY_CURRENT_USER\Software\MyProgram\settings key. What should I be doing to keep this from happening?
Thanks
Ray
|
|
|
|
|
I'm not sure what you mean by 'changes in the toolbar' (is it the layout you mean?), but what likely is happening is that when you make changes in your code, you change only the *default* layout. Your program first initializes the layout as your code specifies (the default layout), and then looks for user-customized layout. Since one is available, it *overrides* the changes you have made to your code.
Again (if this is what I'm thinking it is), your code only sets the initial, default layout. If there is user-customized layout it supersedes it. I think this is how it's supposed to work.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
By changes, I mean say if I add a button to a toolbar it doesn't show up unless I delete these setting in the registry. So where or how do I keep it from loading the customized layout if I make changes to my toolbar?
|
|
|
|
|
What type of toolbar are you using? I mean the name of the class. Standard MFC toolbar, or some customized class?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
It is my class with a base class of CMFCToolBar
|
|
|
|
|
See if CMFCToolBar::LoadState[^] is called. Find it in the MFC sources and put a breakpoint on it. On my computer it's in C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\afxtoolbar.cpp
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I'm coding with VC++2008.
When designing the layout of the controls in the .rc file, we can see their coordinates in the bottomright of the screen.
And now I have a control with (4,30) shown there and another one with (5,156). Then I wanna draw a line between these 2 controls using the coordinates by GDI.
pDC->MoveTo(4,30);
pDC->LineTo(5,156);
But at runtime, the line doesn't correspond to those coordinates. I mean there is a big offset from the expected position.
What's wrong?
Thx in advance.
|
|
|
|
|
Units in the resource editor are in DLU ( Dialog (il)Logical Unit); they are used to handle the large font/small font display settings.
from msdn :
dialog unit
A unit of horizontal or vertical distance within a dialog box. A horizontal DLU is the average width of the current dialog-box font divided by 4. A vertical DLU is the average height of the current dialog-box font divided by
M.
Watched code never compiles.
|
|
|
|
|
|
if you want to draw a line between two controls, the safest way is to get the controls' actual on-screen positions, something like:
CRect r1, r2;
ctrl1.GetWindowRect(&r1);
ScreenToClient(r1);
ctrl2.GetWindowRect(&r2);
ScreenToClient(r2);
dc.MoveTo(r1.right, r1.top);
dc.LineTo(r2.left, r2.top);
|
|
|
|
|
|
I have a xml file which hold the structre of Menu items . I want to create the Menu at runtime by reading the XML file .
Can any body help to know how to do this.
Thaks.
|
|
|
|
|
Use the CreateMenu()[^] and associated functions, using the data from your XML file.
It's time for a new signature.
|
|
|
|
|
Hi all,
i have number of items and subitems in list.
no i want to find the clicked item or subitem on double click of ListCtrl.
and also fetch the text of clicked cell.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
I'm not sure which control you are using but most of the information you need should be here[^].
It's time for a new signature.
|
|
|
|
|
Le@rner wrote: no i want to find the clicked item or subitem on double click of ListCtrl.
Are you referring to this notification?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
How about you stick with your original thread here[^]? Go back there and use the "improve question" link to tell us what you've tried and what "not working" means.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|