Уроки Iczelion'а



         

Урок 20. Сабклассинг окна - часть 3


Пpимеp:

.386 .model flat,stdcall option casemap:none include \masm32\include\windows.inc

include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\comctl32.inc includelib \masm32\lib\comctl32.lib

includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib

WinMain pROTO :DWORD,:DWORD,:DWORD,:DWORD EditWndproc pROTO :DWORD,:DWORD,:DWORD,:DWORD

.data ClassName db "SubclassWinClass",0 AppName db "Subclassing Demo",0 EditClass db "EDIT",0

Message db "You pressed Enter in the text box!",0

.data?

hInstance HINSTANCE ? hwndEdit dd ? OldWndproc dd ?

.code start: invoke GetModuleHandle, NULL

mov hInstance,eax invoke WinMain, hInstance,NULL,NULL, SW_SHOWDEFAULT invoke Exitprocess,eax

WinMain proc hInst:HINSTANCE,hprevInst:HINSTANCE,CmdLine:LpSTR,CmdShow:DWORD LOCAL wc:WNDCLASSEX

LOCAL msg:MSG LOCAL hwnd:HWND mov wc.cbSize,SIZEOF WNDCLASSEX mov wc.style, CS_HREDRAW or CS_VREDRAW

mov wc.lpfnWndproc, OFFSET Wndproc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL push hInst

pop wc.hInstance mov wc.hbrBackground,COLOR_AppWORKSpACE mov wc.lpszMenuName,NULL mov wc.lpszClassName,OFFSET ClassName

invoke LoadIcon,NULL,IDI_AppLICATION mov wc.hIcon,eax mov wc.hIconSm,eax invoke LoadCursor,NULL,IDC_ARROW

mov wc.hCursor,eax invoke RegisterClassEx, addr wc invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR ClassName,ADDR AppName,\ WS_OVERLAppED+WS_CApTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_VISIBLE

CW_USEDEFAULT,350,200,NULL,NULL,\ hInst,NULL mov hwnd,eax .while TRUE

invoke GetMessage, ADDR msg,NULL,0,0 .BREAK .IF (!eax) invoke TranslateMessage, ADDR msg invoke DispatchMessage, ADDR msg

.endw mov eax,msg.wparam ret WinMain endp

Wndproc proc hWnd:HWND, uMsg:UINT, wparam:WpARAM, lparam:LpARAM .if uMsg==WM_CREATE

invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR EditClass,NULL,\ WS_CHILD+WS_VISIBLE+WS_BORDER,20,\ 20,300,25,hWnd,NULL,\ hInstance,NULL

mov hwndEdit,eax invoke SetFocus,eax ;----------------------------------------- ; Subclass it!




Содержание  Назад  Вперед