-
-
[求助]里面的功能怎么去实现它.
-
发表于: 2009-2-17 15:57 2879
-
;MASMPlus 代码模板 - 普通的 Windows 程序代码
.386
.Model Flat, StdCall
Option Casemap :None
Include windows.inc
Include user32.inc
Include kernel32.inc
Include gdi32.inc
includelib gdi32.lib
IncludeLib user32.lib
IncludeLib kernel32.lib
include macro.asm
.const
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
_IDDHD PROTO :DWORD,:DWORD,:DWORD,:DWORD
ButtonID equ 10
ButtonID1 equ 11
IDD_DLG1 equ 1000
.DATA
ClassName1 db "OPEN",0
szClassName db "MASMPlus_Class",0
.DATA?
hInstance dd ?
hButton dd ?
hButton1 dd ?
hDlg dd ?
;结构
wc WNDCLASSEX <>
ofn OPENFILENAME <>
.CODE
START:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke ExitProcess,0
WinMain proc hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
LOCAL msg :MSG
local hWnd :HWND
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,offset szClassName
invoke LoadIcon,hInst,100
mov wc.hIcon,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
mov wc.hIconSm,0
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx,NULL,ADDR szClassName,CTXT("Test主窗口"),WS_OVERLAPPEDWINDOW,200,200,600,400,NULL,NULL,hInst,NULL
mov hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke IsDialogMessage,hWnd,addr msg
.if eax == FALSE
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endif
jmp StartLoop
ExitLoop:
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWin:DWORD,uMsg:DWORD,wParam :DWORD,lParam :DWORD
.if uMsg==WM_CREATE
invoke CreateWindowEx,WS_EX_CLIENTEDGE,CTEXT("BUTTON"),CTEXT("tst"),WS_CHILD or WS_VISIBLE or WS_TABSTOP or BS_DEFPUSHBUTTON,\
100,100,50,50,\
hWin,\
ButtonID,\
hInstance,\
NULL
mov hButton,eax
.elseif uMsg == WM_COMMAND
mov eax,wParam
.if lParam == 0
.if ax == 188
invoke DialogBoxParam,hInstance,IDD_DLG1,hWin,addr WndProc,NULL
mov hDlg,eax
.elseif ax == IDOK
invoke EndDialog,addr hDlg,NULL
.endif
.else
.if ax == ButtonID
shr eax,16
.if ax == BN_CLICKED
invoke SendMessage,hWin,WM_COMMAND,188,0
.endif
.elseif ax == IDOK
invoke EndDialog,addr hDlg,NULL
.endif
.endif
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
.elseif uMsg == WM_CLOSE
invoke EndDialog,addr hDlg,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
.endif
ret
WndProc endp
_IDDHD proc hWinD:DWORD,uMsgD:DWORD,wParamD :DWORD,lParamD :DWORD
.if uMsgD == WM_DESTROY
invoke PostQuitMessage,NULL
.elseif uMsgD == WM_CLOSE
invoke EndDialog,IDD_DLG1,NULL
ret
.endif
ret
_IDDHD endp
END START
; .rc File
#include <resource.h>
#define IDD_DLG1 1000
IDD_DLG1 DIALOGEX 6,6,194,104
CAPTION "IDD_DLG"
FONT 8,"MS Sans Serif",0,0
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
BEGIN
CTEXT "简单的对话框", -1, 36, 14, 70, 19
DEFPUSHBUTTON "退出(&X)", IDOK, 58, 46, 50, 14
CONTROL "", -1, "Static", SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 6, 39, 103, 1
END
本来以为像别的程序 点击菜单 设置 出来的窗口是用 另外一个进程来实现的
后来发现都是一个程序内实现, 所以我就做实验,用CreateWindowEx来创建一个窗口,看能不能实现这个功能,发现不行, 就改用对话框了.
后来越来越糊涂,出现的问题我完全弄不出个头绪来,因为错误的可能太多了.做了多次改动都不能实现,而且资料也不齐全,现在正是学期阶段,这些问题也真够让我们这些新手着急
特来请教,希望各位大哥给我解疑,在此拜谢
.386
.Model Flat, StdCall
Option Casemap :None
Include windows.inc
Include user32.inc
Include kernel32.inc
Include gdi32.inc
includelib gdi32.lib
IncludeLib user32.lib
IncludeLib kernel32.lib
include macro.asm
.const
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
_IDDHD PROTO :DWORD,:DWORD,:DWORD,:DWORD
ButtonID equ 10
ButtonID1 equ 11
IDD_DLG1 equ 1000
.DATA
ClassName1 db "OPEN",0
szClassName db "MASMPlus_Class",0
.DATA?
hInstance dd ?
hButton dd ?
hButton1 dd ?
hDlg dd ?
;结构
wc WNDCLASSEX <>
ofn OPENFILENAME <>
.CODE
START:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke ExitProcess,0
WinMain proc hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
LOCAL msg :MSG
local hWnd :HWND
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,offset szClassName
invoke LoadIcon,hInst,100
mov wc.hIcon,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
mov wc.hIconSm,0
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx,NULL,ADDR szClassName,CTXT("Test主窗口"),WS_OVERLAPPEDWINDOW,200,200,600,400,NULL,NULL,hInst,NULL
mov hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke IsDialogMessage,hWnd,addr msg
.if eax == FALSE
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endif
jmp StartLoop
ExitLoop:
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWin:DWORD,uMsg:DWORD,wParam :DWORD,lParam :DWORD
.if uMsg==WM_CREATE
invoke CreateWindowEx,WS_EX_CLIENTEDGE,CTEXT("BUTTON"),CTEXT("tst"),WS_CHILD or WS_VISIBLE or WS_TABSTOP or BS_DEFPUSHBUTTON,\
100,100,50,50,\
hWin,\
ButtonID,\
hInstance,\
NULL
mov hButton,eax
.elseif uMsg == WM_COMMAND
mov eax,wParam
.if lParam == 0
.if ax == 188
invoke DialogBoxParam,hInstance,IDD_DLG1,hWin,addr WndProc,NULL
mov hDlg,eax
.elseif ax == IDOK
invoke EndDialog,addr hDlg,NULL
.endif
.else
.if ax == ButtonID
shr eax,16
.if ax == BN_CLICKED
invoke SendMessage,hWin,WM_COMMAND,188,0
.endif
.elseif ax == IDOK
invoke EndDialog,addr hDlg,NULL
.endif
.endif
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
.elseif uMsg == WM_CLOSE
invoke EndDialog,addr hDlg,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
.endif
ret
WndProc endp
_IDDHD proc hWinD:DWORD,uMsgD:DWORD,wParamD :DWORD,lParamD :DWORD
.if uMsgD == WM_DESTROY
invoke PostQuitMessage,NULL
.elseif uMsgD == WM_CLOSE
invoke EndDialog,IDD_DLG1,NULL
ret
.endif
ret
_IDDHD endp
END START
; .rc File
#include <resource.h>
#define IDD_DLG1 1000
IDD_DLG1 DIALOGEX 6,6,194,104
CAPTION "IDD_DLG"
FONT 8,"MS Sans Serif",0,0
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
BEGIN
CTEXT "简单的对话框", -1, 36, 14, 70, 19
DEFPUSHBUTTON "退出(&X)", IDOK, 58, 46, 50, 14
CONTROL "", -1, "Static", SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 6, 39, 103, 1
END
本来以为像别的程序 点击菜单 设置 出来的窗口是用 另外一个进程来实现的
后来发现都是一个程序内实现, 所以我就做实验,用CreateWindowEx来创建一个窗口,看能不能实现这个功能,发现不行, 就改用对话框了.
后来越来越糊涂,出现的问题我完全弄不出个头绪来,因为错误的可能太多了.做了多次改动都不能实现,而且资料也不齐全,现在正是学期阶段,这些问题也真够让我们这些新手着急
特来请教,希望各位大哥给我解疑,在此拜谢
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
- [求助]十分无赖的病毒。 6786
- [求助]奇异的定位 4051
- [分享]我们都很无奈! 2861
- [分享]你们是否同样苦恼。 3256
- [原创]缓冲区溢出核心原理。高手飘过!只适合不懂的人。 5974
看原图
赞赏
雪币:
留言: