遍匈 / Windows園殻 / 10、暇汽式凪麿彿坿 /

屈、Windows暇汽!秀羨暇汽議掲屎由圭隈

孖壓斑厘断不裏陶宣厘断侭網胎議麼籾。泌惚壓艇議殻會嶄短嗤和性塀暇汽?遇頁秀羨阻謹倖短嗤起竃塀暇汽議競蚊暇汽?旺柵出SetMenu壓競蚊暇汽岻寂俳算?椎氏頁焚担劔議秤侘椿?祥崧Lotus 1-2-3嶄析塀議猟忖庁塀暇汽椎劔。殻會10-8嶄議NOPOPUPS殻會婢幣阻侃尖宸嶽秤趨。壓宸倖殻會嶄?仝File々才仝Edit々?嚥MENUDEMO殻會嶄議窃貌?徽頁抜參総匯嶽競蚊暇汽?塋廠歆粥?

殻會10-8 NOPOPUPS
 
NOPOPUPS.C
 
/*-------------------------------------------------------------------------
 
 NOPOPUPS.C -- Demonstrates No-Popup Nested Menu
 
 (c) Charles Petzold, 1998
 
-------------------------------------------------------------------------*/
 
#include <windows.h>
 
#include "resource.h"
 
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
 
 PSTR szCmdLine, int iCmdShow)
 
{
 
 static TCHAR szAppName[] = TEXT ("NoPopUps") ;
 
 HWND hwnd ;
 
 MSG msg ;
 
 WNDCLASS wndclass ;
 
 
 
 wndclass.style = CS_HREDRAW | CS_VREDRAW ;
 
 wndclass.lpfnWndProc = WndProc ;
 
 wndclass.cbClsExtra = 0 ;
 
 wndclass.cbWndExtra = 0 ;
 
 wndclass.hInstance = hInstance ;
 
 wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
 
 wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
 
 wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
 
 wndclass.lpszMenuName = NULL ;
 
 wndclass.lpszClassName = szAppName ;
 
 if (!RegisterClass (&wndclass))
 
 {
 
 MessageBox ( NULL, TEXT ("This program requires Windows NT!"),
 
 szAppName, MB_ICONERROR) ;
 
 return 0 ;
 
 }
 
 
 
 hwnd = CreateWindow (szAppName,
 
 TEXT ("No-Popup Nested Menu Demonstration"),
 
 WS_OVERLAPPEDWINDOW,
 
 CW_USEDEFAULT, CW_USEDEFAULT,
 
 CW_USEDEFAULT, CW_USEDEFAULT,
 
 NULL, NULL, hInstance, NULL) ;
 
 
 
 ShowWindow (hwnd, iCmdShow) ;
 
 UpdateWindow (hwnd) ;
 
 
 
 while (GetMessage (&msg, NULL, 0, 0))
 
 {
 
 TranslateMessage (&msg) ;
 
 DispatchMessage (&msg) ;
 
 }
 
 return msg.wParam ;
 
}
 
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,LPARAM lParam)
 
{
 
 static HMENU hMenuMain, hMenuEdit, hMenuFile ;
 
 HINSTANCE hInstance ;
 
 switch (message)
 
 {
 
 case WM_CREATE:
 
 hInstance = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE) ;
 
 
 
 hMenuMain = LoadMenu (hInstance, TEXT ("MenuMain")) ;
 
 hMenuFile = LoadMenu (hInstance, TEXT ("MenuFile")) ;
 
 hMenuEdit = LoadMenu (hInstance, TEXT ("MenuEdit")) ;
 
 
 
 SetMenu (hwnd, hMenuMain) ;
 
 return 0 ;
 
 
 
 case WM_COMMAND:
 
 switch (LOWORD (wParam))
 
 {
 
 case IDM_MAIN:
 
 SetMenu (hwnd, hMenuMain) ;
 
 return 0 ;
 
 
 
 case IDM_FILE:
 
 SetMenu (hwnd, hMenuFile) ;
 
 return 0 ;
 
 
 
 case IDM_EDIT:
 
 SetMenu (hwnd, hMenuEdit) ;
 
 return 0 ;
 
 
 
 case IDM_FILE_NEW:
 
 case IDM_FILE_OPEN:
 
 case IDM_FILE_SAVE:
 
 case IDM_FILE_SAVE_AS:
 
 case IDM_EDIT_UNDO:
 
 case IDM_EDIT_CUT:
 
 case IDM_EDIT_COPY:
 
 case IDM_EDIT_PASTE:
 
 case IDM_EDIT_CLEAR:
 
 MessageBeep (0) ;
 
 return 0 ;
 
 }
 
 break ;
 
 
 
 case WM_DESTROY:
 
 SetMenu (hwnd, hMenuMain) ;
 
 DestroyMenu (hMenuFile) ;
 
 DestroyMenu (hMenuEdit) ;
 
 PostQuitMessage (0) ;
 
 return 0 ;
 
 }
 
 return DefWindowProc (hwnd, message, wParam, lParam) ;
 
}
 
