|
|
|
How can I convert a wchar_t into an integer.
iTest is the integer var.
wByteBuff is the wchar_t var.
I tried: swprintf(iTest,"%d",wByteBuff);
but i always get the error :error C2665: 'swprintf' : none of the 2 overloads can convert parameter 1 from type 'int'
i also tried with %x,%X,%i,%u,%c but none of this is working.
|
|
|
|
|
char to int is implicit. Is that not true for wchar ?
swprintf takes wide strings, I can't imagine why you're passing an int as the first parameter ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
try using the _wtoi function
|
|
|
|
|
thanks, but I searched this so much that I forgot what I wanted at first.
I wanted to convert the character contained in the wchar_t to it's decimal value.
|
|
|
|
|
|
Hi,
To start VC++ basics and concepts where shall i start? Do i need to know win32 appln first (by reading "programming windows" by charles petzold) before MFC???
I would like to learn VC++ in deeper. Could anyone suggest me how ?? and provide me some good books and tutorials???
|
|
|
|
|
The first step is to learn C++ itself, without any Windows stuff. IMO, you should then learn MFC, and finally learn Win32, to gain an understanding of what MFC is taking care of for you. This breaks down what you're learning so you can focus on one bit at a time. Learning Win32 then magically finding you don't need to know it anymore is just too much to bite off at once, IMO.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
After seeing a lot of the IM log managers out there I wanted to create a C++ program that via a command line prompt would copy IM log files into a a buffer or text file. While I get access the space in C:\Doc and Settings\GAIM\logs whatever, I cannot figure out how to open those files/ or write them into a buffer or text file. I am creating the program in Visual Studio for WIndows XP platforms.I know I must be missing a simple windows function call but any help would be greatly appreciated! Thanks
|
|
|
|
|
bobfilar wrote: I cannot figure out how to open those files
Your mean read a text file ? You need to use an ifstream. Read my iostreams articles, or google ifstream for more info.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
well... kinda. After reading you article on iostream modifiers and "deriving your own stream" I understand what you mean, but a for instance in what I am trying to do is this. An IM client, say GAIM, stores logs and user preferences on a .xml file. I am wondering if I can code within my program the ability to enter in my program via the command prompt and have it point towards .xml file, but instead of opening the file to view on my desktop its contents get written into another file, say a text file or whatever you feel like. I too immediately looked at iostream for the project, but was still stuck on the implementation. Thanks for the advice though!
|
|
|
|
|
If the file you're reading is XML, then you want an XML DOM implimentation, such as IXMLDocument, which will allow you to read the XML as XML. In fact, if I were doing this, I'd use XSLT to transform the XML into the text I wanted, then an ofstream to write it back to disk.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There is picture(IDB_BITMAP1) on the dialog. after I clicked pic that I choosed, then I got pic instantly disappearing. I am trying to figure it out to get pic appear. can you tell me what did I wrong?
void CAssignDlg::OnPaint()
{
CPaintDC dc(this);
CBitmap mybmp;
CPoint org(0,0);
HBITMAP hBitmap;
HANDLE hImageFile;
if(m_bNoPicture)//before choose pic
{
CBitmap mybmp;
mybmp.LoadBitmap(IDB_BITMAP1);
m_Picture.SetBitmap((HBITMAP)mybmp);
}
else)//after chose pic
{
HBITMAP hBit = (HBITMAP)LoadImage( NULL,
"C:\\Test.bmp",
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE );
CBitmap* b = new CBitmap;
b->Attach(hBit);
m_Picture.SetBitmap(*b);
//DeleteObject(hBit);
}
}
|
|
|
|
|
This is at least a memory leak. Load the bitmap as a member variable, not in your paint handler. You will run out of GDI resources pretty quickly, in fact, that may be what is happening.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am little confusing about "load the bitmap as member variable, not in your paint handler". can you explain it little more?
|
|
|
|
|
class CAssignDlg
{
HBITMAP m_Bitmap; <- THIS is a member variable
void CAssignDlg::OnPaint() <- THIS is a paint handler.
{
CPaintDC dc(this);
CBitmap mybmp;
CPoint org(0,0);
HBITMAP hBitmap;
HANDLE hImageFile;
if(m_bNoPicture)//before choose pic
{
CBitmap mybmp;
mybmp.LoadBitmap(IDB_BITMAP1);
m_Picture.SetBitmap((HBITMAP)mybmp);
}
else)//after chose pic
{
HBITMAP hBit = (HBITMAP)LoadImage( NULL,
"C:\\Test.bmp",
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE ); <- THIS code loads an image EVERY TIME the form gets painted.
CBitmap* b = new CBitmap;
b->Attach(hBit); <- THIS creates a new pointer every time, and because it's not a member variable, you lose it ( you can't ever clean this memory up )
m_Picture.SetBitmap(*b);
//DeleteObject(hBit);
}
}
I would have a CBitmap * in your class, and set it to NULL. Wrap the code to assign the value in a block that checks if the pointer is currently NULL. Delete the pointer in your destructor.
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Did u try declaring mybmp as global
CBitmap mybmp;
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi all:
I am a quite new visual c++.net user. Does anybody know how to compile c++ program in command line?? And also, I need to do a OpenGL project. Does anybody know how to configure opengl in .NET please??
Thanks in advance!!!
Asura
|
|
|
|
|
If you google for nehe, he's got the best OpenGL tutorials on the web.
Why do you want to compile on the command line if you've got the .NET IDE ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Because I downloaded many code written in plain C, it's more convenient to compile it in command line. And also, I want to learn to use command line rather than using .NET IDE. Another reason is I have to port the application to linux system later.
Asura
|
|
|
|
|
any idea on some good localization tools?
Jim456
|
|
|
|
|
TRY using StringDB at www.swbox.com
- supports ALL languages in the world (ASCII, UNICODE, UTF-8)
- uses MS Excel files for translation
- You can change language and strings without recompiling the software
- Non-technical people can prepare new language releases
- Is being used by embedded devices and also PC software
coldstone
|
|
|
|
|
Multiple filename for single resource i.e Icon is not happening.any suggestions on the sharing of filenames between two icons in an .rc file?
Jim456
|
|
|
|
|
Can anyone tell me why this style would work in one list control, but not another (in the same program)?
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|