Use C language to write Christmas Confession program _c language

Source: Internet
Author: User
Tags assert

It's almost Christmas, is there a male ticket? If not, are there any girls or boys you like? Today I will give you a Christmas confession procedure, I hope you like it, the effect is this:

Christmas is coming, let's Make a Christmas confession program in C language.

The specific code is as follows:

GreetingCardDemoDlg.cpp: Implementation file//#include "stdafx.h" #include "GreetingCardDemo.h" #include "GreetingCardDemoDlg.h" # Include "Afxdialogex.h" #ifdef _DEBUG #define NEW debug_new #endif//CAboutDlg dialog class for Application "about" menu item Caboutdlg:publi C CDialogEx {Public:caboutdlg ();//dialog box data enum {IDD = Idd_aboutbox}; protected:virtual void DoDataExchange (Cdataexcha nge* PDX);
DDX/DDV Support//Implementation protected:declare_message_map ()}; Caboutdlg::caboutdlg (): CDialogEx (Caboutdlg::idd) {} void CAboutDlg::D odataexchange (cdataexchange* pDX) {CDialogEx:
:D Odataexchange (PDX); } begin_message_map (CAboutDlg, CDialogEx) End_message_map ()//Cgreetingcarddemodlg dialog box Cgreetingcarddemodlg:: Cgreetingcarddemodlg (cwnd* pparent/*=null*/): CDialogEx (Cgreetingcarddemodlg::idd, pParent) {M_hIcon = AfxGetApp ()-& Gt
LoadIcon (IDR_MAINFRAME);
} void Cgreetingcarddemodlg::D odataexchange (cdataexchange* pDX) {cdialogex::D odataexchange (PDX);}
Begin_message_map (Cgreetingcarddemodlg, CDialogEx) On_wm_syscommand ()On_wm_paint () On_wm_querydragicon ()//on_bn_clicked (Idc_btn_draw, &cgreetingcarddemodlg::onbnclickedbtndraw) On_wm_timer () End_message_map ()//CGREETINGCARDDEMODLG Message Handler BOOL Cgreetingcarddemodlg::oninitdialog () {CDialogEx:
: OnInitDialog ();
Add the "About ..." menu item to the System menu.
Idm_aboutbox must be within the system command range.
ASSERT ((Idm_aboutbox & 0xfff0) = = Idm_aboutbox);
ASSERT (Idm_aboutbox < 0xf000);
cmenu* Psysmenu = GetSystemMenu (FALSE);
if (Psysmenu!= NULL) {BOOL bnamevalid;
CString Straboutmenu;
Bnamevalid = straboutmenu.loadstring (Ids_aboutbox);
ASSERT (Bnamevalid); if (!straboutmenu.isempty ()) {Psysmenu->appendmenu (mf_separator); Psysmenu->appendmenu (MF_STRING, IDM_
AboutBox, Straboutmenu); }//Set the icon for this dialog box. When the application main window is not a dialog box, the framework will automatically//Perform this action SetIcon (M_hicon, TRUE);/Set Large icon SetIcon (M_hicon, FALSE),//Set small icon//1. is not the method is not called//2.
Is there a problem with the system method inside M_pfont = new CFont; M_PFONT-&GT;CREATEFONTW (0, 0, 0, Fw_bold, False, False, 0, Ansi_charset, Out_default_precis, Clip_default_precis, DEF Ault_quality, DEfault_pitch |
Ff_swiss, L "Arial");
SetTimer (1, nullptr); return TRUE; TRUE} void Cgreetingcarddemodlg::onsyscommand (UINT NID, LPARAM LPARAM) {if (NID & 0xfff0) = = IDM unless the focus is set to the control
_aboutbox) {CAboutDlg dlgabout; Dlgabout.domodal ();} else {Cdialogex::onsyscommand (NID, LParam);}} void Cgreetingcarddemodlg::onpaint () {if (Isiconic ()) {CPAINTDC DC (this);///////////////The device context SendMessage (WM_ICONERASEBKGND, Reinterpret_cast<wparam> (DC.
GETSAFEHDC ()), 0);
Centers the icon in the workspace 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; Draws the icon DC.
DrawIcon (x, y, M_hicon);
else {Draw ();
Cdialogex::onpaint ();
The system calls this function to obtain the cursor//display when the user drags the minimized window. Hcursor Cgreetingcarddemodlg::onquerydragicon () {return static_cast 

These are all the code spicy, inside the sentence you can change Chengxiang to the other side of the words, these are able to change their own, the code is only a reference, to learn is the programming ideas, I hope you can learn C + +, can be used for their own!!

If you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

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.