|
If ypur system really doesn't provide wtof , you may consider to convert your wide character string into standard (i.e. ANSI ) one, via WideCharToMultiByte ), and then use atof .
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
[My articles]
|
|
|
|
|
Hello,
Thanks. I tried the following way :
CString csValue;
GetDlgItem(IDC_PRICE_EDIT)->GetWindowText(csValue);
.....
char* dest;
WideCharToMultiByte(CP_ACP, 0, csValue, -1, dest, 10, NULL, NULL);
float flt = (float)atof(dest);
CString d(_T("Converted Float:"));
d.Format(_T("%s %.2f"), d, flt);
AfxMessageBox(d);
Using WideCharToMultiByte method, I put all values accordingly & converted to float using atof. I get the converted value. BUT as soon as the Converted .. msg box is displayed I also get "Assertion Failed!" :File thrdcore.cpp, Line 867 Abort/Ret/Ig. Retry or ignore doesn't respond so I have to select Abort. It points to
if (m_nDisablePumpCount != 0)
{
TRACE0("Error: CWinThread::PumpMessage called when not permitted.\n");
--------> ASSERT(FALSE);
}
of PumpMessage().
Where am aI going wrong can you point out? Do I need to change anything in Wide...(). AS dest is not initialized, I get warning message for that also.
I have also noted that in eVC++4 I get exceptions at Assert many times, any special reason?
Thanks
Terry
|
|
|
|
|
Trupti Mehta wrote: Where am aI going wrong
You didn't allocate memory for the dest buffer.
The buffer should large enough to get the converted string. Hence you may write
int iLen = csValue.GetLenght();
char * dest = new char[iLen+1];
WideCharToMultiByte(CP_ACP, 0, csValue, -1, dest, iLen, NULL, NULL);
delete [] dest;
or, using a reasonably large array:
char dest[MAX_PATH+1];
WideCharToMultiByte(CP_ACP, 0, csValue, -1, dest, MAX_PATH, NULL, NULL);
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
[My articles]
|
|
|
|
|
Thanks CPallini, its working perfectly as expected. Got rid from all type casts.
Thanks a lot to all of you trying to solve my problem.
Thanks
Terry
|
|
|
|
|
i think your running into trouble with the double cast
((char*)(LPCTSTR)csValue
i think LPCTSTR boils down to wchar_t
so the double cast (char*)(wchar_t*) would be doing horrid things
the wise Pallini has stated the appropreaite funcs
|
|
|
|
|
killabyte wrote: the wise Pallini
like Alfonso of my sign.
Thank 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
[My articles]
|
|
|
|
|
Yeah i really liked that quote in your sig
|
|
|
|
|
I like second more
Regards,
Sandip.
|
|
|
|
|
Trupti Mehta wrote: m_opNo = atoi((char*)(LPCTSTR)csValue);
What's with all the casts?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
As DavidCrow asked....what's with the casts?
I always recommend using NO casts unless absolutely necessary.
If something doesn't compile without the cast, look CLOSELY AT WHY
before casting away the problem.
In this case, you casted away your compile-time problem and turned
it into a run-time problem
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
Whats the difference between CFile and CStdioFile ?Why we are use CFile and CStdioFile?
Thanks
Nisha
|
|
|
|
|
Do you feel documentation (CFile [^] & CStdioFile [^]) inadequate on these subjects?
Roughly speacking, since CStdioFile inherits from CFile we espect the former augmenting the latter functionalities: a quick look at documentation show us two interesting methods (ReadString and WriteString ) provided only by CStdioFile .
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
[My articles]
|
|
|
|
|
CFile deals with any kind of files where CStdioFile deals with TEXT files by default with an implicit convertion of newline character 0x0a into a pair of (0x0d and 0x0a)
The two methods, WriteString and ReadString provided in CStdioFile class assumes the delimiters of each line in the file as CRLF and newline. It can also be used for binary files as well, but certain functionality provided by CFile like Duplicate(), LockRange() etc are not supported in CStdioFile.
|
|
|
|
|
If any body can quide me how can Control Panel designing (PC Interfacing) can be done in VC++. Any website or book for designing Control Panels to interface periferals to computer and control them and to collect data for manual test purpose please.
kd
|
|
|
|
|
Are you wanting to know how to create a Control Panel applet?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Actually I know designing window of control panels, I need to know programming for coms interfacing and data retrieving from external pariferals connected to PC by I2C or RS232. If you know any helping website or book please?
kd
|
|
|
|
|
Read from and write to serial ports using ReadFile() and WriteFile() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks a lot for help. It gave me a good clue.
kd
|
|
|
|
|
hi every body
can you help me with this
how can I get a bitmap from a path in a database field
in a static picture box in the form view
I am using visaul studioC++ ver 6
thanks
I am a Civil Engineer, graduated in 1969, I've a wide experience in quite many fields of civil engineering, aswellas in HR development, Quality assurance, planning and QC,
I've been employed by Consultant Offices, Contractor Companies,
I did services for both Public Sectors and Private Sectors,
I've been in charge in Projects located inside and outside Egypt,
I've dealt with both Arabic companies and American Companies.
All these movements have given me a great variety of experiences.
|
|
|
|
|
Is the problem with reading the path from database or loading and displaing the image or both ?
|
|
|
|
|
you see the program consider the field as a string
so how I tell him this is a file path not a string
becuse he fill the other Edit boxes with strings from
the other fields but for the picture box I gave him a static
variable and I use the loadimage and Bitblt but nothing
shown in the picture box
I am a Civil Engineer, graduated in 1969, I've a wide experience in quite many fields of civil engineering, aswellas in HR development, Quality assurance, planning and QC,
I've been employed by Consultant Offices, Contractor Companies,
I did services for both Public Sectors and Private Sectors,
I've been in charge in Projects located inside and outside Egypt,
I've dealt with both Arabic companies and American Companies.
All these movements have given me a great variety of experiences.
|
|
|
|
|
here is my code I hope you tell me what is wrong with it?
void CFilmsView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
// TODO: Add your specialized code here and/or call the base class
CDaoRecordView::OnActivateView(bActivate, pActivateView, pDeactiveView);
//CPaintDC dc(this);
CClientDC dc(this);
HBITMAP bmpHandle = (HBITMAP)LoadImage(NULL,strPictureName,IMAGE_BITMAP,
0,0,LR_COPYFROMRESOURCE);
CBitmap bmpPicture;
CDC mdcPicture;
CBitmap *bmpFromHandle = bmpPicture.FromHandle(bmpHandle);
CRect rctPicture;
m_Picture1.GetWindowRect(&rctPicture);
mdcPicture.CreateCompatibleDC(&dc);
CBitmap * bmpPrevious = mdcPicture.SelectObject(bmpFromHandle);
ScreenToClient(&rctPicture);
dc.BitBlt(rctPicture.left, rctPicture.top,
rctPicture.Width(), rctPicture.Height(),
&mdcPicture, 0, 0, SRCCOPY);
dc.SelectObject(bmpPrevious);
//DeleteObject(bmpHandle);
I am a Civil Engineer, graduated in 1969, I've a wide experience in quite many fields of civil engineering, aswellas in HR development, Quality assurance, planning and QC,
I've been employed by Consultant Offices, Contractor Companies,
I did services for both Public Sectors and Private Sectors,
I've been in charge in Projects located inside and outside Egypt,
I've dealt with both Arabic companies and American Companies.
All these movements have given me a great variety of experiences.
|
|
|
|
|
What have you done so far?
What are your troubles about?
(i.e. Please be more specific)
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
[My articles]
|
|
|
|
|
I gave the picture box a static control
the program fill all the Edit box aith the string variables I gave him but for the picture box he treated the field as a string not a file path here is my code hope you can tell me what is wrong with it
void CFilmsView::OnPaint()
{
strPictureName=m_pSet->m_P1;
strPictureName=("E:\\BMP\\Hany\\Jimy1.bmp");
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// TODO: Add your control notification handler code here
HBITMAP bmpHandle = (HBITMAP)LoadImage(NULL,strPictureName,IMAGE_BITMAP,
0,0,LR_LOADFROMFILE);
LoadBitmap(0,strPictureName);
CBitmap bmpPicture;
CDC mdcPicture;
CBitmap *bmpFromHandle = bmpPicture.FromHandle(bmpHandle);
CRect rctPicture;
m_Picture1.GetWindowRect(&rctPicture);
mdcPicture.CreateCompatibleDC(&dc);
CBitmap * bmpPrevious = mdcPicture.SelectObject(bmpFromHandle);
ScreenToClient(&rctPicture);
dc.BitBlt(rctPicture.left, rctPicture.top,
rctPicture.Width(), rctPicture.Height(),
&mdcPicture, 0, 0, SRCCOPY);
dc.SelectObject(bmpPrevious);
DeleteObject(bmpHandle);
// Do not call CDaoRecordView::OnPaint() for painting messages
}
I am a Civil Engineer, graduated in 1969, I've a wide experience in quite many fields of civil engineering, aswellas in HR development, Quality assurance, planning and QC,
I've been employed by Consultant Offices, Contractor Companies,
I did services for both Public Sectors and Private Sectors,
I've been in charge in Projects located inside and outside Egypt,
I've dealt with both Arabic companies and American Companies.
All these movements have given me a great variety of experiences.
|
|
|
|
|
Hi,
I have developed an application in eVc++4 on ARMV4I device. At present the application is ready adn in testing phase. Before handing over the final version, I want to know how to do the following:
1) The user should able to start the application only once i.e. if the application is already running, the user shouldn't be able to open another time the application.
2) Create a setup for the application. I want to restrict the setup being used only 3 times. Creating shortcut on desktop will be handled with the setup.
3) Add the application in the start up.
Any helpline and guidance for the above is highly appreciated.
Thanks
Terry
|
|
|
|
|