|
KarstenK wrote: The app icon is sometimes tricky. Best is to give it the lowest icon ID in the resource.h
I second that. I had a similar problem which was solved by doing this
Graham
Librarians rule, Ook!
|
|
|
|
|
Hi all,
please tell me how can i convert CString to float or vice Versa.
i m using this,
float fvar;
CString foo;
foo = "123.45";
fvar= atof(foo);
but this not working.
Please tell me.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: but this not working.
any error message ?
|
|
|
|
|
No there is no error message.
but after calculation the final resul is Zero, that is wrong.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
try
fvar= atof((LPCSTR)foo);
Graham
Librarians rule, Ook!
|
|
|
|
|
i m also try this but same problem occur here.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
The only reason that I can think of that neither code works is that the string contains some other character before the numbers. atof will strip off any leading whitespace characters (MSDN says spaces and tabs only, but in my testing it also strips of newlines). Any other characters, probably including non printable characters, could cause it to return zero. Have you checked the characters in your string?
Graham
Librarians rule, Ook!
|
|
|
|
|
ThatsMe. wrote: but this not working.
Its working fine in my dialog based testapp. I could find only one warning -
"warning C4244: '=' : conversion from 'double' to 'float', possible loss of data".
Since atof() returns double instead of float .
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
is "." the right comma sign, or "," It depends on the system settings.
Set the warning level of the compiler higher to get a message. It also should work harder.
(Use double)
Greetings from Germany
|
|
|
|
|
I answered this for you on Codeguru, but in case you visit here more often...
The most likely reason I can think of (since you don't explain "not working" is this...
If you application is Unicode (default for VS2005 and later) then you can either change it to MBCS, or change your code to:
float fvar;
CString foo;
foo = _T("123.45");
fvar= _tstof(foo);
This change will allow it to work with either Unicode or MBCS.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
ThatsMe. wrote: please tell me how can i convert CString to float or vice Versa.
You can always use std::stringstream and the << operator instead of the old, insecure C-ish atof.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hi,
I use GetDlgItem in thread. But it shows the error that GetDlgItem() does not take 1 parameter. For that i found i have to incude handle for my dialog box. I have displayed the dialog by using DoModal().
I dnt know how to create HANDLE for this dialog.Pls help me .
Anu
|
|
|
|
|
From your question, I think you're using MFC and your dialog class is derived from CDialog . Then call GetSafeHwnd() to get your dialog handle.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Try this.
CEdit* pBoxOne;
pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);
GotoDlgCtrl(pBoxOne);
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Anu_Bala wrote: I use GetDlgItem in thread
You probably then call GetDlgItem outside your dialog class, which means that you are calling ::GetDlgItem and not CDialog::GetDlgItem (which are two different functions). The way to solve this is to pass the pointer to your class instance (the this pointer) in the thread parameter, cast it back to your class in the thread function and call GetDlgItem on it.
|
|
|
|
|
Whats the error? it needs to a handle to window?
|
|
|
|
|
you havent understand the MFC right. GetDlgItem() is a class member of a CWnd dervied class. A Thread not!!!
You better redesign your program with help of a seasoned mate.
Make change in the dialog only in the dialog (thread: your main app)
unse only HWND and communicate with PostMessage-API.
Greetings from Germany
|
|
|
|
|
How to implement CDC MoveTo(int, int) in windows sdk.
Regards
|
|
|
|
|
No need to implement. Microsoft did it for you [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
Need the windows api version of CDC::MoveTo() ? Check MoveToEx() function.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Do you need to MoveTO and LineTo? see this example of MSDN:
void Marker(LONG x, LONG y, HWND hwnd)
{
HDC hdc;
hdc = GetDC(hwnd);
MoveToEx(hdc, (int) x - 10, (int) y, (LPPOINT) NULL);
LineTo(hdc, (int) x + 10, (int) y);
MoveToEx(hdc, (int) x, (int) y - 10, (LPPOINT) NULL);
LineTo(hdc, (int) x, (int) y + 10);
ReleaseDC(hwnd, hdc);
}
|
|
|
|
|
On Proc or Message loop add hook on WM_PAINT
switch ( Message )
{
case WM_PAINT: {
PAINTSTRUCT ps;
ZeroMemory ( &ps, sizeof ( PAINTSTRUCT ));
HDC hDc = BeginPaint ( /*handle of your window*/, &ps );
MoveToEx ( hDc, 0, 0, NULL );
LineTo ( hDc, 10, 10 );
EndPaint ( /*handle of your window*/, &ps );
}
return 0L;
}
}
You can adjust color with HPEN and SelectObject.
Bye...
...
|
|
|
|
|
how to craete a thread in MFC????and implement multithreading,i need to implement a seperate thread of operation inside a button click,what should be done,and createthread() doesn't work
Raja
|
|
|
|
|
Check this -
http://www.codeproject.com/KB/threads/threads_and_mfc.aspx[^]
Mohanraj D wrote: and createthread() doesn't work
Check the error code by adding @err,hr in the watch window. You'll get the reason why its getting failed. If you still have trouble, the post the relevant code.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|