Win32 Notepad program (1), win32 Notepad program

Source: Internet
Author: User

Win32 Notepad program (1), win32 Notepad program

I won't take the title. In general, I want to use win32, imitate windows notepad, write a Notepad program, and finally make my program and Microsoft program look and look similar and functional. In this way, I can learn new knowledge and consolidate old knowledge.

1. Create a menu bar first. Create a menu. rc file. Refer to Microsoft notepad and write the following in it:

1 //menu.rc
 2 
 3 #define IDM_MAIN 0x2000
 4 #define IDM_NEW 0x4101
 5 #define IDM_OPEN 0x4102
 6 #define IDM_SAVE 0x4103
 7 #define IDM_SAVEAS 0x4104
 8 #define IDM_SETTING 0x4105
 9 #define IDM_PRINT 0x4106
10 #define IDM_EXIT 0x4107
11
12 #define IDM_DUDO 0x4201
13 #define IDM_CUTE 0x4202
14 #define IDM_COPY 0x4203
15 #define IDM_PASTE 0x4204
16 #define IDM_DELETE 0x4205
17 #define IDM_FINDE 0x4206
18 #define IDM_FINDENEXT 0x4207
19 #define IDM_REPLACE 0x4208
20 #define IDM_GOTO 0x4209
21 #define IDM_SELETEALL 0x4210
22 #define IDM_DATE 0x4211
twenty three 
twenty four 
25 #define IDM_WORDWRAP 0x4301
26 #define IDM_FONT 0x4302
27
28 #define IDM_STATUS 0x4401
29
30 #define IDM_HELP 0x4501
31 #define IDM_ABOUT 0x4502
32
33
34 IDM_MAIN menu discardable
35 BEGIN
36 popup "& File"
37 BEGIN
38 menuitem "& New", IDM_NEW
39 menuitem "& Open file", IDM_OPEN
40 menuitem "& Save", IDM_SAVE
41 menuitem "& Save As", IDM_SAVEAS
42 menuitem separator
43 menuitem "& Page Settings", IDM_SETTING
44 menuitem "& Print", IDM_PRINT
45 menuitem separator
46 menuitem "& Exit", IDM_EXIT
47 END
48 popup "& Edit"
49 BEGIN
50 menuitem "& Undo", IDM_DUDO GRAYED
51 menuitem separator
52 menuitem "& Cut", IDM_CUTE GRAYED
53 menuitem "& Copy", IDM_COPY GRAYED
54 menuitem "& Paste", IDM_PASTE
55 menuitem "& Delete", IDM_DELETE GRAYED
56 menuitem separator
57 menuitem "& Find", IDM_FINDE GRAYED
58 menuitem "& Find Next", IDM_FINDENEXT GRAYED
59 menuitem "& Replace", IDM_REPLACE
60 menuitem "& Go", IDM_GOTO GRAYED
61 menuitem separator
62 menuitem "& Select All", IDM_SELETEALL
63 menuitem "& Date", IDM_DATE
64 end
65 popup "& Format"
66 BEGIN
67 menuitem "& Wrap", IDM_WORDWRAP
68 menuitem "& Font", IDM_FONT
69 END
70 popup "& View"
71 BEGIN
72 menuitem "& Status Bar", IDM_STATUS GRAYED
73 END
74 popup "& Help"
75 BEGIN
76 menuitem "& View Help", IDM_HELP
77 menuitem separator
78 menuitem "& About Notepad", IDM_ABOUT
79 END
80 END

Finally, in the window function created in the main program, the menu bar handle is passed in.

hwnd = CreateWindow (szAppName,
                           TEXT ("Untitled-Notepad"),
                           WS_OVERLAPPEDWINDOW,
                           CW_USEDEFAULT,
                           CW_USEDEFAULT,
                           CW_USEDEFAULT,
                           CW_USEDEFAULT,
                           NULL,
                           LoadMenu (hInstance, MAKEINTRESOURCE (IDM_MAIN)),
                           hInstance,
                           NULL); 

In this way, the menu bar is displayed.

Programming series articles ". The author does not know who it is.


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.