|
CString str;
str.Format("%i", YOURDWORD);
yourtextbox.SetWindowText(str);
I thing you can just cast it:
int yourint;
yourint = (int)YOURDWORD;
or
yourint = static_cast<int>(YOURDWORD);
should be something like this.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Hi,
Could you help me?
How to find lenght of any string in MFC.
rajesh
|
|
|
|
|
Depends of the type of the container
CString str = "Hello";
str.GetLenght();
char *pcHello = "Hello";
strlen(pcHello);
Check also:
wcslen
_mbslen
_mbstrlen
....
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
CString str = "Any string ";
int len = str.GetLength();
len will return u zero based length
Also chk CString class in MSDN..
|
|
|
|
|
Another method would be.
CString a;
i=0;
do
{
if(a.GetAt(i)=='\0') return i;
i++;
}
The easiest way is CString.GetLength()
|
|
|
|
|
If a has more than one \0 character, your method would not work.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
And why wouldnt it?
Bikram Singh
|
|
|
|
|
Because the return statement gets executed at the first \0 character. A CString object can contain more than one \0 character.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes, but when one says "string length", it does not include null characters. assuming ofcourse, the discussion related to ansi chars.
btw, really really nice signature !! ha ha !!!
Bikram Singh
|
|
|
|
|
"String" and "null-terminated string" are not the same thing. A string can have a length in bytes as well as a length in characters. Assuming ANSI is a habit long since broken.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I agree with you.
Was just trying to answer a question I felt was a novice one, thats all.
I really do respect your knowledge!
Bikram Singh
|
|
|
|
|
bikram singh wrote:
If a has more than one \0 character, your method would not work.
but you do agree, this statement was intended for a "more knowledgable" audience, dont you?
You must have been in a hurry while replying, cos given your knowledge, you would have mentioned the words "unicode" and "ansi"!
I really do appreciate your knowledge!
Bikram Singh
|
|
|
|
|
In my program in VC++, i call functions that are defined in another machine.
When i debug my program (i.e. i go step by step by pressing f10) when i get to some of those extern functions, strange things happen: The debugger jumps many lines and it never stops in the extern functions. I cant ever put a break point in those lines!
Whats happening? Is anything i could do?
|
|
|
|
|
Seems like your linking against a release version of the library that is on the other machine
You need to build on that machine a debug version and link to it.
Or debug on the assembly level
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
mufasa2 wrote:
In my program in VC++, i call functions that are defined in another machine.
You have code on one machine that is using code on another machine. Is that correct? Are these other functions exported in some DLL? Are you explicitly or implicitly linking with this DLL?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Im the opposite of an informatic expert, so i will try to describe my best.
I have a controller simulator program that runs in a SGI machine.
I have a prog in C++ in a windows machine. this prog has a project which is a static library. This project has to call functions of the controller simulator.
In the project properties, in "libraries generation/other dependances" i input two libraries statiques of the simulator (like one example i have that makes use of the simulator).
I also declared a environement variable which makes reference to a file named "site".
"site" has information of the machine of the simulator: IP, port number. Thats how the connections are made (i follow also the same example as before)
|
|
|
|
|
Hello ,
I have a dialog based application.
On a menu command I need to hide sone controls (edit box and buttons) and I can do it (setting as not visible)
Now I need to resize the main dialog, since there is an empty area.
I tried with this (IDD_TEST_GUI_DIALOG is the ID of the main dialog window):
CWnd* pWnd = GetDlgItem(IDD_TEST_GUI_DIALOG);
RECT rc;
pWnd->GetWindowRect(&rc);
rc.right -= 100;
ScreenToClient(&rc);
pWnd->MoveWindow(&rc);
but I get an error.
If, instead of IDD_TEST_GUI_DIALOG, I put the ID of any other child element the function works.
What did I do wrong?
In debugging I find that, after GetDlgItem pWnd is 00000
Thanks in advance
Marco.
|
|
|
|
|
for some reason it's not possible to do a GetDlgItem on a dialog (IDD_...)
You can however, resize and shift your controls in your dialog.
Maybe that's a solution?
Their is a way to resize your dialog, but I have no idea on how. Is there no article about this?
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Why do you try to get a pointer to your own class?
Try this code:
GetWindowRect(&rc);
rc.right -= 100;
ScreenToClient(&rc);
MoveWindow(&rc);
|
|
|
|
|
Hi
I have some questions regarding C++ basic types:
1. Is DWORD the same as unsigned long?
2. What's the difference between BOOL in VC++ and bool in C++? It seems that they're functionally identical, so why the redundancy?
Thanks!
|
|
|
|
|
DWORD I'm not shure. (I think it's 32bit data which can be interpreted as something else then a integer)
BOOL: 0,1 or 2,3,4,... (TRUE is defined as 1 and FALSE as 0)
bool: true or false, this cannot be a number, but is a boolean, a BOOL can be an integer value.
hope it helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
typedef unsigned long ULONG
typedef ULONG DWORD
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Indrawati wrote:
2. What's the difference between BOOL in VC++ and bool in C++? It seems that they're functionally identical, so why the redundancy?
VC++ creates a layer between native types and data types used in the VC++, BOOL is same as bool in windows, may be it will be different in the future release of VC++ or depending on the platform.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Mr.Prakash wrote:
BOOL is same as bool in windows
How so? One is 4 bytes while the other is 1 byte.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
bool is a C++ native type for boolean values whereas BOOL is merely a typedef for int
since C/ C++ treat int values as boolean. The benefit could be in performance etc. for e.g. if
you try to assign int to a bool you get this warning:
Compiler Warning (level 3) C4800
'type' : forcing value to bool 'true' or 'false' (performance warning)
DWORD etc are portable datatypes defined in Windows SDK. You can find a part of
the list in MSDN Library help.
BOOL A Boolean value.
BSTR A 32-bit character pointer.
BYTE An 8-bit integer that is not signed.
COLORREF A 32-bit value used as a color value.
DWORD A 32-bit unsigned integer or the address of a segment and its associated offset.
LONG A 32-bit signed integer.
LPARAM A 32-bit value passed as a parameter to a window procedure or callback function.
LPCSTR A 32-bit pointer to a constant character string.
LPSTR A 32-bit pointer to a character string.
LPCTSTR A 32-bit pointer to a constant character string that is portable for Unicode and DBCS.
LPTSTR A 32-bit pointer to a character string that is portable for Unicode and DBCS.
LPVOID A 32-bit pointer to an unspecified type.
LRESULT A 32-bit value returned from a window procedure or callback function.
UINT A 16-bit unsigned integer on Windows versions 3.0 and 3.1; a 32-bit unsigned integer on Win32.
WNDPROC A 32-bit pointer to a window procedure.
WORD A 16-bit unsigned integer.
WPARAM A value passed as a parameter to a window procedure or callback function: 16 bits on Windows versions 3.0 and 3.1; 32 bits on Win32.
Due Regards
Mahendra
|
|
|
|