flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > WS_CHILD

Author
Thread Post new topic Reply to topic
mikado3333



Joined: 31 Oct 2015
Posts: 6
Location: Russian Federation

WS_CHILD

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  GetModuleHandle0
                mov     [wc.hInstance], eax
                invoke  LoadIcon0IDI_APPLICATION
                mov     [wc.hIcon], eax
                mov     [wc2.hIcon], eax
                invoke  LoadCursor0IDC_ARROW
                mov     [wc.hCursor], eax
                mov     [wc2.hCursor], eax
                invoke  RegisterClasswc
                cmp     eax0
                je              error

                invoke  RegisterClasswc2
                cmp     eax0
                je              error
                
                invoke  CreateWindowEx0,_class,_title,WS_VISIBLE+WS_DLGFRAME+\
                                                WS_SYSMENU,128,128,256,192,0,0,[wc.hInstance],0
                cmp     eax0
                je              error
                mov             edieax
                
                
                invoke  CreateWindowEx0,_class,_title,WS_VISIBLE+WS_CHILD + WS_BORDER,10,10,200,150,edi,0,[wc.hInstance],0
                cmp eax0
                je      error
                
                invoke  CreateWindowEx,          0_szClassb_szClassbWS_VISIBLE+WS_CHILD+\
                                                                                        BS_PUSHBUTTON105010050, \
                                                                                        edi0,[wc.hInstance], 0
                
msg_loop:
                invoke GetMessagemsg000
                cmp    eax0
                je         end_loop
                invoke TranslateMessagemsg
                invoke DispatchMessagemsg
                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    eax0
.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 MessageBox0_text0,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: 6
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  GetModuleHandle0 
                mov     [wc.hInstance], eax 
                invoke  LoadIcon0IDI_APPLICATION 
                mov     [wc.hIcon], eax
                mov     [wc2.hIcon], eax
                invoke  LoadCursor0IDC_ARROW 
                mov     [wc.hCursor], eax
                mov     [wc2.hCursor], eax
                invoke  RegisterClasswc 
                cmp     eax0 
                je              error
                invoke  RegisterClasswc2
                cmp     eax0 
                je              error
                invoke  CreateWindowEx0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,0,0,[wc.hInstance],0
                cmp     eax0 
                je   error

                 
                 

msg_loop
                invoke GetMessagemsg000 
                cmp    eax0 
                je         end_loop 
                invoke TranslateMessagemsg 
                invoke DispatchMessagemsg 
                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  CreateWindowEx0,_class2,_title,WS_VISIBLE+WS_CHILD + WS_BORDER,10,10,200,150,[hwnd],0,[wc.hInstance],0
                 invoke  CreateWindowEx,0_szClassb_szClassbWS_VISIBLE+WS_CHILD+BS_PUSHBUTTON105010050,eax0,[wc.hInstance], 0
                 mov [hButton],eax
                 jmp  .finish
.wmdestroy:
                invoke PostQuitMessage,0 
                mov    eax0 
.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 MessageBox0_text0,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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2017, Tomasz Grysztar.