|
Hi all, quick question. I dont know how to save to a buffer in C++ only in C with sprintf().
Can anyone tell me how to print to a buf with C++? Thanx in advance!
|
|
|
|
|
dellthinker wrote: I dont know how to save to a buffer in C++
dellthinker wrote: tell me how to print to a buf with C++
Save...print... what to what kind of buffer?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
dellthinker wrote: Hi all, quick question. I dont know how to save to a buffer in C++ only in C with sprintf().
sprintf also available in c++ too. are talking abt std::string class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
|
Hello,
I am storing a card number 9999999999 in the database as hexa format 0x09090909090909090909,
i have to send it to the controller in a pack of 5 binary (in hexa Format), meaning 0x02540BE3FF
any sample code appreciated.
With Rgds,
Anil
|
|
|
|
|
__int64 llValue = _tstoi64(_T("9999999999"));
Send low-order 5 bytes of llValue
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Wait, I missed half of this earlier...
AnilUnni wrote: I am storing a card number 9999999999 in the database as hexa format 0x09090909090909090909
Wouldn't ASCII have been easier?
I guess you need to convert those "hexa format" (why the "0x"??) digits to ascii then convert to binary.
Is this homework?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi -
I've been working on a large multi-threaded VC++ 6.0/MFC application for some years and use ODBC as the main database service provider to a backend database in SQL Server 2000.
For one client's application, though, we notice that the ODBC connection disappears from time to time (their database generally resides on a different machine) and the application crashes when it makes a database request over a handle that's gone bad. As the application has recently started transporting real money, this is unacceptable and I need to know the answers to two questions:
1. Is it possible for the ODBC driver to alert me when it determines that a connection has died, rather than leaving me find out the hard way? The application is idle perhaps 98% of the time and a temporary outage caused by a resurrect-on-connection-death is going to affect the performance far less than a system crash.
2. If there is no answer to (1), is there an alternative to ODBC that will give me this functionality - either something (a) that is stateless and which will allow me to query, read and write the database without requiring handles or (b) or which has a fast connect, so that I can make a connection every time that I need to do something or (c) something that doesn't crash when the connection is lost? You can assume that I'm going to continue using VC++ 6.0/MFC for the foreseeable future.
thanks folks,
- robin.
|
|
|
|
|
1) I don't think so, i don't recall any callback functionality, nor do i believe the connection is 'live', i think it is like (is?) a TCP/IP connection.
2)
a)
i)Rewrite the app as a client-server system that can handle caching data while the server is offline.
ii) See if any of the SQL server replication (pub-sub) services can help you.
b) You say that a reconnect would be acceptable, in that case i would suggest turning on connection pooling and reconnecting each time. If there are a lot of requests in a short period then a connect request will receive an existing connection from the pool (fast), if not then a full connect will happen (slower).
c) Why not test the connection before you use it ? If bad reconnect. There shouldn't be any reason for the app to crash.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
cmk wrote: c) Why not test the connection before you use it ? If bad reconnect. There shouldn't be any reason for the app to crash.
I've done this in another module for this application, but it's unreliable because (AFAIR) the code which checks if the database handle is alive (it does a "SELECT GETDATE()") generally crashes if the HDBC is dead. Doesn't do it all the time, which is why I've written it this way. Catching 25% of problems is better than catching none at all.
I might try the connection pooling method and see how I get on with that. It's certainly goin to give better results than I've been getting to date.
Thanks for your help
|
|
|
|
|
Hi
I need to subclass Command Prompt window but CP window's WndProc is Zero , therefore i can not call DefWndProc
I do subclassing window using global hook
Thanks for your ideas
|
|
|
|
|
There is no windows message loop for command prompt applications, so no message queue and no routing of messages to a WndProc.
You could use a hidden window though.
What are you trying to do ?
|
|
|
|
|
I mean window of CMD.exe , i think CMD.exe is a window application , it has window handle , window class , ... , an program can use most of window related functions with Command Prompt window
I use global hook to subclass all top-level windows , in their subclassed WndProc i will send useful messages to main program written in .NET , main program will do something such as : adding title button + system menu , managing window . Would you like to try it ?
|
|
|
|
|
In a new MFC application, I obtain positional data from an eternal source, but would like to generate a Google Earth type image with this data. Perhaps updated a few times per second.
I have looked at Global Majic ActiveX controls (Digital Map), but are they any others that are out there?
I did think of Microsoft's Flight Simulator, it that an option?
Many thanks,
Andy.
|
|
|
|
|
Hi,
Is there any built in separator control in MFC?
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language; please excuse any grammatical or spelling mistakes"
|
|
|
|
|
pDC->MoveTo (100,0);
pDC->LineTo (100,100);
will draw a line, separating two parts of a DC....?
I feel fairly sure that's not what you are after though. Can you explain your question differently?
If it's for putting a line in a dialog box, I just use a static control, with the sunken flag, and make its width (or height) equal to zero.
Iain.
|
|
|
|
|
Iain thanks for reply, i want this sort of separator in some of my dialogs.
http://i9.tinypic.com/5ytbbsj.jpg[^]
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language; please excuse any grammatical or spelling mistakes"
|
|
|
|
|
Use Spy++ to find out what sort of control that is. I'd hazard a guess that it's a static control, one DLU in height.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
That is the method I described in my previous post. Use the dialog editor, and put a box on your dialog (static control).
Drag it to the width you want, and sent the style to sunken.
Move the top to the position you want, then drag the bottom up. Voila - 1 reeeeeally thin box = line / separator.
Iain.
|
|
|
|
|
|
I can tell u how to build that separator. As I'm replying after a long time of u'r post, first respond to this message.
Come online at:-
jubinc@skype
|
|
|
|
|
Are you "the" Don Box who wrote a book on COM?
Yours Truly, The One and Only!
|
|
|
|
|
in the dialog resource editor add a picture control and set it's Type to Ethced Horz
|
|
|
|
|
Hi all,
How would one go about restarting an application ? (i.e. for re-configuration purposes)
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
I can't think of a little api to do it, but it wouldn't be too hard to write a small second program.
A.EXE
fire up B.EXE, and pass B its process handle as a parameter.
B.EXE:
wait for process A to die (for a finite length of time!)
start another A.EXE (perhaps with a "/restarted" flag?)
die!
A.EXE
carry on where you left off.
Iain.
|
|
|
|