" " (Microsoft Visual C++ MFC)

oe y AFX API. oe poe oo Visual C++. yooe ee, " ". peo exeoy oeee, .

,
21.06.2011
2,7 M

. ,

, , , , .

http://www.allbest.ru/

e aa a eea

aee aaee eee e

ea aa

ee - aa ae exe ee

EA AA

E

E ex aa

A E: " " (Microsoft Visual C++ MFC)

e II a

ea 230201.65

ae e

ex

. -091

..

a

2011

Aa

e aa a e C++ Micrsft Visual Studio ae e MFC.

e ea aae a, ee a ae ae aea .

e e , , , .

xe ea ae aae . aee ea aa eae a ae eax.

48 , 24 , 1  2 :  1 - ,  2 - .

oepe

    • eee
  • 1. eopeee oo ppo Windows-poe ooe oe MFC
  • 1.1 API y
  • 1.2 oe y AFX. ooe
  • 1.3 oe poe oo Visual C++
  • 1.4 pyeoe peo - ClassWizard (ep o)
  • 1.4.1 oe ooo .
  • 1.4.2 ee ox eoo
  • 1.4.3 ee ox eeo x
  • 1.4.4 poeyp DDX/DDV RFX
  • 1.5 peyeo MFC oe
  • 1.6 ee ype
  • 1.7 Po epo
  • 2. e pop
    • 2.1 Oe ee
    • 2.2 yooe ee
    • 2.3 Oe oeo pyyp
    • 2.4 peo exeoy oeee
    • 2.5 o pop. oe xoe e
    • 2.6 eoe poo
  • ee
  • poee 1. eppx o
  • poee 2. pop

eee

eo e Windows e, eyoo pye oepoo eo pe epox oepo. ooy yex opeeoo pop py o eo ye pp eee ee poe Windows. poe ooo yo pey e oeo pee x o. oee poppo Windows-poe po Microsoft ppo oe MFC (Microsoft Foundation Classes - oe Microsoft), oop epe pee pe 1992 ee oopo Microsoft C/C++ 7.0. e o pee oo o op o C++, oope oo poppo poe Windows 95,98/NT ooo oo ypoe p, ee e op ox popo e oy y oee oo ypo, o ooe ee poe oo oo e ooo oepoo e. MFC e epo e yoo poppo, Delphi Visual Basic, peeo ox popo. eo e oee oo pop ppe p oo Microsoft Visual ++ MFC. MFC - o p poppo o Windows "epo oe". y oe o p. o, oo MFC ooe o oee ee yoe poe, oope yy oppeo e e e oo ee ppo, o ex pex ooee. e oe o, o MFC oepe e opeee exoo, peoe Windows, p ooe Windows o py e ooe MFC [2].

1. eopeee oo ppo Windows-poe ooe oe MFC

oe MFC oep oy eppx o, x ++. ee epe xo CObject, oop oep pe y, oyee o pe oe pop peee, o, peoe op o eye e o pe oe, o, ep.

E ye e oe, poo o CObject, o o ye peyope ex opeee peoo oe oo po RUNTIME_CLASS(). Xo ++ ee ex RTTI, ex, peo MFC, oo oee ee o pooeo. , poo o CObject, oe o poy poep oe ypeee ooe oey op. o eo oye MFC p oe [8].

ep - o ex, oo peopo eyee ooe oe oeoe oo , oop oo e e , oo ooe oe oeoeoo oo, oo p e . o ooe oxp eyee ooe poe e, o eo p oeye ye. eoope opo eopeeo o CObject. oee poo oye pe x CCmdTarget, CFile, CDC, CGDIObject CMenu. CCmdTarget pee opo ooe. CFile pee po . CDC oeee oepy oeo ypo. O oex ypo ye oop eoo oee. o e pe e y p GDI. CGDIObject e o o px DGI-oeo, x ep, , p pye. CMenu pee y e. O CCmdTarget opoe oe CWnd. O e o o ex o oo, pyee ("oe") ooe, e pe ee ype. oee poo oye poo o e CFrameWnd. ye ee, oe pop oe oo oe oo eo oo . O CCmdTarget, epe CWinThread, opoe, epoe, ee oee x o, opee oopoy MFC-popx poxo py: CWinApp. o o yex o, ooy pee o oo poe [9].

1.1 API y

oo y, ex MFC-pope, e ooo o, opeeex oee. oo y API oy epe y-e MFC. e e eee, e oo op y API py. o o e eoxo, o e e oe ye yoee oo y-e MFC [4].

1.2 oe y AFX. ooe

oee e p ox y. e o pe Afx. o MFC oo pp, o poe AFX, Application Framework. oe p yeex ee AFX epepo MFC, o peee e oxpo o ox eopx oe x o. pep, oe o oye y AfxMessageBox(), oop pee opeeeoe oo ooe. o e e-y MessageBox(). opo, o oe y epep y-e.

e MFC-pop ooo AFXWIN.H. e, e px ooex x, oep o o, pyyp, epeex pyx oeo MFC. O oe oe oo ooox o, oox MFC, o e WINDOWS.H, oopo opeee e y Windows API pye oe, oope oy p poo poppo "o" API.

