|
Hi there.
While sprintf works, it is really a C solution. I just wanted to show you a C++ solution for creating a string to display by using streams.
<br />
#include <sstream><br />
<br />
double num1 = 3.143;<br />
<br />
std::ostringstream outStream;<br />
std::string outString;<br />
<br />
outStream << "Value of double is : " << num1;<br />
<br />
outString = outStream.str();<br />
<br />
label1->Text = gcnew String(outStream.str().c_str());<br />
Using the ostringstream, you will not have to worry about the size of your char array, or have a ptr to char and do any memory allocation/cleanup. All done for you.
Cheers
|
|
|
|
|
How could i get the size (height and width) of the screen by calling a windows API function?
Thanks!
|
|
|
|
|
How about GetSystemMetrics() , or GetDeviceCaps() ?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
If you want to take account of the taskbar, use SystemParametersInfo with SPI_GETWORKAREA . Bear in mind that on a multi-monitor system, each monitor can have a different resolution.
|
|
|
|
|
Hi
i want to take data from user through textbox or rich editbox and write it into the Microsoft Word file and the other thing is that the data written in file shud be colored and bold.
can anybody help me out
thanx
Saima Javaid
|
|
|
|
|
|
I have been putting it off for a month now because i couldnt find a real good place to start studying for this. So i figured I would ask you all here if you recommend some nice places or books to read to work with Internet programming using Windows Sockets or (if you think it is better) any other socket programming.
obviously if at all possible I'd like to study Windows sockets 2, but 1.1 is ok I guess. Remember before you say go read MSDN I am really new to Internet/Network Programming, so something that will guide me is truly the most helpful.
Thanks
|
|
|
|
|
CNewbie wrote: Remember before you say go read MSDN I am really new to Internet/Network Programming, so something that will guide me is truly the most helpful.
What does being new have to do with (not) reading MSDN? In addition to that, I would suggest Googling for specific topics, and perusing this section of CP.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Learn winsock programming via books. I highly recommend Network Programming for Microsoft Windows Second Edition by Anthony Jones and Jim Ohmund.
Check out my website for software development links.
http://www.dslextreme.com/users/kuphryn/links.html[^]
Kuphryn
|
|
|
|
|
|
Thanks Waldermort for your contribution. I wish to capture keys from the keyboard using system-wide windows hooks. I'm not using MFC but Visual Studio's WIN32 Application and DLL. I don't know how to capture keys such as * . + @ # % & etc. How can I do this?
I'm using the following:
if (((keyvalue>=0x41) && (keyvalue<=0x5A)) || (key==VK_SPACE))
to capture keys a..z and the spc key.
Thanks
Ev Scott
EvScott
|
|
|
|
|
you would have to trap and test the value of your WM_CHAR message. You would normally do this in your message loop and send the chars to your winproc.
|
|
|
|
|
Sorry, but how would I do this?
EvScott
|
|
|
|
|
Who can i Know that my Application Supports Doc/View Architecture? using which function call ?
Pls help me Sir
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
if you have the source code, just look at it, otherwise, I'm not certain from an external point of view that it possible ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I am working on some project and can't overcome some errors. I can't understand how typecast is done in C++/C. What if we convert smaller type to bigger - how is it done? And bigger to smaller? Do we just truncate the data to biggest one or... what?
I would be grateful if you could explain that to me.
|
|
|
|
|
Netvisdom wrote: What if we convert smaller type to bigger
No problem. In fact, some types are automatically promoted.
Netvisdom wrote: how is it done?
char c;
int n = c; Netvisdom wrote: And bigger to smaller?
There is potential loss of data.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thanks, but I ment what there would be if we convert, for example, int to char - truncated or maximum number? And what about other convertion cases?
|
|
|
|
|
Netvisdom wrote: ...but I ment what there would be if we convert, for example, int to char...
There would be loss of data if the int value was 128 or greater.
Netvisdom wrote: And what about other convertion cases?
Such as?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I think he is asking, if you cast an int down to a char, does the char take on the value of the least significant byte of the original int, or does the char take on the value of the highest value that a char can hold.
For instance, if the int held the value 50, then it's clear that the char would take on the value 50, but if the int held the value 356, would the char take on the value 128 since 128 is the highest number a char can hold?
|
|
|
|
|
Troposphere wrote: ...but if the int held the value 356, would the char take on the value 128 since 128 is the highest number a char can hold?
No, it would "wrap" all the way back around to (positive) 100. The leftmost 16 bits would go away. A better example would be if the int value was something like 200. The resulting char value would be -56. The leftmost 16 bits still go away, but now the sign bit is 1, indicating a negative.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I am not able to read & write to serial port in WINDOWS CE using embedded visual c++. i am including the code i have tried.it showing no.of bytes written as 1 but while reading it is showing as no.of bytes read as 0.
//writing
DWORD dwError,dwNumBytesWritten;
int rc;
HANDLE hPort;
BYTE B;
TCHAR* pFileName = TEXT("COM1:");
B='a';
hPort =CreateFile(pFileName,GENERIC_READ| GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
rc=WriteFile (hPort,&B,1,&dwNumBytesWritten,NULL);
CloseHandle (hPort);
//reading
DWORD dwError,dwNumBytesRead;
int rc;
HANDLE hPort;
BYTE B;
TCHAR* pFileName = TEXT("COM2:");
hPort =CreateFile(pFileName,GENERIC_READ| GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
rc=ReadFile (hPort,&B,1,&dwNumBytesRead,NULL);
MessageBox(NULL,TEXT(""+B),NULL,MB_OK);
CloseHandle (hPort);
can anyone please halp me
Thanks for your reply in advance.
Neha
|
|
|
|
|
I'm looking for a quick template or sample code to write a quick "installer" type program in (not managed) C++ to install items to the PROGRAMS folder that simply are links to a website.
For example, START / ALL PROGRAMS / MY FOLDER / Link 1, Link 2, etc.
Does anyone have anything like this?
|
|
|
|
|
See here and here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|