.


:




:

































 

 

 

 





:

.

.

CALLBACK, . , DlgProc. , . :

LRESULT, - BOOL;

- , DefWindowProc. - , FALSE. , TRUE.

WM_CREATE. WM_INITDIALOG.

WM_PAINT, .

, , WM_INITDIALOG. TRUE, Windows , WS_TABSTOP. SetFocus, FALSE.

HWND SetFocus(

HWND hWnd // , , // GetDlgItem ( ));

 

WM_INITDIALOG , .

, WM_COMMAND. , wParam , wParam , lParam .

WM_COMMAND

 

BOOL EndDialog(

HWND hDlg, // INT_PTR nResult // (TRUE FALSE));

, ( )

 

 

INT_PTR DialogBox(

HINSTANCE hInstance, // LPCTSTR lpTemplate, // , // MAKEINTRESOURCE LPCTSTR HWND hWndParent, // DLGPROC lpDialogFunc // );

, , 0.

 

, . , .

 

UINT GetDlgItemText(

HWND hDlg, // int nIDDlgItem, // , LPTSTR lpString, // , int nMaxCount // , lpString);

 

BOOL SetDlgItemText(

HWND hDlg, // int nIDDlgItem, // , LPCTSTR lpString // , );

UINT GetDlgItemInt(

HWND hDlg, // int nIDDlgItem, // , BOOL * lpTranslated, // BOOL bSigned // TRUE, // int. );

 

BOOL SetDlgItemInt(

HWND hDlg, // int nIDDlgItem, // , UINT uValue, // , BOOL bSigned // TRUE, . // );

 

 

1. Win32 Project _ 2.

_ 2. WM_COMMAND, wParam, IDM_ABOUT, About

DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);

DialogBox ( " ") About.

. . , Resource.h _ 2.rc.

  1. .

About. , Dialog IDD_ABOUTBOX, . . , . .

- , .

. . .

, 64 90 , logoMTUSI.bmp, , . . , Bitmap, , logoMTUSI.bmp. IDB_LOGOMTUSI.

, . IDD_ABOUTBOX. Picture Control. , .

PictureControl ( ) . IDC_LOGO. . , IDB_LOGOMTUSI, . .

 

 

. , , .

 

 

3. (Text).

:

 

2
:
_
2012-2013 .

 

, . . .

Static Text , . Static , . . IDC_STATIC, , , 1, IDC_STATIC_1.

Caption , Static Text. , . . , , (\t) (\n). ( Left). . .

. .

. . , Resource.h _ 2.rc.

 

4. , , , . : + + , .

0

 

ID_GET  

 

, Dialog , Dialog, .

 

. IDD_GET, : .

 

 

:

ID
Static text IDC_STATIC
Static text IDC_STATIC
Static text IDC_STATIC
Edit control IDC_GET_FAM -
Edit control IDC_GET_IMIA -
Edit control IDC_GET_GOD -

 

5. IDD_GET , , , GetDataDlgProc.

 

( , About , , .)

 

 

GetDataDlgProc :

 

BOOL CALLBACK GetDataDlgProc (HWND hDlg, UINT message,

WPARAM wParam, LPARAM lParam)

{

 

 

switch (message)

{

case WM_INITDIALOG:

// SetFocus

// IDC_GET_FAM

return FALSE;

 

case WM_COMMAND:

switch (LOWORD(wParam))

{

case IDOK:

 

//

// ,

 

EndDialog(hDlg,TRUE);

 

return TRUE;

 

case IDCANCEL:

 

// , ,

//

//

EndDialog(hDlg, FALSE);

return TRUE;

}

break;

}

return FALSE;

 

}

 

_ 2.h , :

#include "resource.h"

#include <time.h>

#define LENFAM 20

#define LENIMIA 15

#define LENFAMI 25

 

struct StudBeg { TCHAR fam[LENFAM]; //

TCHAR imia[LENIMIA]; //

UINT godRojd; //

};

 

struct StudEnd { TCHAR famI[LENFAMI];//

// ,

UINT let; //

};

 

. , ,

:

#include "stdafx.h"

#include " _ 2. h"

 

GetStud

GetStud .

StudBeg GetStud (HWND hDlg)

{ StudBeg studBeg;

TCHAR buf[100]=TEXT("");

BOOL lpFam=TRUE,lpImia=TRUE,lpGod;

GetDlgItemText(hDlg,IDC_GET_FAM,studBeg.fam,20);

if(*studBeg.fam == 0)

{

wcscpy(buf, L" !");

lpFam=FALSE;

}

GetDlgItemText(hDlg,IDC_GET_IMIA,studBeg.imia,12);

if(*studBeg.imia == 0)

{

wcscpy(buf+wcslen(buf), L" !");

lpImia=FALSE;

}

studBeg.godRojd = GetDlgItemInt(hDlg,IDC_GET_GOD,&lpGod,FALSE);

if (lpGod ==FALSE||studBeg.godRojd <1970)

wcscpy(buf+wcslen(buf), L" !");

if (lpGod == FALSE||

studBeg.godRojd < 1970||

lpFam == FALSE||

lpImia == FALSE)

{

MessageBox(hDlg,buf, TEXT(" "), MB_OK);

//

*studBeg.fam=0;

*studBeg.imia = 0;

studBeg.godRojd = 0;

}

return studBeg;

}

 

StudBeg studBeg={ TEXT(""), TEXT(""),0}; WM_COMMAND ID_GET

 

DialogBox(hInst, MAKEINTRESOURCE(IDD_GET), hWnd, GetDataDlgProc);

 

 

GetDataDlgProc, .

.

 

 

5. , .

<time.h>, ,

 

StudEnd obrabotkaInfo(const StudBeg& studBeg)

{

StudEnd studEnd={TEXT(" ",0)};

 

// - newtime.tm_year+1900

// Help _localtime64_s

char buf[26];

time_t ltime;

time(&ltime);

errno_t err = ctime_s(buf, 26, &ltime);

// struct tm

tm newtime;

_localtime64_s(&newtime, &ltime);

int let=0;

//

if(studBeg.godRojd)

let = (newtime.tm_year+1900) - studBeg.godRojd;

//

if(let > 0 && studBeg.godRojd >=1970)

{swprintf(studEnd.famI,23,L"%s %c.",studBeg.fam,*studBeg.imia);

studEnd.let=let;

}

return studEnd;

}

 

6. . PutStud case WM_PAINT

PutStud , obrabotkaInfo.

void PutStud (HDC hDc)

{

StudEnd studEnd = obrabotkaInfo(studBeg);

 

if(studEnd.let)

{

int x=50,y=50;

int tabstop[]={-130, 200, 250};

TCHAR buf[100];

// studEnd

swprintf(buf,100,L":\t%s\t:\t%d",

studEnd.famI,studEnd.let);

int len=wcslen(buf);

//

TabbedTextOut(hDc,x,y,buf,len,3, tabstop, x);

 

 

}

}

.

.

 

7. . .

 

.

(0- )

- -  

 

- (1- )

ID_GET
ID_PUT

 

.

Resource View, Dialog Add Resource, Dialog, New. . IDD_PUT, : .

 

:

ID
Static text IDC_STATIC
Static text IDC_STATIC
Edit control IDC_PUT_FAM - Read-only
Edit control IDC_PUT_LET - Read-only

 

Cancel, OK.

 

PutDataDlgProc

 

BOOL CALLBACK PutDataDlgProc (HWND hDlg, UINT message,

WPARAM wParam, LPARAM lParam)

{

switch (message)

{

case WM_INITDIALOG:

// , //

// ( )

return TRUE;

case WM_COMMAND:

switch (LOWORD(wParam))

{

case IDOK:

EndDialog(hDlg,TRUE);

return TRUE;

case IDCANCEL:

// , Cancel ,

//

//

EndDialog(hDlg, FALSE);

return TRUE;

}

break;

}

return FALSE;

 

}

 

PutStudDlg , obrabotkaInfo PutDataDlgProc.

void PutStudDlg (HWND hDlg)

{

 

StudEnd studEnd = obrabotkaInfo(studBeg);

if(studEnd.let)

{ SetDlgItemText(hDlg,IDC_PUT_FAM,studEnd.famI);

SetDlgItemInt(hDlg,IDC_PUT_LET,studEnd.let,FALSE);

}

}

 

PutDataDlgProc WndProc WM_COMMAND, case ID_PUT:

 

DialogBox(hInst, MAKEINTRESOURCE(IDD_PUT), hWnd, PutDataDlgProc);

 

!

.

 

, , .

1. ?

2. ?

3. .

4. ?

5. ?

6. ?

7. ? .

8. , ?

9. ?

10. ?

11. ?

12. ?

13. ?

14. ?

15. ?

 





:


: 2016-11-18; !; : 1114 |


:

:

,
==> ...

1347 - | 1313 -


© 2015-2024 lektsii.org - -

: 0.134 .