From: Norman Diamond on
> #define TYPECASE(x) case x: s.LoadString(IDS_#x); return s

Every conforming implementation is required to issue a diagnostic, though
they're allowed to do what you want in addition to issuing a diagnostic.
Microsoft already ruled that a "won't fix" for their non-conforming
implementation.

I think this will do it:
#define TYPECASE(x) case x: s.LoadString(IDS_ ## #x); return s
but I haven't tested it.

The .Net Framework provides ways to load localized strings, but as you
pointed out, it is necessary to set a name for the string variable
separately from setting its contents.


"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:mfdit35hgfk3qf828of54ppqahgrs0und2(a)4ax.com...
> Up to a certain point, const declarations and generics will help. But
> every once in a
> while, having a code-generator integrated into the compiler system is
> useful, such as
>
> #define TYPECASE(x) case x: return _T(#x); break
>
> and similar techniques. In the absence of good macros, tricks like this
> become difficult,
> although the C# ToString function handles the above situation trivially,
> it doesn't
> generalize to situations such as
>
> #define TYPECASE(x) case x: s.LoadString(IDS_#x); return s
>
> where localization is necessary. Since C# seems to embed all the literals
> int he code
> instead of in resources, I find this doesn't help a lot (what is the
> opposition to dialog
> templates, STRINGTABLE, MESSAGETABLE, etc. in C#?)
> joe
>
> On Wed, 12 Mar 2008 19:49:10 -0700, "Tom Serface"
> <tom.nospam(a)camaswood.com> wrote:
>
>>The only thing I don't like about C# is no #define macros. I miss that
>>feature from C++.
>>
>>Tom
>>
>>"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
>>news:1E8ACCDC-68B5-4C9F-9E56-5FB0EC54D2B8(a)microsoft.com...
>>>
>>> "Tom Serface" <tom.nospam(a)camaswood.com> wrote in message
>>> news:B45FAA0F-4660-4D86-ACCA-B4226F8B5C7A(a)microsoft.com...
>>>> Yeah, C# just always does Unicode. No _T() or TCHAR or L"" or
>>>> anything.
>>>> That is nice.
>>>
>>> No macros is good. No header files is better.
>>>
>>> ---
>>> Ajay
>>>
>>>
> Joseph M. Newcomer [MVP]
> email: newcomer(a)flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm

From: Norman Diamond on
Ouch, my phrasing is worse. I guess you (Dr. Newcomer) just typoed and
meant:
#define TYPECASE(x) case x: s.LoadString(IDS_##x); return s

"Norman Diamond" <ndiamond(a)newsgroup.nospam> wrote in message
news:uiN2evWhIHA.4844(a)TK2MSFTNGP06.phx.gbl...
>> #define TYPECASE(x) case x: s.LoadString(IDS_#x); return s
>
> Every conforming implementation is required to issue a diagnostic, though
> they're allowed to do what you want in addition to issuing a diagnostic.
> Microsoft already ruled that a "won't fix" for their non-conforming
> implementation.
>
> I think this will do it:
> #define TYPECASE(x) case x: s.LoadString(IDS_ ## #x); return s
> but I haven't tested it.
>
> The .Net Framework provides ways to load localized strings, but as you
> pointed out, it is necessary to set a name for the string variable
> separately from setting its contents.
>
>
> "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
> news:mfdit35hgfk3qf828of54ppqahgrs0und2(a)4ax.com...
>> Up to a certain point, const declarations and generics will help. But
>> every once in a
>> while, having a code-generator integrated into the compiler system is
>> useful, such as
>>
>> #define TYPECASE(x) case x: return _T(#x); break
>>
>> and similar techniques. In the absence of good macros, tricks like this
>> become difficult,
>> although the C# ToString function handles the above situation trivially,
>> it doesn't
>> generalize to situations such as
>>
>> #define TYPECASE(x) case x: s.LoadString(IDS_#x); return s
>>
>> where localization is necessary. Since C# seems to embed all the
>> literals int he code
>> instead of in resources, I find this doesn't help a lot (what is the
>> opposition to dialog
>> templates, STRINGTABLE, MESSAGETABLE, etc. in C#?)
>> joe
>>
>> On Wed, 12 Mar 2008 19:49:10 -0700, "Tom Serface"
>> <tom.nospam(a)camaswood.com> wrote:
>>
>>>The only thing I don't like about C# is no #define macros. I miss that
>>>feature from C++.
>>>
>>>Tom
>>>
>>>"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
>>>news:1E8ACCDC-68B5-4C9F-9E56-5FB0EC54D2B8(a)microsoft.com...
>>>>
>>>> "Tom Serface" <tom.nospam(a)camaswood.com> wrote in message
>>>> news:B45FAA0F-4660-4D86-ACCA-B4226F8B5C7A(a)microsoft.com...
>>>>> Yeah, C# just always does Unicode. No _T() or TCHAR or L"" or
>>>>> anything.
>>>>> That is nice.
>>>>
>>>> No macros is good. No header files is better.
>>>>
>>>> ---
>>>> Ajay
>>>>
>>>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer(a)flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>

