![]() |
|
#1
|
|||
|
|||
How to use C code in MFC?Hi,
I just started learning MFC. I want to make a graphical interface for my program instead of using command window. My program was coded in C. So how can I pass the input values from dialog box to my C program and how can I show the calculation results on dialog box? Thanks, Yuping |
|||
|
#2
|
|||
|
|||
Re: How to use C code in MFC?hello there! xD
Here is a little tutorial to learn the basic of mfc, create a proyect and draw a line declaring the two points of the line in the Doc... creating a Single MFC document: 1-open the visual studio 2008 2-click file->New->Project 3- at "project types" click MFC at "Templates" click MFC Application 4-Put a name and click Ok, put "example" 5- In the Welcome of the MFC Application Wizard: click next 6- In the Application Type of the MFC Application Wizard: click in the ratio button "Single document" 7- Click Finish. Well your project in MFC had been created, now where In the leftSide must be the "Solution Explorer" (if not, well click view->Solution Explorer) with your project and 3 folders (headers files, resources files and Source Files) well in the Solution Explorer are two importants headers and sources named exampleView.h exampleView.cpp and the exampleDoc.h exampleDoc.cpp In the exampleDoc.cpp is where u will put your code referent to datas, and calculation. In the exampleView.cpp u will put all referent to the drawwing of your application. If want to deploy 2d figures, well in the doc u must have a arrary of figures, and in the view u acced to the Doc and draw the figures How to draw a line, where that two points are in the exampleDoc.cpp: 1- add four int x0,y0,x1,y1 in the Attributes of the exampleDoc.h 2-in the constructor method CexampleDoc() in the exampleDoc.cpp, add x0 =0; y0=0; x1 = 100; y1 = 100; 3-In the method OnDraw of the exampleView at final of the method, where it says "//add draw code..." impotant: uncoment the CDC* param of the OnDraw(CDC* /*pDC*/) pDC->MoveTo(pDoc->x0, pDoc->y0); pDC->LineTo(pDoc->x1, pDoc->y1); compile, run, it will appear a line from point 0,0 to 100,100 see that to access to attributes in the exampleDoc u must use the pDoc variable... i hope it could help |
|
#3
|
|||
|
|||
Re: How to use C code in MFC?open a document using the openfolder icon button of the window:
in the class View ( View -> ClassView ), rightClick on the CexampleDoc and click properties, click in Events, ( the Lightning icon ) in the Menu Commands click in ID_FILE_OPEN, and add it! now u will have the method OnFileOpen( ) in this method u must add: CPP / C++ / C Code:
|
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trouble integrating console code into GUI | Barman007 | Java Forum | 18 | 15-May-2008 13:05 |
| How to sort random access file? | wmmccoy0910 | C Programming Language | 12 | 04-Sep-2006 03:40 |
| Here it is again! 35% - 40% off For Life! | my-e-space | Web Hosting Advertisements & Offers | 0 | 20-Apr-2006 14:48 |
| Guidelines for posting requests for help - UPDATED! | WaltP | C Programming Language | 0 | 21-Apr-2005 02:44 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The