Windows oeye popo, o e ooe [3].

e poe Windows o opo e ooe (oo yp y WinMain()). o e oe eopooe ooee oo eeo oepe ooe oo poe epeo Windows, oop e e y o pop ooee ee pye. pox Windows-popx eoxoo ooeo o po o . p oo MFC o e oe oe. Oo o o, o ooe e e yeye. O e eoeeo oo poe [11].

1.3 oe poe oo Visual C++

O px ypo poe po e. eep pop, oo oe oo Visual C++. pepe oo oe oe - poe. o x op poee ppo, oo ooyo oeo ox poox o. o oeee po poe peye eo oee - py oe o eoxoo oe peypo, x poee, y po e .. ep "poe" p oye, o ee y o o poee.

pee Visual C++ oo po pe poeo. e poe oe x o oo opo y oee. p Microsoft ppo e pyep, oe yop oe poeo pee Visual C++. pep, ep MFC AppWizard (exe) ooe o poe, Windows-poe oopoe ee oooye, oooye oo epe oye oey MFC [5].

1.4 pyeoe peo - ClassWizard (ep o)

oe oo poe oe , o ee poe poeo oo oo pyoe pyeoe peo - ClassWizard (ep o), peeoe o ooo ox poox o. Ee oo oooe ee ClassWizard o, o o oe oo epeopeeex eoo. O ooe o e ooe, pxoe y, o oo opo oo x ooe. o oo e ooe y ClassWizard. O e ee, o eo ooo ooo e.

peo ClassWizard peoe po ep yy. O ooe e oo o yeyey y oe eo e [3].

1.4.1 oe ooo

p oo ClassWizard oo o o , o ooe ox o. ee ooo oo oo , eoe o CCmdTarget CRecordset . eo o o pyx ox o oo pe ClassWizard e. e o o pyy, eopeeo eoo peope [3].

oye oo oo poooo. Ee oo oo o oey yope o eo . y poy oo o pyy, o opo ye poe ooo yy ClassWizard. e oo ClassWizard poeyp o oeoo eo yope yee epoo oep oy o pe oe eoo.

1.4.2 ee ox eoo

Oe yoo oo ClassWizard e o ox eoo. oo o y eo, ye opo ooe Windows o o oeo, e eo, epeopeee pye eo ox o [10].

ClassWizard e oo ooe o oe eo, o y x. ClassWizard ooeo y oee eo .

1.4.3 ee ox eeo x

ClassWizard ooe e oo oe eo, o ee x, e o oox ee, op poop op poop e x oe opo e. ClassWizard oye ee poeyp, o p oe ee x o oox ee. poeyp o "oe ooo e" "poep x ooo e" (Dialog Data Exchange and Dialog Data Validation - DDX/DDV). o p o opo e epee, oye poeyp oe o e (Record Field Exchange - RFX) [1].

1.4.4 poeyp DDX/DDV RFX

eo ypo popy poy oo e. O oo o oox ee epeee. o ooe pepye o oox ee, poeyp DDV poep eee e opy o peex e. e poeyp DDX oe opy oepoe oe oox ee pe ee x . oopo, o poee ee ee x , pe o ooo e, poeyp DDX oy py oop oe e oe pe oep. poe oye opo ooe oe o epeyp o, o, e e eee, ey o eo e Windows-pop. , p oo oe MFC oo x ee p o pop, xo poo eo pyo pope. poee ye pop, oo MFC, oep , opoee o o eppx oe: , pee o poe, , pee o o. py o, o o pop eoxoo opo o o CWinApp, pyo - o CFrameWnd. oe o pop.

poe o eyoyx o, pope e o opo opo ex ooe, oyx o Windows. o pepe pop ee eo oeoo e ee, ooy oe oe ooee e yo. MFC opoe e ooe, oope e epey. e e eee, o pepe pyye p oo ooe, poo p ooe. oe pop ee opoee. ye yoo, MFC - o o op (oe) o, x e ++ peex ypoe yope poe poppo Windows. oe oep ooypoey eppx o, y ooo 200 eo. O ooo o Windows-poe e oeo-opepooo oxo. o pe pop, MFC pee oo p, ooe oopoo oo pop Windows.

1.5 peyeo MFC oe

oe MFC pp ypoe , ox epe popo. eo, po eo poppo o Windows peye ooo x ox pop, ex p eex ooeoe. o, o oo p pop eoo oo ooo 75 po o. o epe e yee oo pop ee o oe o oe eepox pepo. Oo e pop, ooe MFC, ye pepo p p ee, ooy oo x ee po o pop [8].

O oox peye po MFC e ooo oopoo oo ooo oo e o. oe oep oo eeo, ox ex Windows-poe, e eoxoo p x oo. eo oo x oo poo eo (oop o oeo-opepooo poppo). poe oo, epe, oeee oeo, pe e o opex ee, eo peyx. ooy pop, e ooe MFC, oy eo po o ep Windows ( oe o o pop, x o eo).

