flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > WS_CHILD

Author
Thread Post new topic Reply to topic
mikado3333



Joined: 31 Oct 2015
Posts: 6
Location: Russian Federation
Hello! Here I tried to create a simple window number 1 (WS_VISIBLE + WS_DLGFRAME) on it the child window number 2 and button number 3. The parent of №2, №3 is №1. Button number 3 crosses the child window number 2. Button does not work! Why?

Code:
format PE GUI 4.0
entry start

include 'win32a.inc'

section '.data' data readable writeable
_class          db 'FASMWIN32',0
_class2         db 'FASMWIN32Child',0
_szClassb       db  'BUTTON',0
_title          db 'Пустое Окно',0
_error          db 'Ошибка',0
_text           db "close",0

wc              WNDCLASS 0,WindowProc,0,0,0,0,0,COLOR_BTNFACE+1,0,_class
wc2             WNDCLASS 0,ChildProc,0,0,0,0,0,COLOR_BTNFACE+1,0,_class2
msg             MSG

section '.code' code readable executable
start:
                invoke  GetModuleHandle, 0
                mov     [wc.hInstance], eax
                invoke  LoadIcon, 0, IDI_APPLICATION
                mov     [wc.hIcon], eax
                mov     [wc2.hIcon], eax
                invoke  LoadCursor, 0, IDC_ARROW
                mov     [wc.hCursor], eax
                mov     [wc2.hCursor], eax
                invoke  RegisterClass, wc
                cmp     eax, 0
                je              error

                invoke  RegisterClass, wc2
                cmp     eax, 0
                je              error
                
                invoke  CreateWindowEx, 0,_class,_title,WS_VISIBLE+WS_DLGFRAME+\
                                                WS_SYSMENU,128,128,256,192,0,0,[wc.hInstance],0
                cmp     eax, 0
                je              error
                mov             edi, eax
                
                
                invoke  CreateWindowEx, 0,_class,_title,WS_VISIBLE+WS_CHILD + WS_BORDER,10,10,200,150,edi,0,[wc.hInstance],0
                cmp eax, 0
                je      error
                
                invoke  CreateWindowEx,          0, _szClassb, _szClassb, WS_VISIBLE+WS_CHILD+\
                                                                                        BS_PUSHBUTTON, 10, 50, 100, 50, \
                                                                                        edi, 0,[wc.hInstance], 0
                
msg_loop:
                invoke GetMessage, msg, 0, 0, 0
                cmp    eax, 0
                je         end_loop
                invoke TranslateMessage, msg
                invoke DispatchMessage, msg
                jmp    msg_loop

error:  
                invoke MessageBox,0,_error,0,MB_ICONERROR+MB_OK
end_loop:
                invoke ExitProcess,[msg.wParam]

proc    WindowProc hwnd,wmsg,wparam,lparam
                push    ebx esi edi
                cmp     [wmsg], WM_DESTROY
                je              .wmdestroy
                
.defwndproc:
                invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
                jmp     .finish
.wmdestroy:
                invoke PostQuitMessage,0
                mov    eax, 0
.finish:
                pop edi esi ebx
ret
endp

proc    ChildProc hwnd,wmsg,wparam,lparam
                push    ebx esi edi
                cmp     [wmsg], WM_DESTROY
                je              .wmdestroy
                
.defwndproc:
                invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
                jmp     .finish
.wmdestroy:
                invoke MessageBox, 0, _text, 0,0
                jmp        .defwndproc
.finish:
                pop edi esi ebx
ret
endp


section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL'
include 'api\kernel32.inc'
include 'api\user32.inc'     
Post 23 May 2017, 13:03
View user's profile Send private message Reply with quote
CrawlUp



Joined: 23 May 2017
Posts: 8
Location: the USSR
Code:
 format PE GUI 4.0
entry start 

include 'win32a.inc' 

section '.data' data readable writeable
str_book        db 'Скачай книгу - Норсеев Сергей "Разработка оконных приложений на Fasme"',0
str_head        db 'Привет!',0
_class          db 'FASMWIN32',0 
_class2         db 'FASMWIN32Child',0 
_szClassb       db  'BUTTON',0 
_title          db 'Пустое Окно',0 
_error          db 'Ошибка',0 
_text           db "close",0
hButton         dd  ?


wc              WNDCLASS 0,WindowProc,0,0,0,0,0,COLOR_BTNFACE+1,0,_class
wc2             WNDCLASS 0,ChildProc,0,0,0,0,0,COLOR_BTNFACE+1,0,_class2

msg             MSG 

section '.code' code readable executable 
start: 
                invoke  GetModuleHandle, 0 
                mov     [wc.hInstance], eax 
                invoke  LoadIcon, 0, IDI_APPLICATION 
                mov     [wc.hIcon], eax
                mov     [wc2.hIcon], eax
                invoke  LoadCursor, 0, IDC_ARROW 
                mov     [wc.hCursor], eax
                mov     [wc2.hCursor], eax
                invoke  RegisterClass, wc 
                cmp     eax, 0 
                je              error
                invoke  RegisterClass, wc2
                cmp     eax, 0 
                je              error
                invoke  CreateWindowEx, 0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,0,0,[wc.hInstance],0
                cmp     eax, 0 
                je   error

                 
                 

msg_loop: 
                invoke GetMessage, msg, 0, 0, 0 
                cmp    eax, 0 
                je         end_loop 
                invoke TranslateMessage, msg 
                invoke DispatchMessage, msg 
                jmp    msg_loop 

error:   
                invoke MessageBox,0,_error,0,MB_ICONERROR+MB_OK 
end_loop: 
                invoke ExitProcess,[msg.wParam] 

proc    WindowProc hwnd,wmsg,wparam,lparam 
                push    ebx esi edi 
                cmp     [wmsg], WM_DESTROY 
                je    .wmdestroy
                cmp [wmsg],WM_CREATE
                je .create
                 
.defwndproc: 
                invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] 
                jmp     .finish
.create:
                 invoke  CreateWindowEx, 0,_class2,_title,WS_VISIBLE+WS_CHILD + WS_BORDER,10,10,200,150,[hwnd],0,[wc.hInstance],0
                 invoke  CreateWindowEx,0, _szClassb, _szClassb, WS_VISIBLE+WS_CHILD+BS_PUSHBUTTON, 10, 50, 100, 50,eax, 0,[wc.hInstance], 0
                 mov [hButton],eax
                 jmp  .finish
.wmdestroy:
                invoke PostQuitMessage,0 
                mov    eax, 0 
.finish: 
                pop edi esi ebx 
ret 
endp 
proc    ChildProc hwnd,wmsg,wparam,lparam
                push    ebx esi edi 
                cmp     [wmsg], WM_DESTROY 
                je    .wmdestroy
                cmp  [wmsg],WM_COMMAND
                je  .command
                 
.defwndproc: 
                invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] 
                jmp     .finish
.command:
                mov eax,[lparam];         обработка событий кнопки в lparam дескриптор
                cmp eax,[hButton]
                je .click
                jmp .finish
.click:
                invoke MessageBox,0,str_book,str_head,MB_OK
                jmp .finish
.wmdestroy: 
                invoke MessageBox, 0, _text, 0,0 
                jmp        .defwndproc 
.finish: 
                pop edi esi ebx 
ret 
endp 




section '.idata' import data readable writeable 
library kernel32,'KERNEL32.DLL',\ 
user32,'USER32.DLL' 
include 'api\kernel32.inc' 
include 'api\user32.inc' 
                                                                              

_________________
Use GoogleTranslate....
Post 23 May 2017, 15:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.