DrawText and Formatting in Visual C++

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

DrawText and Formatting in Visual C++

Postposted on Wed Mar 24, 2004 6:34 pm

Hey everyone I've been using DrawText() for just outputting simple text into a CView I'm using in my application.

I'm now at a stopping point. I basically want to display a table of data like this where each value is aligned under its column header.

Sensor IR US
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0
7 0 0
8 0 0

All the IR and US numbers come from an array from index 1 to index 16, and the sensor numbers are hardcoded....

First of all how can I get the text output formatted like that?
a sample single value output now looks like
DrawText(CString(strSensorValues[nIndex]), rcSensor, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOCLIP);

I have other stuff drawing in this View as well so I dont' want to screw that up.. I have included a link to my source code file, and an image file of what the View currently looks like.

I wouldn't think something like text display and formatting would be this hard, but I'm not used to the Windows side of a lot of the programming stuff yet.

The link is http://www.nmt.edu/~dwent/
and the two files are view.jpg and StatusView.cpp

Thanks a lot
OutlawTornNMT
Gerbil First Class
 
Posts: 148
Joined: Sun Jul 21, 2002 5:30 pm

Postposted on Thu Mar 25, 2004 8:59 am

Hmm, there are lots of ways to do this, but programs like this I use VB, because in the time it took to write this reply I would be done. Well, not quite but VB has so many built-in functions for this sort of thing that it makes it very easy.

What would I do? I would make an array of controls that contain the attributes I want, going so far as to make a single custom user control that can be re-used for each of those circles. Then I can move the circles wherever I want and the text and other attrbutes move with it. To update the text would be a simple matter of myObject.text = format$(value, "00), or setup the control so just assigning it a value will update the text to the format for you. Then you can also setup click events so the user can see further information on the sensor and so on.

Since I don't use C++ on the PC anymore, I would recommend doing things in VB unless you are writing drivers in conjunction with the program. C++ == anal for small programs and sensor interfaces. If C++ is all you've got, then I wont be of much help, sorry!

-LS
liquidsquid
Minister of Gerbil Affairs
 
Posts: 2452
Joined: Wed May 29, 2002 10:49 am
Location: New York


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 1 guest