Ee o yee peyeo MFC e ypoee oe p pop epeo (API) Windows. oe poee oeye Windows epe API, oopoe oep eoo o y. ye pep API pye o o y eo eo. y, e oo poe, oee API py pyo! o ooy oe MFC oee (ye y) y API oe opooe oeo o, epeo o eo ee yp. ooy MFC pee oo op o, x e ++, ooy pop, e ooe MFC, o o e pe pop ++. oo eoxoo e ooey . eoxoo ye o oee , o p eo ye epeopee pye y. Xo pop, oye oey MFC, oo e oep o eex eeo pe ++, x e e eee pey oe o o.

1.6 ee ype

opee (Picture) - o py eeo ype, peex pee peo op px poe. oo o py eeo ooy e oo : opy (Icon), ppo pyo (Bitmap), e Windows (Enhanced Metafile), poyoy py - p (Frame), oe poyo (Rectangle).

Pop opo pee ope ooo e, opeeeo , o pyo pee oo ppo my.bmp:

opye pyo o poe RES;

opoe y Resource View oe Workspace, oe oeoe e Lab1 Resources oe oy Import.

ope oe e ee my.bmp, e e oy Import; pe peypo Resource View o o Bitmap, pyo ye oe poe o ee IDB_BITMAP1;

oee ooo e ee ype Picture;

poe o ee ype - e General oe Type ye ope - Bitmap, oe Image epe peyp - IDB_BITMAP1. eop ee ype ID - IDC_STATIC - oo o e ee.

Peee py ooo e oeo [4].

Poo o-epee (Radio Button) - ee, pee o op; oo oye pye eeo (pooo) op ooo eox x py py po. oeoeo o py pooo ey.

oee ooy e ee Group Box. ee ee Group Box oee poo, pep, p poo, oop yy poe eop IDC_RADIO1, IDC_RADIO2, IDC_RADIO3 ooeeo.

Yoe ox pooo o o oe (caption). epo poo IDC_RADIO1 yoe o Group (py).

e poo yy e opo oep 0, 1, 2 . . ee py pooo epeey, oop ye xp oep po poo. oe epeey m_Radio1, po e eop value e - int.

pye pyy pooo, . e. e oep po o - y OnInitDialog() oooo o oe e //TODO: Add extra initialization here (oe ooey e) o o:

m_Radio1=0; //Ye epy pooy

UpdateData(FALSE); // epepoe p

E o y UpdateData(FALSE) y OnInitDialog() ye e, oop o e ye.

e o oe BN_CLICKED o poo, o poo o o y, oy p ope o o.

eep o pooo ye o oo oe pop; op eye poo pee oe ooeye y opo o [7].

o (Check Box) - pee o op; oe e (, o) p (, o, e opeeeo) oo. peoe ooe ooo oeoo op. Xp ee BOOL (int).

oeoeo po eeo Check Box ey:

yoe ee ooo e poe eo o, oy, eey ooeye eop IDC_CHECK1;

yoe epeey, y eeo - e e m_Check1, poe e eop - value, epeeo - BOOL;

pye ee IDC_CHECK1 - poe o epeeo oe ee TRUE FALSE, oo opepye eo OnInitDialog() ooo e, o oe e // TODO: Add extra initialization here (oe ooey e) o: m_Check1=TRUE;

e e, o oope yoeoo e ee Check Box pe o y UpdateData(FALSE).

1.7 Po epo

o ee ep? oe yo ep e "". o oe, o pop oye epe opee poeyo pee ooee WM_TIMER. opoe oo ooe oo o o. o, o o opo ye o epe opeee poey pee.

o ep o:

pee eo eo o. oo opyop oe ey o:

CMyMainWnd(){

Create(NULL,"My title");

SetTimer(1, 1000, NULL);

}

y SetTimer ee eoo pepo. ep (y o pe 1) - o eop ep. opo (1000 e ye) - o epe oo ey ep e. 1000 oe o p eyy, 500 - o p eyy. pe pep NULL. o oe, o ye op ooee WM_TIMER eo ep y OnTimer eo oooo . o pe pe pep - o pe y-opo.

ep o, eep o opo - oo yo e p e - o ooey eo , eo pe o ooey po py ooe [11].

oe eo :

...

afx_msg void OnPaint();

afx_msg void OnTimer(UINT);

DECLARE_MESSAGE_MAP()

e pe oo eo:

void CMyMainWnd::OnTimer(UINT){

MessageBeep(-1);}

e eoo MessageBeep(-1); oop, o oe p y.

oe po:

...

ON_WM_PAINT()

ON_WM_TIMER()

END_MESSAGE_MAP()

y eyy oe y beep. o, eop o, o pop poe, o e oe pop ep y. oo o o epyop:

~CMyMainWnd(){

KillTimer(1); }

eo KillTimer o pep - o eop ep. y 1 (.. ep ee eo o eop).

2. e pop

2.1 Oe ee

microsoft visual

pop Drob.exe, ppo xoe oo ypooo poe, pee oo poee, oopoe epye ooe o pey e ee po. e e oee, e, yoee eee poe, opee ooex poe ee. pop ooe opoo o pey oeo ypoe pe poex.

