|
By the time you parse each double individually, I would think you would have been better off reading as double in the first place. (you can do some benchmarking to see) If the number of memory locations varies, you could always use a std::vector to hold the values and provide any necessary interfaces to it.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Hello everyone.
I have a dialog to show the scores of a game, and I put a list box in that dialog. I want to show the names and the scores in a table. I just can't find a reference to tell me anything about how to make columns in a list box.
I tried something else to temporarily solve the problem, but something is going wrong. I wrote the following piece of code:
CString Score, Name, Final;
CRect ScoreRect (0,0,0,0), MyListRect;
CListBox *MyList = static_cast < CListBox* > ( GetDlgItem ( IDC_MYLIST ) );
CDC* dc = MyList->GetDC();
MyScoreFile.ReadString ( Name );
MyScoreFile.ReadString ( Score );
MyList->GetWindowRect ( MyListRect );
while ( ScoreRect.Width() < MyListRect.Width() )
{
Name += " ";
Final.Format ( "%s%s" , Name , Score );
dc->DrawText ( Final , ScoreRect , DT_NOCLIP | DT_CALCRECT );
}
MyList->AddString ( Final );
The problem is that the text does not appear taking the whole width of the list box, but rather a small region, about two thirds of the width of the list box. I also tried to use MyList->GetClientRect ( MyListRect ) with the same results.
Thank you very much.
<marquee>Hosam Aly Mahmoud
|
|
|
|
|
This seems like a very convoluted way to be using a listbox. If you are restricted to using a listbox, a simpler approach would be to turn on the listbox's LBS_USETABSTOPS style. Then populate it with something like:
while (! bDone)
{
MyScoreFile.ReadString ( Name );
MyScoreFile.ReadString ( Score );
Final.Format ( "%s\t%s" , Name , Score );
MyList->AddString ( Final );
}
No doubt you'll need to adjust the "width" of the columns (as 32 DLUs are probably not going to be enough for a name-type column) by calling SetTabStops().
That said, I would use a list control (in report mode) instead.
|
|
|
|
|
Thank you very much for your reply.
DavidCrow wrote:
I would use a list control (in report mode) instead.
I really thank you for this advice. Until the time I posted my question, I did not even know that there is something called a list control that is different from a list box. Meanwhile, I now know it exists. I tried to use it on my own (with the help of MSDN), but I could not get the results I wanted (yet). I would be very thankful if you could tell me of an article that explains the subject in details.
Thanky you again.
<marquee>Hosam Aly Mahmoud
|
|
|
|
|
Hosam Aly Mahmoud wrote:
I tried to use it on my own (with the help of MSDN), but I could not get the results I wanted (yet). I would be very thankful if you could tell me of an article that explains the subject in details.
Examples are bountiful, both on MSDN and the Internet (use Google). What exactly is not working for you?
|
|
|
|
|
Hello
Im using serial communicating (COM3 and COM4) to talk with another server.
I use the exact same settings and the same class (overlapped io with readfile/writefile) to communicate with the server (diffrent protocols).
Everything runs smoothly on COM3, but the overlapped read doesn’t complete for COM4 (as nothing is received).
If I connect to COM4 using hyper terminal everything works (both send and receive).
What can be wrong?
Thanks,
Jonas
|
|
|
|
|
Anyone know of a good logging utility for C++? Something that is thread safe as well.
I have looked at log4cpp but I am not sure how reliable it is.
anyhow, thanks
|
|
|
|
|
A "logging utility" is fairly vague. Can you be more specific?
|
|
|
|
|
Well, to be more thorough, a utility that I could use to log
events and errors in my application to a file.
I could obviously use fstream to output to a log file of my own
but I was hoping for something better, hopefully thread safe and
with various output options (i.e. xml, regular text, etc....)
|
|
|
|
|
Its author seems quite proud of this one. Give it a whirl and see if it meets your need.
|
|
|
|
|
thanks
the good thing about log4cpp was that it would just dump it to a file.
You can then go and read the file whenever you want.I think the file had various formats too(text,xml, etc..)
|
|
|
|
|
Did you overlook the CTraceList::setToDisk() and CTraceList::doSave() functions?
|
|
|
|
|
Use the Event Logging API - that's what it's there for.
See :
- ReportEvent()
- General-System-Event Logging on this site
I used to have a home rolled text file based logging class i used for years, but after switching to the Event Logger i can't see myself going back (except on WinCE where it isn't supported .
...cmk
|
|
|
|
|
hi
thanks
Eventviewer is good, but you don't want to log everything in it. For that kind of intense logging, something like a simple text file might be better.
|
|
|
|
|
I have been looking for something like this for a long time. There are several logging programs on this site and other places that I have tested but they all seem to lack some feature that I need and I just end up giving up on the idea. Let me know if you find anything good.
Thanks,
John
|
|
|
|
|
I have a DLL that communicates with a USB device. There is a function that people can call to make this communication happen (called GetAll). When the function GetAll is called, I create a dialog using DialogBox. It's a standard pop-up dialog with a progress bar to show the current operation.
However, if I unlpug the device I'm communicating with mid-way through, I close the current dialog box (with EndDialog) then open a new one (using DialogBox) to show the error message to the user. When I press OK, the system seems to get lost and never returns to the next line after the 2nd DialogBox call. This also occurs if I call MessageBox in pace of the 2nd DialogBox call.
Any suggestions on what's going on here?
Regards
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
One solution is to make sure the DLL terminates the communication process upon an error. Does the DLL spawn a worker thread?
Kuphryn
|
|
|
|
|
Hi,
can anyone tell me how to, (or show me an article which shows how to), use resizable columns in my apps. I mean columns like those in MS excel, where you can drag them to any size you want.
Thanks....
|
|
|
|
|
If you are using MFC, you'll want to use the CListCtrl (or CListView) class. Otherwise, create a SysHeader32 control on top of a SysListView32 control.
|
|
|
|
|
Hi,
I have something like:
Object* MyClass::MyFunction(int value)
{
Object* pObj = new Object(value);
if(!pObj)
return NULL;
else return pObj;
}
do I have to delete pObj? and if I have to delete it, how can I do it? Do I need to call a delete everytime everywhere?
Thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
You could have written:
CObject* MyClass::MyFunction(int value)
{
return new Object(value);
}
As new returns NULL if the allocation fails.
That said, what you are doing is bad coding practice as whoever calls the function needs to remember to delete the returned pointer, and its possible to use a function in such a way that you don't get a copy of the returned pointer, as it would get assigned to a temporary. So its very bad practice. See if you can do it in some other way.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
The gold rule: if you use new you must delete, if you use malloc you must free...
but the other person who has answered is right, it is a bad coding style, it can lead to lots of errors if the coder is not aware of that...
Hope this helps.
|
|
|
|
|
Hi!
I'm writing an app in VC++ 6 that uses ADO through the #import directive.
There are an unknown number of predefined queries in the database (access)
witch I need to execute and I wonder if there's a way of retrieving the
names of those queries using ADO.
I'm using a Connection Object and a RecordSet Object to obtain the results
of the queries but how can I obtain the queries?
thanks
/Anders
|
|
|
|
|
I believe that these are presented as Views to ODBC, so in an ODBC world, you would use SQLTables(...,"VIEW").
In the ADO world, I think that that translates to the OpenSchema method of the Connection object, passing adSchemaTables as the query type and "VIEW" for the criteria TABLE_TYPE.
<marquee scrollamount="3" scrolldelay="80" direction="right" width="40%" style="border: 2px inset silver;background-color:yellow;color:green;font-family:Verdana,Arial;font-size:8pt;font-style:italic">onwards and upwards...
|
|
|
|
|
Thanx for your reply. I'll try that but how can I tell the difference between a returned table and a returned query? Any Idea?
/regards Anders
|
|
|
|