Newbie: Program Design help 
Author Message
 Newbie: Program Design help

This is my first big VC program and I'm running into a lot of trouble
just setting things up, can anyone offer some help or suggestions?

I'm attempting to write a program to display the contents of a data
file. The data file is created from a dos application I wrote, and is
just a structure fwrite()'ed out to a file. The data contains things
such as cpu make and speed, devices on the pci bus, etc. The goal will
be to have the dos program gather data, which can then be viewed by the
windows application in a nice gui.

I picked a form view as my default view class in the app wizard, then
made some edit boxes with static labels identifying them as all the
different pieces of information to be displayed. In Doc::OnOpenDocument
I am trying

CFile file(lpszPathName, CFile::modeRead | CFile::typeBinary);
file.Read(&sysinfo, sizeof(struct sys_data));
file.Close();

One of the big questions I have regards modifying the edit boxes and
DDX. I tried assigning some of of my edit boxes to member variables, and
it made a View::DoDataExchange. What would be the best way to modify the
edit boxes and place all of the data from my structure into them?

Thanks for any tips or suggestions

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 30 Jun 2002 03:00:00 GMT  
 Newbie: Program Design help

Quote:

> This is my first big VC program and I'm running into a lot of trouble
> just setting things up, can anyone offer some help or suggestions?

> I'm attempting to write a program to display the contents of a data
> file. The data file is created from a dos application I wrote, and is
> just a structure fwrite()'ed out to a file. The data contains things
> such as cpu make and speed, devices on the pci bus, etc. The goal will
> be to have the dos program gather data, which can then be viewed by the
> windows application in a nice gui.

> I picked a form view as my default view class in the app wizard, then
> made some edit boxes with static labels identifying them as all the
> different pieces of information to be displayed. In Doc::OnOpenDocument
> I am trying

> CFile file(lpszPathName, CFile::modeRead | CFile::typeBinary);
> file.Read(&sysinfo, sizeof(struct sys_data));
> file.Close();

> One of the big questions I have regards modifying the edit boxes and
> DDX. I tried assigning some of of my edit boxes to member variables, and
> it made a View::DoDataExchange. What would be the best way to modify the
> edit boxes and place all of the data from my structure into them?

> Thanks for any tips or suggestions

> Sent via Deja.com http://www.deja.com/
> Before you buy.

You have three choices.  If you use DDX then you will need a bunch of assignment
statements like m_strEdit1 = GetDocument()->structure.member;
This seems clumsy but for simple put it up/take it down dialogs it is the
preferred answer -- it lets the user change the data in the controls but then
cancel out without changing your original doc variables.

The second choice is to use the wizard to create control variables instead of
string variables.  Then you write code like
 m_Edit1.SetWindowText(GetDocument()->structure.member);
This is preferred for OOP code clarity and/or if you might want the control
variables for other purposes like disabling, resetting, etc.

Finally, you can do it with no member variables at all.  The functions
GetDlgItem(IDC_EDIT1, text) and SetDlgItem read/write the controls using a Win32
mechanism that sends your text to a child control by ID.  It iterates through
the child window hierarchy to find the control and send a message to it.  This
technique is a quick hack that I find suitable for mind-numbing cut-and-paste
coding situations when you want to do the whole job with one line, one place.

--
Scott McPhillips [VC++ MVP]



Sun, 30 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie: Help regarding design approach

2. Help in designing program with command line arguments?

3. Help on designing a C programming course

4. Program Help for Newbie

5. ***Newbie Needs Help With Functions Program ***

6. I need help with a program newbie :)

7. ***Newbie Needs Help With Functions Program ***

8. newbie help with sockets programming...

9. Help for C newbie with simple stat() program.

10. Semi-newbie programmer seeking help with comm program

11. ***COMPLETE PROGRAMMING NEWBIE: PLEASE HELP!!!***

12. c newbie needs help with programs!!

 

 
Powered by phpBB® Forum Software