pop ppo oepox e ee Windows pee Microsoft Visual C++ 6.0 ooe oe MFC.

2.2 yooe ee

pop pee poep oo yeo ey ee po eoo epo, e peoe oee, e, yoee eee poe, opee ooex poe ee, ee peyope eoo o opoo ( opo ooo, eox po oe, oo p oe).

oe aya oa ao oa (yo 2.1).

Pyo 2.1 - oe oo

o xo oeea xo oa.

o aa e o oo, aoee x oae, oe eyao.

eee oa ooo oa aao oea oye ee (y 2.2).

yo 2.2 - oo oo aaa oea

a ooa ey o ooae oa ooo oea aay (yo 2.3). o yae eea ooaee oa oee a ooee aaee eoy oey.

yo 2.3 - oo oo oea aay

ee yy oo, ey oa eox aao oea (yo 2.4).

yo 2.4 - oo oo eox aao oea

oe oe a e oo o oo eyao, oeaee oey a ooae oeo oooe.

Pyo 2.5 - Oo pey

2.3 Oe oeo pyyp

o pope o e o:

1. CAboutDlg - o o p o pope.

2. CDrobApp - oo poe eo.

3. CDrobDlg - oo o, oo oe oe y pop.

oo xo eo OnCancel(), oee xo pop.

oo e eo ooo OnOK(). Ooe y pop oep o eoe. e oo y DoModal() oeeeo oee oo opo o opy. e opoo p oeo po oe y.

4. CQuestion_1 - o e, oo oe oe oy e o oe. e opo eye eo: OnRadio1(), OnRadio2(), OnRadio3(), pepye e opeeo poo pe, e y OnInitDialog(), y ep OnTimer(UINT nIDEvent), o poy o peee poxoe e.

e CDrobDlg oo oe q1 CQuestion_1 y DoModal() opoo oee eyx 11 oo opo.

5. CQuestion_2 - o e. e e peo y po epo, eo ooeo RadioButton oo ooe CheckBox.

6. CQuestion_3 - o e. e e peo y po epo

7. Result_ - epeo oo oo pey e poex, oe oe oe oe opo.

2.1 - e ppox o

py

oo oy

ee

CDrobDlg

void OnOK()

protected

y epo

CQuestion_1

int SecondRemain

public

oe ey o oo epo

int vibranii_variant

public

p, p ooee

CQuestion_1

CString m_option1

CString m_option2

CString m_option3

public

oopee p oe

CString m_quest

public

e opo

CQuestion_1

CString m_TimeRemain

public

oee pe

CQuestion_1

void OnRadio1()

void OnRadio2()

void OnRadio2()

protected

op ooo po oe

CQuestion_1

BOOL OnInitDialog()

protected

pye ep

CQuestion_1

OnTimer(UINT nIDEvent)

protected

ooe oee pe

CQuestion_1

void OnOK()

protected

epexo . opoy

CQuestion_2

int SecondRemain

public

oe ey o oo epo

CQuestion_2

BOOL m_Check5

BOOL m_Check4

BOOL m_Check3

BOOL m_Check2

BOOL m_Check1

public

p oe

CQuestion_2

CString m_option1

CString m_option2

CString m_option3

CString m_option4

CString m_option5

public

oopee p oe

CQuestion_2

CString m_TimeRemain

public

oee pe

CQuestion_2

CString m_quest

public

e opo

CQuestion_2

BOOL OnInitDialog()

protected

pye ep

CQuestion_2

OnTimer(UINT nIDEvent)

protected

ooe oee pe

CQuestion_3

int SecondRemain

public

oe ey o oo epo

CQuestion_3

CString m_TimeRemain

public

oee pe

CQuestion_3

CString m_quest

public

e opo

CQuestion_3

CString m_answer

public

oe, ee ooee

CQuestion_3

BOOL OnInitDialog()

protected

pye ep

CQuestion_3

OnTimer(UINT nIDEvent)

protected

ooe oee pe

CResult_

CString m_res

public

pey

2.4 peo exeoy oeee

e peo oepy, oyoee yeo poo ooe, oep o ypee Windows 95/98/Me/NT/2000/XP/Vista/W7: poeop o Intel 80486, oep o 16 , ooo 2,3 eo e, eo oop c ppeee o 800x600, .

2.5 o pop. oe xoe e

yo pop y y eoxoo opo popy. y eoxoo o Drob.exe. oe oo p ee oe oo poe.

xo e eee ooee oe. xo e pey e o poex.

2.6 eoe poo

pop e Drob. pope ppo e o x eo. pope peyope p opoo: 1- - peyope p p oe ooe pee p o, 2-o pee ooe p eoo po oe, 3- pee ooe e oe yp eoe oe o. poxoee e ooe oo y. Oee pe ooo oope ope opoo. E ooe e yo oeeoe pe, o pop oe poe.

oe y pop pe oe oe oo ( 2.2.1) oopo oep p op o ee eoo oo: xo e.

Pyo 2.2.1 - oe oo

