mikado3333
Joined: 31 Oct 2015
Posts: 7
Location: Russian Federation
|
Hello! I'm from russia, so sorry for my english!
I created a window "My message box". Working!
locals
hFont dd 0
hWindow dd ?
stMSG MSG
stRC RECT
stWCM WNDCLASS 0,MyModalProc,0,0,0,0,0,COLOR_BTNHIGHLIGHT,0,.class
stWC WNDCLASS 0,MyNoModalProc,0,0,0,0,0,COLOR_BTNHIGHLIGHT,0,.class2
endl
styleEdit equ WS_CHILD+WS_VISIBLE+ES_AUTOVSCROLL+ES_READONLY+ES_MULTILINE+WS_VSCROLL
push esi edi ebx
lea edi, [stWC]
mov esi, .class2
cmp [modal], 0
jz @f
lea edi, [stWCM]
mov esi, .class
@@: invoke FindWindow, esi, 0
cmp eax,0
jnz @f
INVOKE GetModuleHandle, [edi + WNDCLASS.hInstance], 0
INVOKE LoadIcon, [edi + WNDCLASS.hIcon], 0, IDI_EXCLAMATION
INVOKE LoadCursor, [edi + WNDCLASS.hCursor], 0, IDC_ARROW
invoke RegisterClass, edi
cmp eax,0
jz .error
@@: mov edx, .title
cmp [zagalovok], 0
cmovne edx, [zagalovok]
INVOKE CreateWindowEx, [hWindow], 0, esi, edx, WS_VISIBLE+WS_OVERLAPPEDWINDOW,\
128, 128, 500, 200, 0, 0, [edi + WNDCLASS.hInstance],0
cmp eax,0
jz .error
lea ebx, [stRC]
invoke GetClientRect, [hWindow], ebx
INVOKE CreateWindowEx, edi, WS_EX_CLIENTEDGE, .edit, [text], styleEdit, 0,\
0,[ebx + RECT.right],[ebx + RECT.bottom],[hWindow],0,\
[edi + WNDCLASS.hInstance],0
cmp eax,0
jz .error
INVOKE CreateFont, [hFont], 18, 0, 0, 0, 500, 0, 0, 0,DEFAULT_CHARSET,\
OUT_DEFAULT_PRECIS ,CLIP_DEFAULT_PRECIS,\
PROOF_QUALITY, FIXED_PITCH + FF_DONTCARE, .FontName
cmp eax,0
jz .error
invoke SendMessage, edi, WM_SETFONT, [hFont], 1
cmp [modal], 0
jz .exit
lea ebx,[stMSG]
.msg_loop:
invoke GetMessage,ebx,0,0,0
cmp eax,0
je .exit
invoke TranslateMessage,ebx
invoke DispatchMessage,ebx
jmp .msg_loop
.exit: mov eax, [hWindow]
mov edx, edi
pop ebx edi esi
clc
ret
.error: invoke DeleteObject, [hFont]
pop ebx edi esi
stc
ret
.title db "Информация",0
.class db 1,0
.class2 db 2,0
.edit db 'EDIT',0
.FontName db "Courier New",0
endp
proc MyModalProc hwnd,wmsg,wparam,lparam
locals
class db 1,0
edit db 'EDIT',0
rc RECT
endl
push ebx esi edi
cmp [wmsg],WM_CLOSE
jz .close
cmp [wmsg],WM_SIZE
jz .size
cmp [wmsg],WM_DESTROY
jz .destroy
invoke DefWindowProc, [hwnd],[wmsg],[wparam],[lparam]
jmp .out
.close: invoke GetWindow, [hwnd], GW_CHILD
invoke SendMessage, eax, WM_GETFONT, 0, 0
invoke DeleteObject, eax
invoke DestroyWindow, [hwnd]
lea esi, [class]
invoke FindWindow, esi, 0
cmp eax,0
jnz .exit
invoke GetModuleHandle, 0
invoke UnregisterClass, esi, eax
jmp .exit
.destroy: invoke PostQuitMessage, 0
jmp .exit
.size: lea ebx, [rc]
invoke GetClientRect, [hwnd], ebx
lea eax, [edit]
invoke FindWindowEx, [hwnd], 0, eax, 0
invoke MoveWindow, eax, 0, 0, [ebx + RECT.right], [ebx + RECT.bottom], TRUE
.exit: mov eax, 0
.out: pop edi esi ebx
ret
endp
Working!
I'm Subclassing Edit Control in my program.
proc NewDlgProcEditTb hwnd,wmsg,wparam,lparam
push ebx esi edi
invoke GetParent, [hwnd]
invoke GetParent, eax
mov ebx, eax
cmp [wmsg], WM_CHAR
je .wmchar
cmp [wmsg], WM_KILLFOCUS
je .wmkillfocus
.def: invoke CallWindowProc, [pOldProcEdit], [hwnd], [wmsg], [wparam], [lparam]
jmp .out
.wmchar: cmp [wparam], VK_TAB
jnz .def
invoke SendMessage, ebx, WM_EDITTB, [hwnd], [wparam]
jmp .finish
.wmkillfocus: invoke SendMessage, ebx, WM_EDITTB, [hwnd], -1
jmp .finish
.finish: xor eax, eax
.out: pop edi esi ebx
ret
endp
Working! But I call
.KillFocus: invoke SendMessage, [wparam], WM_GETTEXTLENGTH, 0, 0
From DialogProc then "bugs" with Edit Control(Can not close window "MyMessage" and crush font) in "MyMessage Box"
If
.def: invoke CallWindowProc, [pOldProcEdit], [hwnd], [wmsg], [wparam], [lparam]
[b] jmp .finish[/b]
then working, but LENGTH = 0 (xor eax, eax).
|