ID card number lottery program source code [VC ++ 6]

xiaoxiao2021-03-06  41

// giftdlg.h: Header file //

#if! defined (afX_giftdlg_h__21d8d4ef_07f4_4f29_9351_78f99bff7723__included _) # define afX_giftdlg_h__21d8d4ef_07f4_4f29_9351_78f99bff7723__included_

#if _MSC_VER> 1000 # prgma overce # endif //_MSC_VER> 1000

/// cgiftdlg dialog

Class cgiftdlg: public cdialog {// constructionpublic: int freeMem (); int resetdata (); int initdata (); // initialization array cgiftdlg (cWnd * pParent = null); // standard constructor char * code [1000]; / / Pointer Char * name [1000], pointing to the ID number array; // Pointer CHAR DATA [1000]; // Random array int PTR; // The schedule is currently pointing to the random array of pointer INT TOTALID; //// Participate in the total ID of the draw, if you take one, you can subtract 1 BOOL BSTART; / / Tagged progress bar is scrolling

// Dialog Data // {{AFX_DATA (CGIFTDLG) ENUM {IDD = IDD_GIFT_DIALOG}; cbutton m_btgo; cstract m_code; cstract m_msg; ///} AFX_DATA

// ClassWizard generated virtual function overrides // {{AFX_VIRTUAL (CGIFTDLG) protected: Virtual Void DodataExchange (CDATAEXCHANGE * PDX); // DDX / DDV Support ///}} AFX_VIRTUAL

// ImplementationProtace: hicon m_hicon;

// Generated message map functions // {{AFX_MSG (CGiftDlg) virtual BOOL OnInitDialog (); afx_msg void OnPaint (); afx_msg HCURSOR OnQueryDragIcon (); virtual void OnOK (); afx_msg void OnTimer (UINT nIDEvent); afx_msg void OnCancelMode ( Virtual void oncancel (); //}} AFX_MSG DECLARE_MESSAGE_MAP ()};

// {{AFX_INSERT_LOCATION}} // Microsoft Visual C Will Insert Additional Declarations Immediately Before The Previous Line.

#ndif //! defined (AFX_GIFTDLG_H__21D8D4EF_07F4_4F29_9351_78F99BFF7723__INCluded _) // giftdlg.cpp: importation file //

#include "stdafx.h" #include "gift.h" #include "giftdlg.h"

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

/// cgiftdlg dialog

CGiftdlg :: cgiftdlg (cwnd * pparent / * = null * /): cdialog (cgiftdlg :: IDD, pParent) {// {{AFX_DATA_INIT (CGIFTDLG) m_code = _t (""); m_msg = _t (""); //}} AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp () -> LoadIcon (IDR_MAINFRAME);} void CGiftDlg :: DoDataExchange (CDataExchange * pDX) {CDialog :: DoDataExchange (pDX); // {{AFX_DATA_MAP (CGIFTDLG) DDX_Control (PDX, IDOK, M_BTGO); DDX_TEXT (PDX, IDC_STATIC_CODE2, M_CODE); DDX_TEXT (PDX, IDC_STATIC_MSG, M_MSG); //}} AFX_DATA_MAP}

Begin_MESSAGE_MAP (CGIFTDLG, CDIALOG) / / {{AFX_MSG_MAP (CGIFTDLG) ON_WM_PAINT () ON_WM_QUERYDRAGICON () ON_WM_TIMER () ON_WM_CANCELMODE () / /}} AFX_MSG_MAPEND_MESSAGE_MAP ()

/// cgiftdlg message handlers

BOOL CGiftDlg :: OnInitDialog () {CDialog :: OnInitDialog (); InitData (); bstart = false;. // 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 // Todo: add extra initialization herE m_msg.format ("Press the start button to start scrolling, the number of people in the lottery box:% D", Totalid); Updatedata (false); return true; // return true unless}

// 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 cgiftdlg :: 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; int Cyicon = getSystemMetrics (sm_cyicon); CRECT RECT; getClientRect (& Re); 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 cgiftdlg :: ONQUERYDRAGICON () {Return (hcursor) m_hicon;}

Void cgiftdlg :: onok () {// Todo: add extra validation here if (bstart) {killtimer (1); bstart = false; m_msg.format ("Press the start button to start scrolling, the number of people in the lottery box:% D", Totalid-1); m_code.format ("Take the number:% S / N Name:% s", Code [Data [PTR]], Name [Data [PTR]]); // AfxMessageBox; resetdata ); // Remove the extracted number, rescottate if (Totalid <1) {m_btgo.enablewindow (false);} m_btgo.setwindowText ("Start");} else {settimer (1, 100, null); bstart = True; m_msg.format ("Pick up a award button"); M_BTGO.SETWINDOWTEXT ("Stop");} Updatedata (false); // cdialog :: Onok ();}

Void cgiftdlg :: ONTIMER (uint nidevent) {// Todo: add your message hand default m_code.format ("The Number:% S", Code [Data [PTR]]); Updatedata (False) PTR ; PTR% = Totalid; cdialog :: Ontimer (nidevent);

Void cgiftdlg :: oncancelmode () {cdialog :: oncancelmode (); // Todo: add your message handler code here}

INT CGIFTDLG :: initdata () {file * fp = fopen ("id.txt", "r"); ptr = 0; Totalid = 1; if (fp == null) {return 0;} char buf [80] INT line = 0; While (! Feof (fp)) {char * p = fgets (BUF, 80, FP); if (p! = Null) {name [line] = (char *) Malloc (80); Code [line] = (char *) Malloc (80); MEMSET (CODE [line], 0, 80); MEMSET (Name [line], 0, 80); int flag = 0; for (int i = 0; I <80 && buf [i]! = '/ 0'; i ) {ix ((BUF [i]! = ',') && (Flag == 0)) {code [line] [i] = buf [i] } Else if (flag == 0) {flag = i;} else if ((buf [i]! = ',') && (flag! = 0)) {name [line] [i-flag-1] = BUF [I];}} TRACE ("% S-% S", CODE [line], name [line]); MEMSET (BUF, 0, 80); line ;}} fclose (fp); for (int J = 0; j

INT cgiftdlg :: freeMem () {int line = Totalid; for (int i = 0; i

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

New Post(0)