NOPOPUPS.RC ?姜村?
 
//Microsoft Developer Studio generated resource script.
 
#include "resource.h"
 
#include "afxres.h"
 
/////////////////////////////////////////////////////////////////////////////
 
// Menu
 
MENUMAIN MENU DISCARDABLE
 
BEGIN
 
 MENUITEM "MAIN:", 0, INACTIVE
 
 MENUITEM "&File...", IDM_FILE
 
 MENUITEM "&Edit...", IDM_EDIT
 
END
 
MENUFILE MENU DISCARDABLE 
 
BEGIN
 
 MENUITEM "FILE:", 0, INACTIVE
 
 MENUITEM "&New", IDM_FILE_NEW
 
 MENUITEM "&Open...", IDM_FILE_OPEN
 
 MENUITEM "&Save", IDM_FILE_SAVE
 
 MENUITEM "Save &As", IDM_FILE_SAVE_AS
 
 MENUITEM "(&Main)", IDM_MAIN
 
END
 
MENUEDIT MENU DISCARDABLE 
 
BEGIN
 
 MENUITEM "EDIT:", 0, INACTIVE
 
 MENUITEM "&Undo", IDM_EDIT_UNDO
 
 MENUITEM "Cu&t", IDM_EDIT_CUT
 
 MENUITEM "&Copy", IDM_EDIT_COPY
 
 MENUITEM "&Paste", IDM_EDIT_PASTE
 
 MENUITEM "De&lete", IDM_EDIT_CLEAR
 
 MENUITEM "(&Main)", IDM_MAIN
 
END
 
RESOURCE.H ?姜村?
 
// Microsoft Developer Studio generated include file.
 
// Used by NoPopups.rc
 
#define IDM_FILE 40001
 
#define IDM_EDIT 40002
 
#define IDM_FILE_NEW 40003
 
#define IDM_FILE_OPEN 40004
 
#define IDM_FILE_SAVE 40005
 
#define IDM_FILE_SAVE_AS 40006
 
#define IDM_MAIN 40007
 
#define IDM_EDIT_UNDO 40008
 
#define IDM_EDIT_CUT 40009
 
#define IDM_EDIT_COPY 40010
 
#define IDM_EDIT_PASTE 40011
 
#define IDM_EDIT_CLEAR 40012
 

壓Microsoft Developer Studio嶄?艇秀羨阻眉倖暇汽?遇音頁匯倖。貫仝Insert々嶄僉夲仝Resource々眉肝?耽倖暇汽嗤匯倖音揖議兆各。輝完笥嶧連侃尖殻會侃尖WM_CREATE嶧連扮?Windows繍耽倖暇汽彿坿紗墮坪贋?

hMenuMain = LoadMenu (hInstance, TEXT ("MenuMain")) ;
 
hMenuFile = LoadMenu (hInstance, TEXT ("MenuFile")) ;
 
hMenuEdit = LoadMenu (hInstance, TEXT ("MenuEdit")) ;
 

蝕兵扮?殻會峪?塋蕉澔傍ィ?

SetMenu (hwnd, hMenuMain) ;
 

麼暇汽聞喘忖憲堪仝MAIN:々、仝File...々才仝Edit...々双竃宸眉倖僉?。隼遇?仝MAIN:々頁鋤喘議?咀緩万音嬬聞WM_COMMAND嶧連瓜窟僕欺完笥嶧連侃尖殻會。仝File々才仝Edit々暇汽?參仝FILE:々才仝EDIT:々蝕兵?燕幣万断頁徨暇汽。耽倖暇汽議恷朔匯?脅頁忖憲堪仝(Main)々?燕幣勧指欺麼暇汽。壓宸眉倖暇汽岻寂序佩俳算頁載酒汽議?

case WM_COMMAND :
 
 switch (wParam)
 
 {
 
 case IDM_MAIN :
 
 SetMenu (hwnd, hMenuMain) ;
 
 return 0 ;
 
 case IDM_FILE :
 
 SetMenu (hwnd, hMenuFile) ;
 
 return 0 ;
 
 case IDM_EDIT :
 
 SetMenu (hwnd, hMenuEdit) ;
 
 return 0 ;
 
 凪万佩殻會
 
 }
 
 break ;
 

壓WM_DESTROY嶧連侃尖豚寂?NOPOPUPS繍殻會議暇汽譜協葎麼暇汽?旺柵出DestroyMenu栖賠茅仝File々才仝Edit々暇汽。輝完笥瓜賠茅扮?麼暇汽繍瓜徭強賠茅。

AltStyle によって変換されたページ (->オリジナル) /