Windows Programming-Aircraft War notes (single document file landing interface)

Source: Internet
Author: User

2015/07/21////////////////

by xbw///////////////////////

Environment VS 2013////////////

Aircraft war done almost, idle to add something tall on the landing interface of the single document;

The interface is a bit ugly, but enough account login, first try;

It's not bad, it's all there.

Let's talk about the process 、、、、、、

First, we want to create a dialog dialog box in the Resource view;;;

First the general picture of this dialog box, your own design is good, and then right-click in the blanks to add the class, to this dialog box to add classes;

Here, I added a loading class, English is not too good, carelessly write a bit tall on the English;;

Where to use the dialog we'll need it. # include "Loading.h" plus for his head file,,,

So, I built a function in the view class.

BOOL Cplanegameview::indlg () {loading dlg;//opening = TRUE; if (dlg. DoModal () = = IDOK) {  Invalidate ();  opening = DLG.OPEN1; } return TRUE;


Called in

void Cplanegameview::oninitialupdate () {cview::oninitialupdate ();//TODO: Add a dedicated code here and/or call the base class//Login Interface Indlg ();//Initialize the game if (! opening) Initgame (); else exit (0);}


This function will run in sequence;

In this case, the login interface will be displayed before the Single document window,

As for the opening is I set the switch, is the point Login Interface Exit button will be executed exit (0), the whole program is over, before the problem is, point out the Exit button, the program instead ran the Aircraft War main program, in distress, simply put this button deleted, Players can only enter the game to quit, and then a think this does not, haha, so get up;

First, the code of paragraph loading.cpp;

The complete ******

Loading.cpp: Implement file//#include "stdafx.h" #include "PlaneGame.h" #include "loading.h" #include "afxdialogex.h"//Loading dialog box implement_dynamic (loading, CDialogEx) loading::loading (cwnd* pparent/*=null*/): CDialogEx (Loading::idd, pParent) , open (False), Open1 (false) {}loading::~loading () {}void loading::D odataexchange (cdataexchange* pDX) {}begin_message_ MAP (loading, CDialogEx) on_wm_nchittest () On_wm_ctlcolor () on_bn_clicked (IDCANCEL, &loading::onbnclickedcancel) On_bn_clicked (IDOK, &loading::onbnclickedok) on_bn_clicked (IDOK2, &loading::onbnclickedok2) END_MESSAGE_ MAP ()//Loading message handler//mouse Drag window move lresult loading::onnchittest (CPoint point) {//TODO: Add Message Handler code here and/ or call the default value ScreenToClient (&point); CRect RC; GetClientRect (&RC), if (RC. PtInRect (point)) {return htcaption;} Else{return cdialogex::onnchittest (point);}} Hbrush Loading::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nctlcolor) {//hbrush HBR = Cdialogex::onctlcolor (PDC, PWnd, Nctlcolo R);//cfont Font;//font. CreatePointFont (_t ("Arial"), NULL);//getdlgitem (idc_static)->setfont (&font);//TODO: Change any of the properties of the DC here//Add in the OnInitDialog () function://TODO: Add additional initialization tokens here if (nCtlColor = = ctlcolor_static)   {Pdc->settextcolor (200, 100, 50));pD C->setbkmode (RGB () Set background transparent return Hbrush (Getstockobject (Hollow_brush));} TODO: If the default is not the desired brush, return another brush//return Hbr;return 0;} void Loading::onbnclickedcancel () {//TODO: In this Add control notification handler code open = FALSE; Cdialogex::oncancel ();} void Loading::onbnclickedok () {//TODO: This adds a control to the notification handler code CString name; CString Pwd;int flog = 1; GetDlgItem (IDC_EDIT3)->GETWINDOWTEXTW (name); GetDlgItem (IDC_EDIT4)->getwindowtextw (PWD); if (Name.compare (_t ("xbw12138")) | | Pwd.compare (_t ("201401061130"))) {if (Name.compare (_t ("xbw12138"))) {flog = 0; MessageBox (_t ("username is incorrect"), _t ("hint"));} if (Pwd.compare (_t ("201401061130")) &&flog==1) MessageBox (_t ("Incorrect password"), _t ("hint"));} Else{onok ();}} void Loading::onbnclickedok2 () {open1 = false;//TODO: Add control notification handler code here}


LRESULT loading::onnchittest (CPoint point) This is the added message, specifically what the message no longer this explanation, please look at my other articles, the mouse Drag dialog box to move the article, yes, that is the function;

Hbrush Loading::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nCtlColor) is also the added message, in order to make some space such as static text transparent, when there is a background map, the effect is obvious, but the installation force failed. , one more article to fill up;;;;;

void Loading::onbnclickedcancel ()
{
TODO: Add control notification Handler code here
open = FALSE;
Cdialogex::oncancel ();
}

This paragraph has been useless, the cancellation of the space has been deleted by me;;;

void Loading::onbnclickedok ()
{
TODO: Add control notification Handler code here
CString name;
CString pwd;
int flog = 1;
GetDlgItem (IDC_EDIT3)->GETWINDOWTEXTW (name);
GetDlgItem (IDC_EDIT4)->getwindowtextw (PWD);
if (Name.compare (_t ("xbw12138")) | | Pwd.compare (_t ("201401061130")))
{
if (Name.compare (_t ("xbw12138")))
{
Flog = 0;
MessageBox (_t ("username is incorrect"), _t ("hint"));
}

if (Pwd.compare (_t ("201401061130")) &&flog==1)

MessageBox (_t ("Incorrect password"), _t ("hint"));
}
Else
{
OnOK ();
}
}

This is the focus of the bar, check whether the landing is correct,, although it is a single machine, but this is also very tall, follow up, I will use XML to record some data, try to achieve an Account record a score, get a leaderboard what, and so I ang;

void Loading::onbnclickedok2 ()
{
Open1 = FALSE;
TODO: Add control notification Handler code here
}
This is the exit button switch,,, as for some variables, are added in the corresponding header file, it is important to remember to initialize, to not mess,,,

This is basically the same, the wrong place to exchange learning, there is a problem in the bottom of the message, I will reply with you to solve the problem together,

It's not much of a car.

, don't say much.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Windows Programming-Aircraft War notes (single document file landing interface)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.