VC and database projects are the most comprehensive landing settings of the calculator color, etc.

xiaoxiao2021-03-06  71

/// Class Name: Caboutdlg // Function: Address Book "About" dialog

/

#include "stdafx.h" #include "address.h" #include "addressdlg.h" #include "pswdset.h" // When a class is required in another class, the header should be Document plus in the CPP of this class #include "maindlg.h"

#ifdef _debug # define new debug_new # undef this_filestatic char this_file [] = __file __; # ENDIF

/// Caboutdlg Dialog Used for App About

Class Caboutdlg: public cdialog {public: capoutdlg ();

// 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

// ImplementationProtace: // {{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_MAPEND_MESSAGE_MAP ()

/// CADDRESSDLG DIALOG

Caddressdlg :: Caddressdlg (CWND * PParent / * = null * /): cdialog (Caddressdlg :: IDD, PPARENT) {// {{AFX_DATA_INIT (CADDRESSDLG) m_password = _t ("); //}} AFX_DATA_INIT // Note That Loadicon Does Not Require A Subsequent Destroyicon in Win32 M_Hicon = AFXGetApp () -> Loadicon; count = 0; second = 20;}

void CAddressDlg :: DoDataExchange (CDataExchange * pDX) {CDialog :: DoDataExchange (pDX); // {{AFX_DATA_MAP (CAddressDlg) DDX_Control (pDX, IDC_EDIT1, m_ctrlpassword); DDX_Text (pDX, IDC_EDIT1, m_password); //}} AFX_DATA_MAP }

BEGIN_MESSAGE_MAP (CAddressDlg, CDialog) // {{AFX_MSG_MAP (CAddressDlg) ON_WM_SYSCOMMAND () ON_WM_PAINT () ON_WM_QUERYDRAGICON () ON_WM_TIMER () ON_WM_CLOSE () ON_WM_CTLCOLOR () //}} AFX_MSG_MAPEND_MESSAGE_MAP () /// CAddressDlg message handlers

Bool Caddressdlg :: OnNitDialog () {cdialog :: OnIndIalog (); // Todo: add extra initialization her_ctrlpassword.setfocus (); /// function is to initialize its initialization set to settimer when the dialog is just appear. 0,3000, null); SetTimer (1,4000, null);

Return True; // Return True UnsS you set the focus to a control}

void CAddressDlg :: 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 automaticly done for you by the framework.

Void Caddressdlg :: 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 (×, y, m_hicon);} else {cdialog :: onpaint ();}}

// The system calls this to obtain the cursor to display while the user Drags // The minimized window.hcursor Caddressdlg :: ONQUERYDRAGICON () {Return (hcursor) m_hicon;}

///// Name: Onok // function: Require input password

// void Caddressdlg :: Onok () {// Todo: add extra validation here cpswdset * m_recordset = new cpswdset (& m_database); // Dynamic allocation memory can be given different values ​​CString strsql; // m_database is Updatedata (TRUE) is defined in the header file; // read the password entered by the user Updatedata (true); strsql.format ("Select * from password where password = '% s'", m_password); /// strsql .Format ("Select * from password where password = '% s'", m_password); // Write a complete SQL statement m_recordset-> open (AFX_DB_USE_DEFAULT_TYPE, STRSQL); // From the database, if the input password is correct // Record the object or pointer to open a record, execute the SQL statement method is Open if (m_recordset-> getRecordCount () == 0) {if (count <3) {MessageBox ("Password error!", "Prompt", MB_OK | MB_ICONITIONFORMATION); count ; // Login number plus 1 m_password.empty (); m_ctrlpassword.setfocus (); Updatedata (false);} else {MessageBox ("You do not have to use this system!", "Warning", MB_OK | MB_ICONHAND); m_database.close (); // Turn off the database cDialog :: Onok (); // Close dialog box} // If the login is successful, open the main interface of the address book else {m_database.close (); cmaindlg m_dlg; m_dlg.m_database.Open ("AddressList")); // //> The internal parameter is the database name KillTimer (0); // Close the timer timer must be turned off after the use, otherwise waste resources

CDIALOG :: Onok (); // Close the current dialog m_dlg.domodal (); // Open the main dialog box}}

/// Name: ONTIMER / / Function: Implement the countdown function on the login interface

/ void Caddressdlg :: ONTIMER (uint nidEvent) {// Todo: add your message handler code here and / or call defaultiff (nidevent == 0) {cstring str; seconds--; str.format ("% d", Seconds; this-> setWindowText ("Password (" STR ") Second Address Book - Ma Jingfa"); // Plus indicates parentheses IF (seconds == 0) {killtimer (0); Caddressdlg :: oncancel () ; // because Caddressdlg is a class name, not an entity, so use ::}} else {cstring str; seconds-; str.format ("% d", seconds); this-> setWindowText ("password (" STR ") Second Harbin University of Technology computer 03-5 Ma Jingfa"); // plus sign indicates parentheses IF (seconds == 0) {killtimer (0); Caddressdlg :: oncancel (); // Because Caddressdlg is a class, Instead of entity, use: // Close the function called by the function called by: //.

} Cdialog :: ONTIMER (Nidevent);

// Name: OnClosr // Function: Close the landing interface

/ void Caddressdlg :: OnClose () // This is a member function of the system closes the dialog box {// Todo: add your message handler code here and / or call default killtimer (0); if (MessageBox " Dear users, / n Do you confirm? "", "Ma Jingfa reminds you", MB_OKCANCEL) == IDOK)

CDIALOG :: onClose ();

/// Name: OnCtrlColor // Function: Set the color of the login interface text

HBRUSH CAddressDlg :: OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor) {HBRUSH hbr = CDialog :: OnCtlColor (pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC-> SetTextColor (RGB (0, 0, 255)); // Todo: Return A Different Brush if the default is not desired return hbr;} ///

转载请注明原文地址:https://www.9cbs.com/read-118720.html

New Post(0)