|
See my other post. Using stringstream just to avoid the buffer overrun issue can cause performance problems. snprintf was created just for this problem.
A while back someone had a problem with std::hash being very slow. It was discovered that he was generating his keys with stringstream. Once he switched over to something with less overhead, it was MUCH faster.
Don't get me wrong, stringstream is great. However in this case it is like using a 767 airliner for cropdusting.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
Thank You everybody.
I would like to mention that it appears snprintf() is limited to Unix. I am using Visual C++ .NET and I had to call _snprintf() for this to work.
I still had to be sure that my string declaration was fairly large to accomodate the whole number.
char fpsString[22];
But, I could easily change decimal precision using the _snprintf().
I'm not sure about the speed issue, but if someone else could confirm that would be nice.
CBerg
|
|
|
|
|
Woops, I forgot about that...
(Which is another reason to use stringstream due to badly designed C routines.)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
char fpsString [80];
float fps;
fps = FrameCnt / TimeElapsed;
snprintf(fpsString, 80, "Fps: %f \0", fps);
1. Trying to sprintf to a string like you were doing might cause problems on some platforms.
2. As someone pointed out, the sprintf might overflow the buffer. snprintf works great to avoid this problem without using STL which has its share of problems.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
See here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
first,in "afx.h" include "afxdb.h"
second declare global variable "CDatabase db;" and define "CString os="ODBC;DSN=MyDb;UID="user";PWD="mypassword";"in view
third,when i write"db.open(NULL,FALSE,FALSE,os);the result of compiling show there are 4 error.
why?
how to connect access database in vc++6.0?(the data source of ODBC done already)
|
|
|
|
|
You create a ODBC connection. Example: Name is MyDb.
The function is:
db.Open("MyDb");
If has User Name, Password:
db.Open("MyDb", FALSE, FALSE, "ODBC;UID=UserName;PWD=MyPassword");
Not use the char " in UserName And Password string
|
|
|
|
|
i did it in the way recommended by you,first ,set the odbc
second in my view declare CDatabase db;at the same time #iclude "afxdb.h"in afx.h,but when i write db.open("student")(student is my odbc data source),
after running ,telling me 4 error.
i am ambarrassed!
|
|
|
|
|
CString sDsn;
CString sFile = "e:\\DAS.mdb"; //path to database
// You must change above path if it's different
// Build ODBC connection string
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ = %s",sDriver,sFile);
TRY
{CDatabase ComboDatabase;
// Open the database
ComboDatabase.Open(NULL,false,false,sDsn);
// Build the SQL statement
SqlCommand = "DELETE FROM BandSetting "
"WHERE BANDNAME = '" + m_Store + "'" ;
ComboDatabase.ExecuteSQL(SqlCommand);
// Close the database
ComboDatabase.Close();
}
CATCH(CDBException, e)
{
// If a database exception occured, show error msg
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;
}
#include "afxdb.h"
#include "odbcinst.h" include these 2 as header files
this shd worl perfectlt fine.. cos it worked well for me =)
|
|
|
|
|
Anonymous wrote:
...after running ,telling me 4 error.
And those errors are?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Since you are using ODBC, and have created a working DSN, why not just let ClassWizard create a CRecordset -derived class for you. It's much easier than the path you are currently taking. Once the class has been created, it's very easy to create and use an instance of it:
CDatabase db;
CMyRecordset rs(&db);
rs.Open();
rs.MoveFirst();
while (! rs.IsEOF())
rs.MoveNext();
rs.Close();
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
I had used Visual C++ AppWizard to create a database using Microsoft's Access but when I copied the whole program into other PC, I could run it.
Listed below is the error message I received.
Error Message - Unable to Locate DLL
The dynamic link library MFC42D.DLL cound not be found in the specified path...
How to I solve this problems?
Need Help
|
|
|
|
|
You find all the DLL file in CD ROM of Visual C++ or Microsoft Access. And then, copy them to C:\Windows\System.
Example: MFC42D.DLL Show on the Error Message
|
|
|
|
|
Hi,
The "Unable to Locate DLL" error is gone but I'm getting another error of "Data source name not found and no default driver specified".
Please Help..
|
|
|
|
|
I'm just guessing here, but this is an ODBC application, and your second machine doesn't have an ODBC source configured, or you have hardcoded the path to your database and it doesn't exist in the same location on the second machine.
Tim is right; it's illegal to redistribute the debug DLLs that Microsoft supply as part of Visual C++, as you will then be in breach of your license agreement.
Steve S
|
|
|
|
|
Ok, I know this is a bit anal, but...
You can not legally redistribute any of the debug libraries. If you are actually trying to distribute this program, then build it in release mode.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
siew hoon wrote:
The dynamic link library MFC42D.DLL cound not be found in the specified path...
You need to compile the application in release mode before distributing it. The only machines that will have the debug versions of the MFC libraries (e.g., MFC42D.DLL) are those with Visual Studio installed. Otherwise, distributing the debug versions of the MFC libraries is against the rules!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Ok, I manage to run the database on a PC with Visual C++ installed. I still don't understand why can I run the .exe file on other PC without Visual C++ installed? I .exe file is an executable file right? I thought .exe file can run in any PC
|
|
|
|
|
siew hoon wrote:
I still don't understand why can I run the .exe file on other PC without Visual C++ installed?
Perhaps you meant "can't." This has already been explained. The .exe depends on one or more DLLs that are not present on machines not having VS installed.
siew hoon wrote:
I thought .exe file can run in any PC
That's correct, assuming all necessary files are present.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Oops, it's a typing error. Should be "can't". Ok, I got the message.
Thank you.
|
|
|
|
|
Hi all;
I am building an application which will need to present quite a few statistics. I was wandering whether to use Microsoft Chart or MS Office chart 9.0. Anyway, can anybody help me in finding a tutorial on eithe please. I badly need it.
Thank you;
Krugger
|
|
|
|
|
Hello,
After enumerating windows, I need to know that a given window CAN accept keyboard input, how can I check that? (By keyboard input, I mean the alphanumeric keys + punctuation keys only, no control keys or extended keys!).
No help with IsWindowEnabled() , because it returns a TRUE for windows like the "Microsoft Outlook" main window. Now that is not what I want, because the MS-Outlook main window DOES not accept any alphanumeric keys or punctuation keys. It accepts control keys like ALT+F, UP, DOWN, TAB, SHIFT-TAB, CTRL-O, etc. But it is the MS-Outlook e-mail composer window (which opens when you want to compose a new e-mail), which can accept alphanumeric keys or punctuation keys. I want the composer window to be listed and the MS-Outlook main window, not to be listed.
Something like the MSN Messenger, ICQ and Yahoo! Messenger main windows. They don't accept alphanumeric + punctuation keys, but only control keys. But the chat window, accepts alphanumeric + punctuation keys.
Is there any way that you have tried something similar, or are you aware about how can I get this going?
Thanks,
Rgds,
Nirav
* Don't wish it was easier, wish you were better! *
|
|
|
|
|
As far as I know, there is no general purpose way to detect if an arbitrary window accepts keyboard input.
There are a couple of things you can try. One, retrieve the class name of the window. The builtin Windows controls (edit, etc.) have well-known class names. Once you know the class name, you can use messages specific to the class to discover how the control is set up, and find out what keys it accepts.
Two, the WM_GETDLGCODE message will get a little of the information you are looking for. It is used by the Windows dialog manager to find out what keys a control in a dialog wants.
BTW: The IsWindowEnabled() function only tells you if the window is enabled, i.e. that it accepts user input. User input means keypresses and mouse activity. Unfortunately, as you've discovered, this has nothing to do with the type of user input the window accepts.
Software Zen: delete this;
|
|
|
|
|
Thanks Gary!
I will start looking at the options you've explained!
Thanks again,
- Nirav
* Don't wish it was easier, wish you were better! *
|
|
|
|