Create a Win32 Application in vc6.0

Source: Internet
Author: User

When you get started with MFC, you cannot understand the code. Let's start with the principle of Windows programming...

 

# Include <windows. h> <br/> # include <stdio. h> </P> <p> lresult callback winsunproc (hwnd, uint umsg, wparam, lparam); </P> <p> int winapi winmain (hinstance, hinstance hprevinstance, lpstr lpcmdline, int nshowcmd) {<br/> wndclass; <br/> wndclass. cbclsextra = 0; <br/> wndclass. cbwndextra = 0; <br/> wndclass. hbrbackground = (hbrush) getstockobject (black_brush); <br/> wndclass. hcu Rsor = loadcursor (null, idc_sizens); <br/> wndclass. hicon = loadicon (null, idi_question); <br/> wndclass. hinstance = hinstance; <br/> wndclass. lpfnwndproc = winsunproc; <br/> wndclass. lpszclassname = "lihan"; <br/> wndclass. lpszmenuname = NULL; <br/> wndclass. style = cs_hredraw | cs_vredraw; <br/> registerclass (& wndclass); </P> <p> hwnd; <br/> hwnd = createwindow ("lihan ", "Shijiazhuang", ws_overlappedwindow, 600, 400, null, null, hinstance, null); </P> <p> showwindow (hwnd, sw_shownormal); <br/> updatewindow (hwnd ); </P> <p> MSG; <br/> while (getmessage (& MSG, null, 0, 0) {<br/> translatemessage (& MSG ); <br/> dispatchmessage (& MSG); <br/>}< br/> return 0; <br/>}</P> <p> lresult callback winsunproc (hwnd, uint umsg, wparam, lparam) {<br/> switch (umsg) <br/>{< br/> case wm_char: <br/> char szchar [20]; <br/> sprintf (szc Har, "char is % d", wparam); <br/> MessageBox (hwnd, szchar, "lihan", 0); <br/> break; <br/> case wm_lbuttondown: <br/> MessageBox (hwnd, "click", "lihan", 0); <br/> HDC; <br/> HDC = getdc (hwnd); <br/> textout (HDC, 0, 50, "lihan", strlen ("lihan ")); <br/> releasedc (hwnd, HDC); <br/> break; <br/> case wm_paint: <br/> HDC hdc1; <br/> paintstruct pS; <br/> hdc1 = beginpaint (hwnd, & PS); <br/> textout (hdc1, 0, 0, "lihan", strlen ("lih An "); <br/> endpaint (hwnd, & PS); <br/> break; <br/> case wm_close: <br/> If (idyes = MessageBox (hwnd, "is it true? "," Lihan ", mb_yesno) {<br/> destroywindow (hwnd); <br/>}< br/> break; <br/> case wm_destroy: <br/> postquitmessage (0); <br/> break; <br/> default: <br/> return defwindowproc (hwnd, umsg, wparam, lparam ); <br/>}< br/> return 0; <br/>}</P> <p>

 

Running status:

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.