oe o e oe epoe oo epo ( 2.2.2) oopoe oep opypoy , p p oe oee pe epo.

Pyo 2.2.2 - Oo epo

oe op p oe yo oy ey opo, e e p o po o peypeee ooee ( 2.2.3). op peyey opoy e.

Pyo 2.2.3 - peypeee oo

Pyo 2.2.2 - Oo epo

Pyo 2.2.2 - Oo epo

Pyo 2.2.2 - Oo epo

e opo oep opypoy , po oeo pe oopx yo p eoo px oeo oee pe epo ( 2.2.4).

Pyo 2.2.4 - Oo epo

Pyo 2.2.4 - Oo epo

Pyo 2.2.4 - Oo epo

eoe e opo, oep opypoy , oe o oe oee pe epo ( 2.2.5).

oe oo pee e pe oo (e o pey).

Pyo 2.2.5 - Oo epo

Pyo 2.2.5 - Oo epo

Pyo 2.2.5 - Oo epo

ee opoo, oe oe oe opo oe oo Peyo ( 2.2.6). Pey o poex. e o oe e o ee e.

Pyo 2.2.6 - Oo pey

Pyo 2.2.6 - Oo pey

Pyo 2.2.6 - Oo pey

Pyo 2.2.6 - Oo pey

ee

xoe oe ypooo poe o oo Windows-poee, oopoe epye ooe e y eo ooeyy ey. pop Microsoft Visual C++ 6.0 ooe oe MFC.

xoe ppo ypooo poe ooe po Microsoft Visual C++. peye eo pop. ooe po po o, eo o, oo oe ooex peypo ooe pyoe.

e poe ey ooe, oy poo ep px epx eoeeo eeo. oo ooe pop e poppo Microsoft Visual C++ ooe oe MFC o pyx poe.

o oyeo epyp

1. Oo poppo Visual C++,eoee y o ypy exoo poppo.

2. e peop ooe Visual C++ 6.0,, ,.: e o ,2000

3. . epoo Visual C++ MFC,yp MCSD poeoo,.: ep ,2000

4. . , Y.ppe ooe pyooo o Visual C++, .:OOO oypp,1999

5. . y Visual C++6, .: opop ox ,1999

6. . ep ,, p poppoe Visual C++. poeoo,.:o,1998

7. . . eo Visual ++ 6.0 (VISUAL STUDIO 98 ) .Ypo poppo,.:o -,1999

8. . . poo, . . poo Microsoft Visual C++ MFC. poppo Windows 95 Windows NT 2-x .(1) (oe eoo pop;.24) .: o ,1997

9. . . poo, . . poo Microsoft Visual C++ MFC. poppoe Windows 95 Windows NT ( 2) (oe eoo pop; . 28) .: o - , 1997

10. X. . po, . . opo eoee peoe o oope ox ypox poeo (po), poo: -o e- Y, 2000

11. O..eeo Visual C++ .NET, poppo, o: y 2002.

poee 1. eppx o

poee 2. pop

// DrobDlg.cpp : implementation file

//

#include "stdafx.h"

#include "Drob.h"

#include "DrobDlg.h"

#include "Question_1.h"

#include "Question_2.h"

#include "Question_3.h"

#include "Result_.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog

{

public:

CAboutDlg();

// Dialog Data

//{{AFX_DATA(CAboutDlg)

enum { IDD = IDD_ABOUTBOX };

//}}AFX_DATA

// ClassWizard generated virtual function overrides

//{{AFX_VIRTUAL(CAboutDlg)

protected:

virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

//}}AFX_VIRTUAL

// Implementation

protected:

//{{AFX_MSG(CAboutDlg)

//}}AFX_MSG

DECLARE_MESSAGE_MAP()

};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)

{ //{{AFX_DATA_INIT(CAboutDlg)

//}}AFX_DATA_INIT

}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)

{ CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CAboutDlg)

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)

//{{AFX_MSG_MAP(CAboutDlg)

// No message handlers

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CDrobDlg dialog

CDrobDlg::CDrobDlg(CWnd* pParent /*=NULL*/)

: CDialog(CDrobDlg::IDD, pParent)

{ //{{AFX_DATA_INIT(CDrobDlg)

// NOTE: the ClassWizard will add member initialization here

//}}AFX_DATA_INIT

// Note that LoadIcon does not require a subsequent DestroyIcon in Win32

m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

}

void CDrobDlg::DoDataExchange(CDataExchange* pDX)

{ CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CDrobDlg)

// NOTE: the ClassWizard will add DDX and DDV calls here

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CDrobDlg, CDialog)

//{{AFX_MSG_MAP(CDrobDlg)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CDrobDlg message handlers

BOOL CDrobDlg::OnInitDialog()

{ CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.

ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);

if (pSysMenu != NULL)

{ CString strAboutMenu;

strAboutMenu.LoadString(IDS_ABOUTBOX);

if (!strAboutMenu.IsEmpty())

{ pSysMenu->AppendMenu(MF_SEPARATOR);

pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);

}

}

// Set the icon for this dialog. The framework does this automatically

