'How to remove hardcoded value for _T() in C++
CAToolbar* pToolBarCommunicate = (CAToolbar*)pCommandBars->Add(new CAToolbar, _T("Comman Toolbar"), xtpBarTop);
I have this piece of code where the 'Common Toolbar' is hardcoded, I need to change it to some IDS mentioned in .rc file, shall I directly remove the text and replace with ID which is mentioned in .rc file with this text. something like ->Add(new CAToolbar, _T(IDS_COMMAN_TOOLBAR), xtpBarTop);
is it correct way of doing this ? or is there any better way?
Solution 1:[1]
You can use MAKEINTRESOURCE:
CAToolbar* pToolBarCommunicate = (CAToolbar*)pCommandBars->Add(
new CAToolbar,
MAKEINTRESOURCE(IDS_COMMAN_TOOLBAR),
xtpBarTop);
You can see more about it here: MAKEINTRESOURCEA macro (winuser.h)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrew Truckle |
