




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
華北科技學院課程設(shè)計說明書課程名稱:匯編語言班級:計算機B08-1姓名:_李鵬飛___學號:____設(shè)計題目:___win32編寫記事本___設(shè)計時間:_6月23日_至_7月1日__指導(dǎo)教師:_____杜杏菁_________________評語:_____________________________________________________________________________________________________________________________________________________________________________________________________評閱成績:____評閱教師:_____一、課程設(shè)計目的進行程序設(shè)計方法和技能的基本訓練,鞏固在課堂上學到的有關(guān)程序設(shè)計的基本知識和基本方法,通過實際動手能力的培養(yǎng),進一步熟悉匯編語言的結(jié)構(gòu)和使用方法,達成能獨立閱讀、編制和調(diào)試一定規(guī)模的匯編語言程序的水平。二、課程設(shè)計規(guī)定1.規(guī)定編寫并調(diào)試通過一個小型軟件,實現(xiàn)對軟件或硬件的操作。2.遵循模塊化、結(jié)構(gòu)化的程序設(shè)計方法。3.規(guī)定程序必須對的。4.程序簡明易懂,多運用輸入輸出提醒,犯錯信息及必要的注釋。5.規(guī)定程序結(jié)構(gòu)合理,語句使用得當。6.適當追求編程技巧和程序運營效率。三、課程設(shè)計題目:win32編寫記事本四、課題分析WINDOW記事本的編寫,規(guī)定能實現(xiàn)基本菜單框架并打開窗口,有能力的同學可以編寫進行數(shù)據(jù)錄入并保存的代碼開始加載頭文獻開始加載頭文獻加載數(shù)據(jù)段編譯代碼設(shè)計窗體編譯生成文獻結(jié)束六、程序源代碼:.386.modelflat,stdcalloptioncasemap:noneinclude windows.incinclude user32.incincludelib user32.libinclude kernel32.incincludelibkernel32.libinclude shell32.incincludelib shell32.libinclude comctl32.incincludelibcomctl32.libinclude comdlg32.incincludelibcomdlg32.libICO_MAIN EQU 1000h ;圖標IDM_MAIN EQU 2023h ;菜單IDA_MAIN EQU 2023h ;加速鍵IDM_NEW EQU 2101h ;新建IDM_OPEN EQU 2102h ;打開IDM_SAVE EQU 2103h ;保存IDM_SAVEAS EQU 2104h ;另存為IDM_EXIT EQU 2105h ;退出IDM_UNDO EQU 2201h ;撤消IDM_CUT EQU 2203h ;剪切IDM_COPY EQU 2204h ;復(fù)制IDM_PASTE EQU 2205h ;粘貼IDM_DELETE EQU 2206h ;刪除IDM_FIND EQU 2207h ;查找IDM_REPLACE EQU 220Ah ;替換IDM_SELECTALL EQU 220Bh ;全選IDM_FONT EQU 2301h ;字體IDM_STATUSBAR EQU 2401h ;狀態(tài)欄IDM_HELP EQU 2501h ;幫助主題IDM_ABOUT EQU 2502h ;關(guān)于IDM_MENUHELP EQU 2601h ;菜單信息.data?hInstance dd ?hWinMain dd ?hMenu dd ?hWinStatus dd ?hWinEdit dd ?hFile dd ?hFindDialog dd ?hRichEdit dd ?dwFontColor dd ?idFindMessage dd ?stFind FINDREPLACE <?>szFindText db 100dup(?)szReplaceText db 100 dup (?)szFileName db MAX_PATHdup(?)stLogFont LOGFONT <?>dwOption dd ?.dataF_STATUSBAR equ 00000001hdllEdit db "RichEd20.dll",0errTitle db "錯誤",0noRichEdit db "無法找到RichEd20.dll"className db "TextEditor",0captionMain db "文本編輯器",0classEdit db "RichEdit20A",0fontFace db "Fixedsys",0modify db "你已經(jīng)改動過啦,要不要存一下?",0filter db "文本文獻(*.txt)",0,"*.txt",0,"所有文獻",0,"*.*",0,0defExt db "txt",0titleFormat db "%s-我的記事本",0errCreateFile db "咦!出現(xiàn)問題了!",0errOpenFile db "咦!怎么打不開!",0notFound db "不給力啊,找不到!",0noName db "還沒起名字",0timeFormat db "%02d:%02d:%02d",0charsFormat db "字節(jié)數(shù):%d",0lineFormat db "行:%d",0colFormat db "列:%d",0helpTitle db "幫助",0helpText db "Sorry!無法提供任何幫助",0aboutTitle db "關(guān)于記事本",0aboutText db "我的記事本",0ah,0dh,"作者:李鵬飛",0ah,0dh,"2023年07月01日",0ah,0dh,0dwStatusWidth dd 100,200,300,400,-1dwMenuHelp dd 0,IDM_MENUHELP,0,0FINDMSGSTRING db "commdlg_FindReplace",0.code;====================================================================================================_CheckModifyStatePROC invoke SendMessage,hWinEdit,EM_GETMODIFY,0,0 ;獲取控件內(nèi)容是否改變的信息 .if eax!=0 invoke MessageBox,hWinMain,addrmodify,addrcaptionMain,\ MB_YESNOCANCELorMB_ICONQUESTION .if eax==IDYES call _SaveFile ;有待改動 .elseif eax==IDCANCEL mov eax,FALSE ret .endif .endif mov eax,TRUE ret_CheckModifyStateENDP;====================================================================================================;Richedit的流出操作_StreamProcOutPROCusesebxediesi_dwCookie,lpBuffer,NumBytes,pBytes invoke WriteFile,hFile,lpBuffer,NumBytes,pBytes,0 xoreax,1 ;假如ReadFile或WriteFile返回1(成功),則最終eax返回0,說明操作成功 ret_StreamProcOutENDP;====================================================================================================;Richedit的流入操作_StreamProcInPROCusesebxediesi_dwCookie,lpBuffer,NumBytes,pBytes invoke ReadFile,hFile,lpBuffer,NumBytes,pBytes,0 xoreax,1 ;假如ReadFile或WriteFile返回1(成功),則最終eax返回0,說明操作成功 ret_StreamProcInENDP;====================================================================================================;設(shè)立字體和字體的顏色_SetFont PROC _lpszFont,_dwFontSize,_dwColor local @stCf:CHARFORMAT invoke RtlZeroMemory,addr@stCf,sizeof @stCf ;開始填充stCf結(jié)構(gòu) mov @stCf.cbSize,sizeof@stCf mov @stCf.dwMask,CFM_SIZEorCFM_FACEorCFM_BOLDorCFM_COLOR ;字段掩碼,用來指定結(jié)構(gòu)中哪些字段是有效的 push _dwFontSize pop @stCf.yHeight push _dwColor pop @stCf.crTextColor mov @stCf.dwEffects,0 invoke lstrcpy,addr@stCf.szFaceName,_lpszFont invoke SendMessage,hWinEdit,EM_SETTEXTMODE,1,0 ;設(shè)立工作模式 invoke SendMessage,hWinEdit,EM_SETCHARFORMAT,SCF_ALL,addr@stCf ;為控件中的所有文本設(shè)立指定的格式 ret_SetFontENDP;====================================================================================================;查找文字_FindText PROC local @stFindText:FINDTEXTEX;設(shè)立查找區(qū)域 invoke SendMessage,hWinEdit,EM_EXGETSEL,0,addr @stFindText.chrg .if stFind.Flags&FR_DOWN ;向下查找 push @stFindText.chrg.cpMax pop @stFindText.chrg.cpMin ;將這個選擇區(qū)域的結(jié)束位置用做下一次查找的起始點 .endif mov @stFindText.chrg.cpMax,-1 ;一直查找到所有文本的最后;設(shè)立查找選項 mov @stFindText.lpstrText,offsetszFindText mov ecx,stFind.Flags and ecx,FR_MATCHCASEorFR_DOWNorFR_WHOLEWORD ;查找并把光標設(shè)立到找到的文本上 invoke SendMessage,hWinEdit,EM_FINDTEXTEX,ecx,addr@stFindText ;ecx中存儲的是搜索選項 .if eax== -1 mov ecx,hWinMain .if hFindDialog mov ecx,hFindDialog .endif invoke MessageBox,ecx,addrnotFound,NULL,MB_OKorMB_ICONINFORMATION ret .endif ;找到文本以后,文本的位置在FINDTEXTEX結(jié)構(gòu)的chrgText字段中返回,chrgText字段是一個CHARRANGE結(jié)構(gòu),直接在EM_EXSETSEL消息中使用它將選擇區(qū)域設(shè)立到找到的文字上 invoke SendMessage,hWinEdit,EM_EXSETSEL,0,addr@stFindText.chrgText invoke SendMessage,hWinEdit,EM_SCROLLCARET,NULL,NULL ;卷動文字,以便找到的文本可以出現(xiàn)在用戶的視野中 ret_FindText ENDP;====================================================================================================;保存文獻,假如沒有打開或創(chuàng)建文獻則另存為_SaveFile PROC local @stES:EDITSTREAM .if !hFile call _SaveAs .if !eax ret .endif .endif mov @stES.dwCookie,FALSE ;在Richedit的流操作中寫文獻 mov @stES.dwError,NULL mov @stES.pfnCallback,offset_StreamProcOut ;回調(diào)函數(shù) invoke SendMessage,hWinEdit,EM_STREAMOUT,SF_TEXT,addr@stES ;流出操作,文本格式是簡樸的文本格式 invoke SendMessage,hWinEdit,EM_SETMODIFY,FALSE,0 ;設(shè)立修改狀態(tài) mov eax,TRUE ret _SaveFile ENDP;=====================================================================================================;另存為_SaveAs PROC local @stOF:OPENFILENAME local @stEs:EDITSTREAM invoke RtlZeroMemory,addr@stOF,sizeof@stOF;顯示"保存文獻"對話框 ;填充stOF結(jié)構(gòu) mov @stOF.lStructSize,sizeof@stOF push hWinMain pop @stOF.hwndOwner ;所屬窗口 mov @stOF.lpstrFilter,offsetfilter ;指定文獻名篩選字符串 mov @stOF.lpstrFile,offsetszFileName mov @stOF.nMaxFile,MAX_PATH ;指定lpstrFile參數(shù)指向的緩沖區(qū)的長度,260 mov @stOF.Flags,OFN_PATHMUSTEXIST ;途徑必須存在 mov @stOF.lpstrDefExt,offsetdefExt ;默認擴展名 mov @stOF.lpstrTitle,NULL ;標題為“另存為” invoke GetSaveFileName,addr@stOF .if eax ;創(chuàng)建新文獻 invoke CreateFile,addrszFileName,GENERIC_READorGENERIC_WRITE,\ ;存取方式:為讀寫 FILE_SHARE_READ,\ ;共享屬性:允許其他進程同時以讀方式打開文獻 0,\ ;安全屬性:無法被繼承 CREATE_ALWAYS,\ ;創(chuàng)建新文獻,假如文獻已經(jīng)存在則清除原文獻 FILE_ATTRIBUTE_NORMAL,\ ;文獻屬性:普通文獻 0 ;文獻模板句柄 .if eax!=INVALID_HANDLE_VALUE push eax .if hFile ;有打開的文獻 invokeCloseHandle,hFile .endif pop eax ;保存文獻 mov hFile,eax ;文獻句柄 call _SaveFile call _SetCaption call _SetStatus mov eax,TRUE ret .else invoke MessageBox,hWinMain,addrerrCreateFile,NULL,MB_OKorMB_ICONERROR .endif .endif mov eax,FALSE ret_SaveAs ENDP;=====================================================================================================;打開及輸入文獻_OpenFile PROC local @stOF:OPENFILENAME local @stES:EDITSTREAM invoke RtlZeroMemory,addr@stOF,sizeof@stOF;顯示“打開文獻”對話框 mov @stOF.lStructSize,sizeof@stOF push hWinMain pop @stOF.hwndOwner mov @stOF.lpstrFilter,offsetfilter mov @stOF.lpstrFile,offsetszFileName mov @stOF.nMaxFile,MAX_PATH mov @stOF.Flags,OFN_FILEMUSTEXISTorOFN_PATHMUSTEXIST ;文獻必須存在 invoke GetOpenFileName,addr@stOF .if eax ;創(chuàng)建文獻 invoke CreateFile,addrszFileName,GENERIC_READorGENERIC_WRITE,\ FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0 ;打開存在的文獻,當文獻不存在時函數(shù)會返回失敗 .if eax== INVALID_HANDLE_VALUE invoke MessageBox,hWinMain,addrerrOpenFile,NULL,MB_OKorMB_ICONSTOP ret .endif push eax .if hFile invoke CloseHandle,hFile .endif pop eax mov hFile,eax ;讀入文獻 mov @stES.dwCookie,TRUE ;在Richedit的流操作中讀文獻 mov @stES.dwError,NULL mov @stES.pfnCallback,offset_StreamProcIn invoke SendMessage,hWinEdit,EM_STREAMIN,SF_TEXT,addr@stES ;流入操作,文本格式是簡樸的文本格式 invoke SendMessage,hWinEdit,EM_SETMODIFY,FALSE,0 ;設(shè)立修改狀態(tài) call _SetCaption call _SetStatus .endif ret_OpenFile ENDP;=====================================================================================================;選擇字體_ChooseFont PROC local @stCF:CHOOSEFONT invoke RtlZeroMemory,addr@stCF,sizeof@stCF mov @stCF.lStructSize,sizeof@stCF push hWinMain pop @stCF.hwndOwner mov @stCF.lpLogFont,offsetstLogFont ;指定字體的名稱和屬性 push dwFontColor pop @stCF.rgbColors mov @stCF.Flags,CF_SCREENFONTSorCF_INITTOLOGFONTSTRUCTorCF_EFFECTS ;字體列表中只顯示屏幕字體,對話框中顯示“效果”復(fù)選框 invoke ChooseFont,addr@stCF .if eax push @stCF.rgbColors pop dwFontColor mov eax,@stCF.iPointSize ;用戶選擇的字體大小,單位是1/10磅 shl eax,1 invoke _SetFont,addrstLogFont.lfFaceName,eax,@stCF.rgbColors .endif ret_ChooseFont ENDP;=====================================================================================================;設(shè)立標題欄的顯示內(nèi)容_SetCaption PROC local @szBuffer[1024]:byte .if szFileName ;假如當前是某一文獻,則顯示文獻名 mov eax,offsetszFileName .else mov eax,offsetnoName ;否則顯示未命名 .endif invoke wsprintf,addr@szBuffer,addrtitleFormat,eax invoke SetWindowText,hWinMain,addr@szBuffer ret_SetCaption ENDP;=====================================================================================================;設(shè)立菜單項,狀態(tài)欄的狀態(tài)和信息_SetStatus PROC local @stRange:CHARRANGE local @dwLines,@dwLine,@dwLineStart local @szBuffer[256]:byte local @stST:SYSTEMTIME ;在狀態(tài)欄顯示行列信息 invoke GetWindowTextLength,hWinEdit invoke wsprintf,addr@szBuffer,addrcharsFormat,eax invoke SendMessage,hWinStatus,SB_SETTEXT,2,addr@szBuffer ;總字節(jié)數(shù) invoke SendMessage,hWinEdit,EM_EXGETSEL,0,addr@stRange ;獲取選定區(qū)域 invoke SendMessage,hWinEdit,EM_EXLINEFROMCHAR,0,-1 ;得知指定的字符位于哪一行中 mov @dwLine,eax invoke SendMessage,hWinEdit,EM_LINEINDEX,eax,0 ;獲取指定行的起始字符的位置 mov ecx,@stRange.cpMin sub ecx,eax inc ecx ;顯示給用戶的列號從1開始編號 invoke wsprintf,addr@szBuffer,addrcolFormat,ecx invoke SendMessage,hWinStatus,SB_SETTEXT,1,addr@szBuffer ;光標所在位置的列 inc @dwLine ;顯示給用戶的行號從1開始 invoke wsprintf,addr@szBuffer,addrlineFormat,@dwLine invoke SendMessage,hWinStatus,SB_SETTEXT,0,addr@szBuffer ;光標所在位置的行 ;根據(jù)情況改變菜單項的狀態(tài) mov eax,@stRange.cpMin .if eax==@stRange.cpMax ;選中區(qū)域為空則復(fù)制粘貼刪除不可用 invoke EnableMenuItem,hMenu,IDM_COPY,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_CUT,MF_GRAYED .else invoke EnableMenuItem,hMenu,IDM_COPY,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CUT,MF_ENABLED .endif invoke IsClipboardFormatAvailable,CF_TEXT ;判斷剪貼板的格式是否是文本格式 .if eax ;假如剪貼板有內(nèi)容則可以粘貼 invoke EnableMenuItem,hMenu,IDM_PASTE,MF_ENABLED .else invoke EnableMenuItem,hMenu,IDM_PASTE,MF_GRAYED .endif invoke GetWindowTextLength,hWinEdit .if eax ;假如可以全選 invoke EnableMenuItem,hMenu,IDM_SELECTALL,MF_ENABLED .else invoke EnableMenuItem,hMenu,IDM_SELECTALL,MF_GRAYED .endif invoke SendMessage,hWinEdit,EM_GETMODIFY,0,0 .if eax ;假如可以保存 invoke EnableMenuItem,hMenu,IDM_SAVE,MF_ENABLED .else invoke EnableMenuItem,hMenu,IDM_SAVE,MF_GRAYED .endif .if dwOption&F_STATUSBAR ;假如選中了狀態(tài)欄 invoke CheckMenuItem,hMenu,IDM_STATUSBAR,MF_CHECKED .else invoke CheckMenuItem,hMenu,IDM_STATUSBAR,MF_UNCHECKED .endif ret_SetStatus ENDP;=====================================================================================================_Resize PROC local @stRect:RECT local @stRectTemp:RECT local @dwWidth,@dwHeight ;取得窗口客戶區(qū)的大小 invoke GetClientRect,hWinMain,addr@stRect mov eax,@stRect.right sub eax,@stRect.left mov @dwWidth,eax mov eax,@stRect.bottom sub eax,@stRect.top mov @dwHeight,eax ;計算及調(diào)整狀態(tài)欄 .if dwOption&F_STATUSBAR invoke ShowWindow,hWinStatus,SW_SHOW invoke MoveWindow,hWinStatus,0,0,0,0,TRUE invoke GetWindowRect,hWinStatus,addr@stRectTemp mov eax,@stRectTemp.bottom sub eax,@stRectTemp.top sub @dwHeight,eax .else invoke ShowWindow,hWinStatus,SW_HIDE .endif ;調(diào)整Richedit控件位置 invoke MoveWindow,hWinEdit,@stRect.left,@stRect.top,@dwWidth,@dwHeight,TRUE ret_Resize ENDP;=====================================================================================================_Quit PROC invoke _CheckModifyState .if eax invoke DestroyWindow,hWinMain invoke PostQuitMessage,NULL ;產(chǎn)生一條WM_QUIT消息 .if hFile ;假如有打開的文獻則關(guān)閉 invoke CloseHandle,hFile .endif .endif invoke KillTimer,hWinMain,1 ;取消定期器 ret_Quit ENDP;=====================================================================================================_CreateWindowPROC;注冊“查找”對話框消息,初始化“查找”對話框的結(jié)構(gòu) mov stFind.lStructSize,sizeofstFind ;結(jié)構(gòu)的長度 push hWinMain pop stFind.hwndOwner ;指定所屬窗口 mov stFind.Flags,FR_DOWN ;把“方向”單選鈕設(shè)立為“向下” mov stFind.lpstrFindWhat,offsetszFindText ;lpstrFindWhat指向包含查找字符串的指針 mov stFind.wFindWhatLen,sizeofszFindText ;wFindWhatLen指示lpstrFindWhat緩存區(qū)的長度 mov stFind.lpstrReplaceWith,offsetszReplaceText ;指向包含替換為字符串的指針 mov stFind.wReplaceWithLen,sizeofszReplaceText ;lpstrReplaceWith緩存區(qū)的長度 invoke RegisterWindowMessage,addrFINDMSGSTRING ;注冊自定義的消息 mov idFindMessage,eax ;eax中返回消息ID ;建立狀態(tài)欄 invoke CreateStatusWindow,SBARS_SIZEGRIPorWS_CHILDorWS_VISIBLE,\ ;顯示狀態(tài)欄右下角的斜條 NULL,hWinMain,2 ;父窗口為hWinMain,狀態(tài)欄控件的ID為2,初始化字符串為NULL mov hWinStatus,eax invoke SendMessage,hWinStatus,SB_SETPARTS,5,offsetdwStatusWidth ;提成四欄 ;建立輸出文本窗口 invoke CreateWindowEx,WS_EX_CLIENTEDGE,offsetclassEdit,NULL,\ ;客戶區(qū)立體邊框 WS_CHILDORWS_VISIBLEORWS_VSCROLLOR WS_HSCROLL\ ORES_MULTILINEorES_NOHIDESEL,\ ;可以編輯多行文字,失去鍵盤輸入焦點的時候仍然顯示選擇區(qū)域 0,0,0,0,\ hWinMain,0,hInstance,NULL ;0指定的是子窗口的ID號 mov hWinEdit,eax or dwOption,F_STATUSBAR ;注釋 invoke _SetCaption ;設(shè)立標題 invoke _SetStatus ;設(shè)立狀態(tài)欄 invoke _SetFont,addrfontFace,9*20,0 ;注釋 ;在使用多行Edit控件時,父窗口發(fā)送EM_SETEVENTMASK消息給RichEdit控件,指定它對哪些消息感愛好 ;wParam必須為0,ENM_CHANGE發(fā)送EN_CHANGE告知NM_SELCHANGE發(fā)送EN_SELCHANGE告知 invoke SendMessage,hWinEdit,EM_SETEVENTMASK,0,ENM_CHANGEorENM_SELCHANGEorENM_MOUSEEVENTS invoke SendMessage,hWinEdit,EM_EXLIMITTEXT,0,-1 ;設(shè)立控件中可以容納字符的總數(shù),0FFFFFFFFh(-1)字節(jié) invoke SendMessage,hWinMain,EM_EMPTYUNDOBUFFER,0,0 ;清空undo,redo隊列 ret_CreateWindowENDP;====================================================================================================;窗口過程_ProcWinMain PROC usesebxediesihWnd,uMsg,wParam,lParam local @stRange:CHARRANGE local @stST:SYSTEMTIME local @szBuffer[128]:byte local @pt:POINT local hPopup:DWORD local @stES:EDITSTREAM mov eax,uMsg .ifeax==WM_CREATE push hWnd pop hWinMain invoke _CreateWindow invoke SetTimer,hWinMain,1,300,NULL ;設(shè)立定期器 .elseif eax==WM_DROPFILES ;拖放文獻 call _CheckModifyState .ifeax==FALSE call _SaveFile .endif invoke DragQueryFile,wParam,0,addrszFileName,128 ;獲取文獻的途徑 invoke CreateFile,addrszFileName,GENERIC_READorGENERIC_WRITE,\ FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0 ;打開文獻 mov hFile,eax mov @stES.dwCookie,TRUE ;在Richedit的流操作中讀文獻 mov @stES.dwError,NULL mov @stES.pfnCallback,offset_StreamProcIn invoke SendMessage,hWinEdit,EM_STREAMIN,SF_TEXT,addr@stES ;流入操作,文本格式是簡樸的文本格式 invoke SendMessage,hWinEdit,EM_SETMODIFY,FALSE,0 ;設(shè)立修改狀態(tài) call _SetCaption call _SetStatus .elseifeax==WM_TIMER invoke GetLocalTime,addr@stST movzx eax,@stST.wHour movzx ebx,@stST.wMinute movzx ecx,@stST.wSecond invoke wsprintf,addr@szBuffer,addrtimeFormat,eax,ebx,ecx invoke SendMessage,hWinStatus,SB_SETTEXT,3,addr@szBuffer .elseifeax==WM_SIZE invoke _Resize .elseifeax==WM_NOTIFY mov eax,lParam mov eax,[eax+NMHDR.hwndFrom] .if eax==hWinEdit invoke _SetStatus .endif push esi mov esi,lParam assume esi:ptr NMHDR .if[esi].code==EN_MSGFILTER ;鼠標滑輪發(fā)送的消息 assumeesi:ptrMSGFILTER .if[esi].msg==WM_RBUTTONDOWN invoke GetMenu,hWinMain ;獲取窗口主菜單句柄 invoke GetSubMenu,eax,1 ;獲取彈出式子菜單的句柄 mov hPopup,eax invoke _SetStatus mov edx,[esi].lParam ;位置信息 mov ecx,edx and edx,0FFFFh shr ecx,16 mov @pt.x,edx mov @pt.y,ecx invoke ClientToScreen,hWinMain,addr@pt invoke TrackPopupMenu,hPopup,TPM_LEFTALIGNorTPM_BOTTOMALIGN,@pt.x,@pt.y,NULL,hWinMain,NULL .endif .endif pop esi .elseif eax==WM_MENUSELECT invoke MenuHelp,WM_MENUSELECT,wParam,lParam,lParam,hInstance,hWinStatus,offsetdwMenuHelp .elseifeax==WM_COMMAND mov eax,wParam movzx eax,ax .ifeax==IDM_OPEN invoke _CheckModifyState .ifeax ;eax==TRUE說明沒有被修改 call _OpenFile .endif .elseifeax==IDM_NEW invoke _CheckModifyState .if eax .if hFile invoke CloseHandle,hFile mov hFile,0 .endif mov szFileName,0 invoke SetWindowText,hWinEdit,NULL invoke _SetCaption invoke _SetStatus .endif .elseif eax==IDM_SAVE call _SaveFile .elseif eax==IDM_SAVEAS call _SaveAs .elseif eax==IDM_EXIT call _Quit .elseif eax==IDM_UNDO invoke SendMessage,hWinEdit,EM_UNDO,0,0 .elseif eax==IDM_SELECTALL mov @stRange.cpMin,0 mov @stRange.cpMax,-1 invoke SendMessage,hWinEdit,EM_EXSETSEL,0,addr@stRange .elseif eax==IDM_COPY invoke SendMessage,hWinEdit,WM_COPY,0,0 .elseif eax==IDM_CUT invoke SendMessage,hWinEdit,WM_CUT,0,0 .elseif eax==IDM_PASTE invoke SendMessage,hWinEdit,WM_PASTE,0,0 .elseif eax==IDM_FIND and stFind.Flags,notFR_DIALOGTERM ;FR_DIALOGTERM代表取消按鈕 invoke FindText,addrstFind .if eax mov hFindDialog,eax .endif .elseif eax==IDM_FONT invoke _ChooseFont .elseif eax==IDM_STATUSBAR xor dwOption,F_STATUSBAR ;注釋 invoke _Resize .elseif eax ==IDM_HELP invoke MessageBox,NULL,offsethelpText,offsethelpTitle,MB_OKorMB_ICONQUESTION .elseif eax==IDM_ABOUT invoke MessageBox,NULL,offsetaboutText,offsetaboutTitle,MB_OK .endif .elseif eax== idFindMessage .if stFind.Flags&FR_DIALOGTERM mov hFindDialog,0 .else invoke _FindText .endif .elseif eax== WM_ACTIVATE ;窗口激活 mov eax,wParam .if (ax== WA_CLICKACTIVE)||(ax==WA_ACTIVE) ;由鼠標點擊激活或被鼠標點擊以外的方法激活 invoke SetFocus,hWinEdit .endif .elseif eax==WM_CLOSE call _Quit .else invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .endif xor eax,eax ret _ProcWinMain ENDP;====================================================================================================_WinMainPROC local@stWndClass:WNDCLASSEX local@stMsg:MSG local@hAccelerator invokeGetModuleHandle,NULL ;得到應(yīng)用程序的句柄 mov hInstance,eax invokeLoadMenu,hInstance,IDM_MAIN ;加載菜單,IDM_MAIN指定要裝入的菜單資源ID mov hMenu,eax ;eax返回菜單句柄 invokeLoadAccelerato
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 電工聘請合同范本
- 供熱ppp項目合同范本
- 分期出租手機合同范本
- 共享單車租賃合同范本
- 個體雇傭司機合同范本
- 公司買車抵押合同范本
- 沖壓模具采購合同范本
- 內(nèi)墻涂料維修合同范本
- 醫(yī)療材料采購合同范本
- 保險服務(wù)合同范本
- 非遺資源數(shù)據(jù)庫建設(shè)
- 銀屑病診療指南2024
- (高清版)DB43∕T 1734-2020 快開門式壓力容器聯(lián)鎖裝置安全技術(shù)要求
- 2024年安防監(jiān)控系統(tǒng)技術(shù)標準與規(guī)范
- 出生醫(yī)學證明警示教育培訓
- DB11-T 2324-2024腳手架鋼板立網(wǎng)防護應(yīng)用技術(shù)規(guī)程
- 供應(yīng)鏈資源開發(fā)年終總結(jié)
- 作業(yè)區(qū)鐵路專用線工程項目可行性研究報告
- 金礦探礦權(quán)合作協(xié)議書范文范本
- 七年級下學期生物蘇教版電子教材
- 小學五年級美術(shù)《青花瓷》
評論
0/150
提交評論