// when the application's main window is not a dialog

SetIcon(m_hIcon, TRUE); // Set big icon

SetIcon(m_hIcon, FALSE); // Set small icon

return TRUE; // return TRUE unless you set the focus to a control

}

void CDrobDlg::OnSysCommand(UINT nID, LPARAM lParam)

{ if ((nID & 0xFFF0) == IDM_ABOUTBOX)

{ CAboutDlg dlgAbout;

dlgAbout.DoModal();

}

else

{ CDialog::OnSysCommand(nID, lParam);

}

}

// If you add a minimize button to your dialog, you will need the code below

// to draw the icon. For MFC applications using the document/view model,

// this is automatically done for you by the framework.

void CDrobDlg::OnPaint()

{ if (IsIconic())

{ CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle

int cxIcon = GetSystemMetrics(SM_CXICON);

int cyIcon = GetSystemMetrics(SM_CYICON);

CRect rect;

GetClientRect(&rect);

int x = (rect.Width() - cxIcon + 1) / 2;

int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon

dc.DrawIcon(x, y, m_hIcon);

}

else

{

CDialog::OnPaint();

}

}

// The system calls this to obtain the cursor to display while the user drags

// the minimized window.

HCURSOR CDrobDlg::OnQueryDragIcon()

{ return (HCURSOR) m_hIcon;

}

void CDrobDlg::OnOK()

{ CQuestion_1 q1;

CResult_ rs;

double grade = 0.0;

// 1 //

q1.ans=0;

q1.m_option1="0,25";

q1.m_option2="1";

q1.m_option3="2";

q1.m_quest="e ee e: 0,5 + 0,5 ";

q1.SecondRemain = 1200;

UpdateData(false);

q1.DoModal();

if (q1.ans == 2) grade=grade+5;

// 2 //

q1.ans=0;

q1.m_option1="15";

q1.m_option2="10,5";

q1.m_option3="15,5";

q1.m_quest="e ee e: 1,5 x 10";

UpdateData(false);

q1.DoModal();

if (q1.ans == 1) grade=grade+5;

// 3 //

q1.ans=0;

q1.m_option1="50,31";

q1.m_option2="48,31";

q1.m_option3="58,13";

q1.m_quest="e ee e: 78,61 - 28,3";

UpdateData(false);

q1.DoModal();

if (q1.ans == 1) grade=grade+5;

// 4 //

q1.ans=0;

q1.m_option1="3,2";

q1.m_option2="2,3";

q1.m_option3="2,6";

q1.m_quest=" ey ey: 13/5";

UpdateData(false);

q1.DoModal();

if (q1.ans == 3) grade=grade+5;

// 5 //

q1.ans=0;

q1.m_option1="3,1";

q1.m_option2="2,5";

q1.m_option3="7,001";

q1.m_quest="e ee e: 15,5 / 5";

UpdateData(false);

q1.DoModal();

if (q1.ans == 1) grade=grade+5;

// 6 //

q1.ans=0;

q1.m_option1="7,52";

q1.m_option2="2,57";

q1.m_option3="7,5";

q1.m_quest="e ee e: 3,12 + 4,4";

UpdateData(false);

q1.DoModal();

if (q1.ans == 1) grade=grade+5;

// 7 //

q1.ans=0;

q1.m_option1="5,4";

q1.m_option2="5,06";

q1.m_option3="9,12";

q1.m_quest="e ee e: 50,6 / 10";

UpdateData(false);

q1.DoModal();

if (q1.ans == 2) grade=grade+5;

// 8 //

q1.ans=0;

q1.m_option1="3,44";

q1.m_option2="3,3";

q1.m_option3="3,2";

q1.m_quest="e ee e: 6,4 / 2";

UpdateData(false);

q1.DoModal();

if (q1.ans == 3) grade=grade+5;

// 9 //

q1.ans=0;

q1.m_option1="5,44";

q1.m_option2="4,25";

q1.m_option3="5,24";

q1.m_quest=" ey ey: 68/16";

UpdateData(false);

q1.DoModal();

if (q1.ans == 2) grade=grade+5;

// 10 //

q1.ans=0;

q1.m_option1="90,1";

q1.m_option2="6,25";

q1.m_option3="1,03";

q1.m_quest="e ee e: 2,5 x 2,5";

UpdateData(false);

q1.DoModal();

if (q1.ans == 2) grade=grade+5;

// 11 //

q1.ans=0;

q1.m_option1="2";

q1.m_option2="7";

q1.m_option3="4";

q1.m_quest=" ey ey: 512/128";

UpdateData(false);

q1.DoModal();

if (q1.ans == 3) grade=grade+5;

// 12 //

CQuestion_2 q2;

q2.m_option1="10,4-3,25";

q2.m_option2="7-5";

q2.m_option3="3,3+3,85";

q2.m_option4="7,05+0,2";

q2.m_option5="2,9*2,5";

q2.m_quest="ee e e. 7,15 y: ";

q2.SecondRemain = q1.SecondRemain;

UpdateData(false);

q2.DoModal();

if (q2.m_Check_1==true

&& q2.m_Check_2==false

&& q2.m_Check_3==true

&& q2.m_Check_4==false

&& q2.m_Check_5==false

) grade=grade+10;

// 13 //

q2.m_option1="12,4*10";

q2.m_option2="75,5+15,67";

q2.m_option3="5-854";

q2.m_option4="715/14";

q2.m_option5="60,64+63,36";

q2.m_quest="ee e e. 124 y: ";

q2.SecondRemain = q1.SecondRemain;

q2.m_Check_1=false;

q2.m_Check_2=false;

q2.m_Check_3=false;

q2.m_Check_4=false;

q2.m_Check_5=false;

UpdateData(false);

q2.DoModal();

if (q2.m_Check1==true

&& q2.m_Check2==false

&& q2.m_Check3==false

&& q2.m_Check4==false

&& q2.m_Check5==true

) grade=grade+10;

// 14 //

CQuestion_3 q3;

q3.m_quest = "e 28,4 e 4 ";

q3.SecondRemain = q2.SecondRemain;

q3.m_answer = "";

UpdateData(false);

q3.DoModal();

if (q3.m_answer == "7,1")

grade=grade+15;

// 15 //

q3.m_quest = " ey ey 118/16 ";

q3.m_answer = "";

UpdateData(false);

q3.DoModal();

if (q3.m_answer == "7,375")

grade=grade+20;

rs.m_res.Format("%.f", grade);

int result = rs.DoModal();

if (result == IDCANCEL)

CDialog::OnOK();

}

