|
Hello!
Is there any way to use a std::string with the Windows API method LoadString() without having to use a char* as an intermediate step? For example, something like this:
std::string junk;
LoadString(AfxGetInstanceHandle(),IDS_JUNK_STRING,junk.c_str(),250);
This doesn't compile, but maybe there's a way around it. I'm just not used to mixing STL and C-API's.
Thanks,
Derek
|
|
|
|
|
Yes you can.
const int MAX = 250;
std::string junk;
junk.resize(MAX);
LoadString(AfxGetInstanceHandle(), IDS_JUNK_STRING, &junk[0], MAX);
Jam on.
|
|
|
|
|
Thanks! It works using a std::vector<char>, but I wasn't sure if it was correct to use the same &junk[0] method for std::string.
|
|
|
|
|
Yep, vector and string are the two STL containers with guaranteed contiguous memory.
|
|
|
|
|
Actually, Neither string or vector guarantee contiguous memory today. There is a proposal in front of the committee to alter the standard to require contiguous memory for vector, but not for string.
Having said that, it's highly unlikely that anyone will create a string implementation that doesn't use contiguous memory, at least on Win32.
|
|
|
|
|
I'm writing a MDI application with a toolbar in a child window. I want to chnge the toolbar from flat to non-flat buttons (and back) programatically.
I've already got a function in the CChildFrame class that responds to an message, but everything I try results in failure (in one form or another).
Does anyone know what the secret is?
|
|
|
|
|
Hi John,
I just tried with ModifyStyle(TBSTYLE_FLAT, 0) (and vice-versa) and Invalidate() and it seems to work. It's a very simple project though ...
From where are you trying to change the toolbar? (I did it in the MDI child frame)
Well, I think we all need more details to help
Paolo.
|
|
|
|
|
That was exactly what I needed. Thanks buddy.
I was over-engineering my own attempt at a solution, and was so far into the forest, I couldn't see the trees.
|
|
|
|
|
I can't figure out how to control the color of text drawn with CDC::TextOut. CFont or LOGFONT don't seem to have a color attribute, and none of the other crazy things I tried worked. Ideas?
thanks,
Jake
|
|
|
|
|
CDC::SetTextColor(clr);
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
|
|
A long is 32bits.
so try 2^31 for a long (1 bit for sign) and 2^32 for an unsigned long
+-2147483648 and 4294967296
there are defined for these. Look for MAX_LONG, MAX_FLOAT etc.
|
|
|
|
|
from -2147483648 to 2147483648.
The LONG is a 32-bit signed integer!!!
Cheers!!!
Carlos Antollini.
|
|
|
|
|
What this 'xor'?
How do use in this in vc++
|
|
|
|
|
True xor True => False
True xor False => True
False xor True => True
False xor False => False
For use it you need to use the ^ macro.
^ == Xor
Cheers
Carlos Antollini.
|
|
|
|
|
so:
^x;
or so:
x^;
or another ?
|
|
|
|
|
XOR is a binary operator.
z = x ^ y;
if x = 00101101b
and y = 01110111b
then z = 01011010b
Hope this helps.
>>>-----> MikeO
|
|
|
|
|
|
CSrting str;
I want that str would contain some variables in its string
for example so:
str = (" the price is %d, the nameis: %s", x,s);
|
|
|
|
|
Use.
CString::Format();
Is like sprinf();
CString str = _T("");
int iVal = 10;
Cstring strName = _T("Carlos");
str.Format("The price is %d, the name is %s", iVal, strName);
Cheers!!!
Carlos Antollini.
|
|
|
|
|
|
|
The size of an integral type is entirely compiler-dependent (well, except for char which is always 1 byte). In MSVC, an int is 4 bytes.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|