From: Mihai N. on
You misspelled "late" as "lead"


--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

From: Joseph M. Newcomer on
Oops. That should have been IDS_##x; I originally had type _T(#x) and then fixed it, kind
of.
joe

On Fri, 14 Mar 2008 09:39:12 +0900, "Norman Diamond" <ndiamond(a)newsgroup.nospam> wrote:

>> #define TYPECASE(x) case x: s.LoadString(IDS_#x); return s
>
>Every conforming implementation is required to issue a diagnostic, though
>they're allowed to do what you want in addition to issuing a diagnostic.
>Microsoft already ruled that a "won't fix" for their non-conforming
>implementation.
>
>I think this will do it:
> #define TYPECASE(x) case x: s.LoadString(IDS_ ## #x); return s
>but I haven't tested it.
>
>The .Net Framework provides ways to load localized strings, but as you
>pointed out, it is necessary to set a name for the string variable
>separately from setting its contents.
>
>
>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>news:mfdit35hgfk3qf828of54ppqahgrs0und2(a)4ax.com...
>> Up to a certain point, const declarations and generics will help. But
>> every once in a
>> while, having a code-generator integrated into the compiler system is
>> useful, such as
>>
>> #define TYPECASE(x) case x: return _T(#x); break
>>
>> and similar techniques. In the absence of good macros, tricks like this
>> become difficult,
>> although the C# ToString function handles the above situation trivially,
>> it doesn't
>> generalize to situations such as
>>
>> #define TYPECASE(x) case x: s.LoadString(IDS_#x); return s
>>
>> where localization is necessary. Since C# seems to embed all the literals
>> int he code
>> instead of in resources, I find this doesn't help a lot (what is the
>> opposition to dialog
>> templates, STRINGTABLE, MESSAGETABLE, etc. in C#?)
>> joe
>>
>> On Wed, 12 Mar 2008 19:49:10 -0700, "Tom Serface"
>> <tom.nospam(a)camaswood.com> wrote:
>>
>>>The only thing I don't like about C# is no #define macros. I miss that
>>>feature from C++.
>>>
>>>Tom
>>>
>>>"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
>>>news:1E8ACCDC-68B5-4C9F-9E56-5FB0EC54D2B8(a)microsoft.com...
>>>>
>>>> "Tom Serface" <tom.nospam(a)camaswood.com> wrote in message
>>>> news:B45FAA0F-4660-4D86-ACCA-B4226F8B5C7A(a)microsoft.com...
>>>>> Yeah, C# just always does Unicode. No _T() or TCHAR or L"" or
>>>>> anything.
>>>>> That is nice.
>>>>
>>>> No macros is good. No header files is better.
>>>>
>>>> ---
>>>> Ajay
>>>>
>>>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer(a)flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Norbert Unterberg on

David Ching schrieb:
> "David Wilkinson" <no-reply(a)effisols.com> wrote in message
> news:%233GOU0OhIHA.5900(a)TK2MSFTNGP02.phx.gbl...
>> Yes, but you only have to do it once. It's not like the constant annoyance
>> of fighting the "Add Control Variable" wizard in the "new" IDE.
>>
>
> I've never understood the outcry about that. It's no big deal. You add one
> variable, type Alt+W 2 to go back to the dialog window, select the next
> control, and add it.

Well, my problem is that it takes up to 10 minutes to show that wizard, and
nobody can explain why.

Norbert
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Prev: CDhtmlDialog Charset Problem
Next: Can't get OLE interface