|
format your format string manually ...
something like :
CString sFormatString;
sFormatString.Format ( "% 0.%i", accyf );
m_display.Format(sFormatString , output)
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Use:
m_display.Format("%0.*f", accy, output);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks david. That worked.
-hithesh
|
|
|
|
|
Hi guys,
I am trying to implement the backspace function. The last element of the Cstring should be deleted when the backspace button is pressed.
The data is entered by the used in a text display box.
Thanks in advance.
-hithesh
|
|
|
|
|
1. Code to trim rightmost character form CString.
<br />
CString csTemp;<br />
int iLength;<br />
<br />
iLength = csTemp.GetLength();<br />
if( iLength > 1 ){<br />
csTemp = csTemp.Left(iLength - 1);<br />
}<br />
2. Edit field should be handling the backspace keypress already.
|
|
|
|
|
I think you meant if (iLength > 0) ...
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks Blake. you saved me a lot of time.
-hithesh
|
|
|
|
|
Removing just the last TCHAR will break if the string ends in a DBCS character. You need to call CharPrev() to move back one "character" from the end (whether it's 1 or 2 bytes).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
And I actually know better, thanks for the correction
|
|
|
|
|
I hope i will be your partners
|
|
|
|
|
Me Not!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
i am reading some text from the selected file, then when i push a button i want to insert some data to database (ADO), but cant do. There is an error occured.
i tested : when i dont read data from a file, i can use data functions well.
I even close CStdioFile and delete its pointer.
Can anybody help?
|
|
|
|
|
ugur_basak wrote:
There is an error occured.
I give up. What's the error?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Oh come on David Use your ESP, or lacking that, take a wild guess. You may just hit upon the correct solution.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
the error:
Runtime Error!
Program:..... .exe
This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
---
the error is about this sentence.
pConnectRead->Open(commandString, connectionString, adOpenStatic, adLockReadOnly, adCmdText);
can this be helpfull to GUESS the solution.
|
|
|
|
|
ugur_basak wrote:
Runtime Error!
Program:..... .exe
Usually this type of error occur due to IMproper/unreferenced Memory allocation.
ugur_basak wrote:
pConnectRead->Open(commandString, connectionString, adOpenStatic, adLockReadOnly, adCmdText);
have you checked that is pConnectRead hold valid memory or any of it args!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, NULL, this);
if(fileDlg.DoModal()==IDOK)
{
sSelectedFile = fileDlg.GetPathName();
}
I guess the problem is about the above code, when i use this dialog window the error happens. But if i use the files path name by editing the editbox there is no error.
But still cannot use this dialog
|
|
|
|
|
At the end i find the solution. its about an ugly problem. When we use CFileDialog without OFN_NOCHANGEDIR, it doesnt release some of the handles, and system crashes...
dlg = new CFileDialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_NOCHANGEDIR);
this solves everything...
|
|
|
|
|
I need some help in codding ActiveX container. Short description : Microsoft Visual Studio 2003 and other vsersion (6,7) , includes sample TstCon - a sample of ActiveX Container. When I place control and than delete it or open new document, this program hang up every time when i close it.
I modified ContainerItem method OnDelete()... after pItem->Delete() i put delete(pItem); its all works under win2k... but... in 98SE,XP after deleting control, when i try to insert new control an error occured "Failed to connect.Link may be broken".
So does any one knows how to solve this, and force it to work correctly.
Thanks.
|
|
|
|
|
I have a dialog based application which runs fine on NT and 2000. However, it doesnt work under XP. I have done some traces, the application gets invoked, but the main dialog window does not appear. Any ideas?
Man Learns from History that he never learns from History
|
|
|
|
|
May be its problem with controls (especialy when using CustomCtrl) in your dialog.
|
|
|
|
|
Create the dialog with the DS_NOFAILCREATE style. If that works, then you know there is a control-related issue. This is normally because an ActiveX control is being used that does not exist, or has not been registered, on the target machine.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hiho@ll
i'm using this http://www.codeproject.com/library/lyoulhttpclient.asp http client to upload a file (like the example)
what i do:
i'm uploading a few text files, not very big, 1 or 2kB
the problem:
i can upload (to my self programmed php script) 2 files
the third file doesn't work
HttpSendRequestExA (on line 639 in the http client above) throws a exception after a few minutes! (i get error code 12002 ERROR_WINHTTP_TIMEOUT)
The Apache doesn't get a request! in the access.log i only see the first two requests
the flags for the connection are NTERNET_FLAG_HYPERLINK | INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_UI | INTERNET_FLAG_RESYNCHRONIZE | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD
1. anybody else had similar problems with HttpSendRequestEx (and what solved/caused the problem?)
2. anybody has an idea what's causing the problem
3. solutions/workarounds?
4. i don't know how to analyze the problem, so know what causes the problem
how can i analyze what HttpSendRequestExA does to know what causes the problem?
5. may it helps if anyone explains how to use HttpSendRequestExA (i mean, making a connection, working with the connection, closing the connection (just like a function list/ maybe the connection isn't closed and i don't know which function does this))
thx@ll
|
|
|
|
|
i tried the example from the msdn and i get an error 997 Overlapped I/O operation is in progress
the code:
BOOL UploadToURL::Test(TCHAR *upFile){
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
HINTERNET hConnect=NULL,hInternet=NULL;
hInternet=InternetOpen("User Agent",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,INTERNET_FLAG_ASYNC);
hConnect=InternetConnect(hInternet,"127.0.0.1",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,NULL);
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );
HINTERNET hRequest = HttpOpenRequest (hConnect, "PUT",
"/upload.php", NULL, NULL, NULL, 0, 0);
if (!hRequest)
{
printf("Failed to open request handle: %lu\n", GetLastError ());
return FALSE;
}
HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("\nFailed to open local file %s.", upFile);
return FALSE;
}
BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
printf ("File size is %d\n", BufferIn.dwBufferTotal );
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE, 0))
{
DWORD d=GetLastError();
printf( "Error on HttpSendRequestEx %lu\n",d);
return FALSE;
}
DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
printf ("\nReadFile failed on buffer %lu.",GetLastError());
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
printf ("\nInternetWriteFile failed %lu", GetLastError());
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle (hFile);
printf ("Actual written bytes: %d\n", sum);
if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
printf( "Error on HttpEndRequest %lu \n", GetLastError());
return FALSE;
}
return TRUE;
}
but this time i get the error in the first try!
|
|
|
|
|
|