// Question_1.cpp : implementation file

//

#include "stdafx.h"

#include "Drob.h"

#include "Question_1.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CQuestion_1 dialog

CQuestion_1::CQuestion_1(CWnd* pParent /*=NULL*/)

: CDialog(CQuestion_1::IDD, pParent)

{ //{{AFX_DATA_INIT(CQuestion_1)

m_option1 = _T("");

m_option2 = _T("");

m_option3 = _T("");

m_quest = _T("");

m_TimeRemain = _T("");

//}}AFX_DATA_INIT

}

void CQuestion_1::DoDataExchange(CDataExchange* pDX)

{ CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CQuestion_1)

DDX_Text(pDX, IDC_OPTION1, m_option1);

DDX_Text(pDX, IDC_OPTION2, m_option2);

DDX_Text(pDX, IDC_OPTION3, m_option3);

DDX_Text(pDX, IDC_QUESTION, m_quest);

DDX_Text(pDX, IDC_TIME_REMAIN, m_TimeRemain);

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CQuestion_1, CDialog)

//{{AFX_MSG_MAP(CQuestion_1)

ON_BN_CLICKED(IDC_RADIO1, OnRadio1)

ON_BN_CLICKED(IDC_RADIO2, OnRadio2)

ON_BN_CLICKED(IDC_RADIO3, OnRadio3)

ON_WM_TIMER()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CQuestion_1 message handlers

void CQuestion_1::OnRadio1()

{ vibranii_variant=1;

}

void CQuestion_1::OnRadio2()

{ vibranii_variant=2;

}

void CQuestion_1::OnRadio3()

{ // TODO: Add your control notification handler code here

vibranii_variant=3;

}

void CQuestion_1::OnTimer(UINT nIDEvent)

{ SecondRemain--;

if (SecondRemain==0)

exit(1);

/////////oy y

int Min=0;

int Sec = 0;

Min=SecondRemain/60;

Sec = SecondRemain%60;

//////////////////////////

CString t;

t.Format ("Oo %d y %d ey",Min,Sec);

m_TimeRemain = t;

UpdateData(false);

CDialog::OnTimer(nIDEvent);

}

BOOL CQuestion_1::OnInitDialog()

{ CDialog::OnInitDialog();

SetTimer(1,1000,NULL);

return TRUE; // return TRUE unless you set the focus to a control

// EXCEPTION: OCX Property Pages should return FALSE

}

void CQuestion_1::OnOK()

{ // OTDO: Add extra validation here

if (vibranii_variant==0)

AfxMessageBox("epe oe");

else

CDialog::OnOK();

}// Question_2.cpp : implementation file

//

#include "stdafx.h"

#include "Drob.h"

#include "Question_2.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CQuestion_2 dialog

CQuestion_2::CQuestion_2(CWnd* pParent /*=NULL*/)

: CDialog(CQuestion_2::IDD, pParent)

{ //{{AFX_DATA_INIT(CQuestion_2)

m_TimeRemain = _T("");

m_quest = _T("");

m_option1 = _T("");

m_option2 = _T("");

m_option3 = _T("");

m_option4 = _T("");

m_option5 = _T("");

m_Check_1 = FALSE;

m_Check_2 = FALSE;

m_Check_3 = FALSE;

m_Check_4 = FALSE;

m_Check_5 = FALSE;

//}}AFX_DATA_INIT

}

void CQuestion_2::DoDataExchange(CDataExchange* pDX)

{ CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CQuestion_2)

DDX_Text(pDX, IDC_TIME_REMAIN, m_TimeRemain);

