;_________________________________________________________________________________________________ ; ; Heinz - Volker Viehof (c) 2006 ; Assembler Test - , Demo - und Beispieldateien ; Erzeug Fenster und Button , fängt WM_MESSAGE ab ;_________________________________________________________________________________________________ .386 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include analize.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD RegisterWinClass PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD MsgLoop PROTO :DWORD Static PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD ;_________________________________________________________________________________________________ ; ; Daten (initialisiert) ; ;_________________________________________________________________________________________________ .data szCaption db"HVV Assembler Fenster Demo",0 szClassName db"My_Class",0 szText7 db "--Test--",0 szEnde db "--Ende--",0 szText10 db "Heinz - Volker Viehof ",10,13,"Test - und DemoSoftware",0 btnClass db "BUTTON",0 btnClass3 db "STATIC" ;_________________________________________________________________________________________________ ; ; nicht initialisierte Daten ; ;_________________________________________________________________________________________________ .data? hInstance dd ? hIcon dd ? hCursor dd ? hWnd dd ? hbutt dd ? hSelf dd ? hStat1 dd ? hStat2 dd ? hEnde dd ? ;_________________________________________________________________________________________________ ; ; Programm (Hauptteil) ; ;_________________________________________________________________________________________________ .code start: call Init call Main invoke ExitProcess,eax ;_________________________________________________________________________________________________ ; ; Subroutinen ; ;_________________________________________________________________________________________________ Init proc invoke GetModuleHandle, NULL mov hInstance, eax invoke LoadIcon,hInstance,IDI_APPLICATION mov hIcon, eax invoke LoadCursor,NULL,IDC_ARROW mov hCursor, eax ret Init endp Main proc LOCAL Wwd:DWORD,Wht:DWORD,Wtx:DWORD,Wty:DWORD mov Wtx,10 ;x koordinate oben links mov Wty,10 ;y koordinate oben links mov Wwd,280 ;+x= unten rechts mov Wht,200+100 ;+y= unten rechts invoke RegisterWinClass,ADDR WndProc,ADDR szClassName,hIcon,hCursor,COLOR_BTNFACE+3 invoke CreateWindowEx,WS_EX_CONTEXTHELP,ADDR szClassName,ADDR szCaption, WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,NULL,NULL,hInstance,NULL mov hWnd,eax invoke Static,ADDR szText10,hWnd,40,20,180,40,500 mov hStat1, eax invoke PushButton,ADDR szText7,hWnd,40,80,180,25,600 mov hSelf,eax invoke PushButton,ADDR szEnde,hWnd,40,240,180,25,999 mov hEnde,eax invoke Static,ADDR puffer,hWnd,40,120,180,100,501 mov hStat2,eax invoke ShowWindow,hWnd, SW_SHOWNORMAL invoke UpdateWindow,hWnd invoke MsgLoop,0 ret Main endp m2m MACRO M1, M2 push M2 pop M1 ENDM ;_________________________________________________________________________________________________ ; ; andere Unterprogramme ; ;_________________________________________________________________________________________________ RegisterWinClass proc lpWndProc:DWORD,lpClassName:DWORD,Icon:DWORD,Cursor:DWORD, bColor:DWORD LOCAL wc:WNDCLASSEX mov wc.cbSize, sizeof WNDCLASSEX mov wc.style, CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW m2m wc.lpfnWndProc, lpWndProc mov wc.cbClsExtra, NULL mov wc.cbWndExtra, NULL m2m wc.hInstance, hInstance m2m wc.hbrBackground, bColor mov wc.lpszMenuName, NULL m2m wc.lpszClassName, lpClassName m2m wc.hIcon, Icon m2m wc.hCursor, Cursor m2m wc.hIconSm, Icon invoke RegisterClassEx,ADDR wc ret RegisterWinClass endp ;_________________________________________________________________________________________________ ; ; Message Loop ;_________________________________________________________________________________________________ MsgLoop proc hMSG:DWORD LOCAL msg:MSG StartLoop: call analyse_init invoke GetMessage,ADDR msg,0,0,0 .if eax == 0 jmp ExitLoop .endif invoke GetMessage,ADDR msg,hMSG,0,0 .if msg.wParam != 0200h .if msg.message == 0201h invoke Beep ,1000,50 .endif invoke analyse_main,msg.hwnd invoke analyse_main,msg.message invoke analyse_main,msg.wParam invoke analyse_main,msg.lParam invoke analyse_main,msg.time mov edi,dword ptr[myPointer] mov al,0 stosb invoke SetWindowText,hStat2,addr puffer .endif invoke DispatchMessage ,ADDR msg jmp StartLoop ExitLoop: mov eax, msg.wParam ret MsgLoop endp ;_________________________________________________________________________________________________ WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD .if uMsg == WM_DESTROY invoke PostQuitMessage,NULL mov eax, 0 ret .elseif wParam == 999 invoke PostQuitMessage,0 .endif invoke DefWindowProc,hWin,uMsg,wParam,lParam ret WndProc endp ;_________________________________________________________________________________________________ PushButton proc lpText:DWORD,hParent:DWORD, a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,ID:DWORD invoke CreateWindowEx,0, ADDR btnClass,lpText, WS_CHILD or WS_VISIBLE or BS_PUSHBUTTON or BS_NOTIFY, a,b,wd,ht,hParent,ID, hInstance,NULL ret PushButton endp ;_________________________________________________________________________________________________ Static proc lpText:DWORD,hParent:DWORD, a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,ID:DWORD invoke CreateWindowEx,WS_EX_STATICEDGE, ADDR btnClass3,lpText, WS_CHILD or WS_VISIBLE, a,b,wd,ht,hParent,ID, hInstance,NULL ret Static endp end start