DDX_Text(pDX, IDC_QUESTION, m_quest);

DDX_Text(pDX, IDC_STATIC1, m_option1);

DDX_Text(pDX, IDC_STATIC2, m_option2);

DDX_Text(pDX, IDC_STATIC3, m_option3);

DDX_Text(pDX, IDC_STATIC4, m_option4);

DDX_Text(pDX, IDC_STATIC5, m_option5);

DDX_Check(pDX, IDC_CHECK1, m_Check_1);

DDX_Check(pDX, IDC_CHECK2, m_Check_2);

DDX_Check(pDX, IDC_CHECK3, m_Check_3);

DDX_Check(pDX, IDC_CHECK4, m_Check_4);

DDX_Check(pDX, IDC_CHECK5, m_Check_5);

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CQuestion_2, CDialog)

//{{AFX_MSG_MAP(CQuestion_2)

ON_WM_TIMER()

ON_BN_CLICKED(IDC_CHECK1, OnCheck1)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CQuestion_2 message handlers

void CQuestion_2::OnTimer(UINT nIDEvent)

{ UpdateData(true);

SecondRemain--;

if (SecondRemain==0)

exit(1);

/////////oy y

int Min=0;

int Sec = 0;

Min=SecondRemain/60;

Sec = SecondRemain%60;

//////////////////////////

CString t;

t.Format ("Oo %d y %d ey",Min,Sec);

m_TimeRemain = t;

UpdateData(false);

CDialog::OnTimer(nIDEvent);

}

BOOL CQuestion_2::OnInitDialog()

{ CDialog::OnInitDialog();

// TODO: Add extra initialization here

m_Check1 = false;

m_Check2 = false;

m_Check3 = false;

m_Check4 = false;

m_Check5 = false;

SetTimer(1,1000,NULL);

return TRUE; // return TRUE unless you set the focus to a control

// EXCEPTION: OCX Property Pages should return FALSE

}

void CQuestion_2::OnOK()

{ // TODO: Add extra validation here

UpdateData(true);

if (m_Check_1 ==false

&& m_Check_2==false

&& m_Check_3==false

&& m_Check_4==false

&& m_Check_5==false)

AfxMessageBox("epe oe");

else

CDialog::OnOK(); }

void CQuestion_2::OnCheck1()

{ // TODO: Add your control notification handler code here

m_Check1=true; }

// Question_3.cpp : implementation file

//

#include "stdafx.h"

#include "Drob.h"

#include "Question_3.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CQuestion_3 dialog

CQuestion_3::CQuestion_3(CWnd* pParent /*=NULL*/)

: CDialog(CQuestion_3::IDD, pParent)

{ //{{AFX_DATA_INIT(CQuestion_3)

m_TimeRemain = _T("");

m_quest = _T("");

m_answer = _T("");

//}}AFX_DATA_INIT

}

void CQuestion_3::DoDataExchange(CDataExchange* pDX)

{ CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CQuestion_3)

DDX_Text(pDX, IDC_TIME_REMAIN, m_TimeRemain);

DDX_Text(pDX, IDC_QUESTION, m_quest);

DDX_Text(pDX, IDC_EDIT1, m_answer);

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CQuestion_3, CDialog)

//{{AFX_MSG_MAP(CQuestion_3)

ON_WM_TIMER()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CQuestion_3 message handlers

void CQuestion_3::OnTimer(UINT nIDEvent)

{ SecondRemain--;

if (SecondRemain==0)

exit(1);

/////////oy y

int Min=0;

int Sec = 0;

Min=SecondRemain/60;

Sec = SecondRemain%60;

//////////////////////////

CString t;

t.Format ("Oo %d y %d ey",Min,Sec);

UpdateData(true);

m_TimeRemain = t;

UpdateData(false);

CDialog::OnTimer(nIDEvent);

}

BOOL CQuestion_3::OnInitDialog()

{

CDialog::OnInitDialog();

SetTimer(1,1000,NULL);

return TRUE; // return TRUE unless you set the focus to a control

// EXCEPTION: OCX Property Pages should return FALSE

}

void CQuestion_3::OnOK()

{

// TODO: Add extra validation here

CDialog::OnOK();

}

// Result_.cpp : implementation file

//

#include "stdafx.h"

#include "Drob.h"

#include "Result_.h"

#include "Question_1.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CResult_ dialog

CResult_::CResult_(CWnd* pParent /*=NULL*/)

: CDialog(CResult_::IDD, pParent)

{ //{{AFX_DATA_INIT(CResult_)

m_res = _T("");

//}}AFX_DATA_INIT }

void CResult_::DoDataExchange(CDataExchange* pDX)

{ CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CResult_)

DDX_Text(pDX, IDC_RESULT, m_res);

//}}AFX_DATA_MAP }

BEGIN_MESSAGE_MAP(CResult_, CDialog)

//{{AFX_MSG_MAP(CResult_)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CResult_ message handlers

void CResult_::OnOK()

{ CDialog::OnOK(); }

Allbest.ru


, , ..
PPT, PPTX PDF- .
.