flat assembler
Message board for the users of flat assembler.

Index > Windows > Problems in a new project (Win64 GUI)

Author
Thread Post new topic Reply to topic
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
Hi all!
I make the program - MMMM (Mandel Machine Movie Maker), BUT... I should begin from window design. So, I learned tthsqe's code, and tried to make the window. Yes, platform is 64-bit.

Code:
format PE64 GUI 4.0
entry Start

include 'win64axp.inc'
;include 'encoding\WIN1251.INC'

section '.code' code readable executable

Start:  push rbp
         sub rsp,16

        invoke  GetModuleHandle,0
           mov  [wc.hInstance],rax
           mov  [hInstance],rax
        invoke  LoadIcon,rax,17
           mov  [wc.hIcon],rax
        invoke  LoadCursor,0,IDC_ARROW
           mov  [wc.hCursor],rax
        invoke  RegisterClass,wc
          test  rax,rax
            jz  Error
        invoke  LoadMenu,[wc.hInstance],37
        invoke  CreateWindowEx,0,w_class,w_title,WS_VISIBLE+WS_OVERLAPPEDWINDOW,0,0,100,100,NULL,rax,[wc.hInstance],NULL
           mov  [hMainWindow],rax
          test  rax,rax
            jz  Error

proc WindowProc hwnd,wmsg,wparam,lparam
;                 WTF???
;          What I must write here???
;              Please, help!!!


Error:
        invoke MessageBox,NULL,w_error,NULL,MB_ICONERROR+MB_OK
section '.idata' import data readable writeable

     library kernel32,'KERNEL32.DLL',\
         user32,'USER32.DLL',\
         gdi32,'GDI32.DLL',\
         comctl,'COMCTL32.DLL',\
         comdlg32,'COMDLG32.DLL',\
         msvcrt,'MSVCRT.DLL'

     include 'api/kernel32.inc'
     include 'api/user32.inc'
     include 'api/gdi32.inc'

 import msvcrt,\
        sprintf,'sprintf'

 import comctl,\
        CreateStatusWindow,'CreateStatusWindowA',\
        InitCommonControlsEx, 'InitCommonControlsEx'

 import comdlg32,\
        GetOpenFileNameA,'GetOpenFileNameA',\
        GetSaveFileNameA,'GetSaveFileNameA',\
        ChooseColor,'ChooseColorA'


section '.data' data readable writeable
   wc WNDCLASS  0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class

align 1
   INIFileString rb 1024
   OpenFileString rb 1024

     w_title TCHAR 'Mandel Machine Movie Maker'
     w_class TCHAR 'MMMM'
     w_error TCHAR 'LOL, Startup failed =)'
align 8
  hInstance             dq ?
  hMainWindow           dq ?
section '.rsrc' resource data readable

     menu main_menu
     menuitem '&File',10,MFR_POPUP
     menuitem '&Open',11,IDM_LOAD    


What should I do with WindowProc? Help me, project is very big.

+ How to decompress file using deflate algorithm.


Last edited by SeryZone on 27 Nov 2014, 06:11; edited 1 time in total
Post 22 Nov 2014, 20:27
View user's profile Send private message Reply with quote
RIxRIpt



Joined: 18 Apr 2013
Posts: 50
RIxRIpt
Quote:
What should I do with WindowProc?

You can find an example in FASM\EXAMPLES\WIN64\TEMPLATE\TEMPLATE.ASM
Post 23 Nov 2014, 11:13
View user's profile Send private message Visit poster's website Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
Now, how to make mainmenu?

Code:
format PE64 GUI 5.0
entry start

include 'win64a.inc'

PROGRAM_WIDTH = 1280
PROGRAM_HEIGHT = 720

section '.text' code readable executable

  start:
        sub     rsp,8
        invoke  GetModuleHandle,0
        mov     [wc.hInstance],rax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc.hIcon],rax
        mov     [wc.hIconSm],rax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],rax
        invoke  RegisterClassEx,wc
        test    rax,rax
        jz      error

        invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,PROGRAM_WIDTH,PROGRAM_HEIGHT,NULL,NULL,[wc.hInstance],NULL
        test    rax,rax
        jz      error

  msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        cmp     eax,1
        jb      end_loop
        jne     msg_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  error:
        invoke  MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK

  end_loop:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc uses rbx rsi rdi, hwnd,wmsg,wparam,lparam

; Note that first four parameters are passed in registers,
; while names given in the declaration of procedure refer to the stack
; space reserved for them - you may store them there to be later accessible
; if the contents of registers gets destroyed. This may look like:
;       mov     [hwnd],rcx
;       mov     [wmsg],edx
;       mov     [wparam],r8
;       mov     [lparam],r9

        cmp     edx,WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc,rcx,rdx,r8,r9
        jmp     .finish
  .wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  .finish:
        ret

endp

section '.data' data readable writeable

  _title TCHAR 'Mandel Machine Movie Maker',0
  _class TCHAR 'MMMM',0
  _error TCHAR 'Startup failed. Hahahahaha',0

  wc WNDCLASSEX sizeof.WNDCLASSEX,0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class,NULL

  msg MSG

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL'

  include 'api\kernel32.inc'
  include 'api\user32.inc'

section '.rsrc' resource data readable


  menu main_menu
       menuitem '&File',0,MFR_POPUP
                menuitem '&Load...',10
                menuitem '&Close',11
                menuseparator
                menuitem 'E&xit',1,MFR_END
       menuitem '&Help',0,MFR_POPUP + MFR_END
                menuitem '&ABOUT...',12,MFR_END
    
Post 23 Nov 2014, 18:17
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 724
tthsqe
this is a lot of windows specific issue. you can find some examples on how to do this on this board.
options:
1) you can put the menu in the resource section and call LoadMenu before RegisterClass
2) manually create the menu in the winodwProc by api calls

I am familiar with 1) because it is easiest
Post 25 Nov 2014, 03:09
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
Go learn the Win32 API from TheForger, then come back to FASM later...
http://www.winprog.org/tutorial/
Post 25 Nov 2014, 03:29
View user's profile Send private message Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
bitshifter wrote:
Go learn the Win32 API from TheForger, then come back to FASM later...
http://www.winprog.org/tutorial/


And how to learn this? It fully English (My English is not amazing!!!) + I badly undertand C++. It is hard for me.
Post 25 Nov 2014, 16:54
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
@SeryZone There are many articles in Russian as well, for example here: http://wasm.ru/wault/

Read them carefully!

You know, without foreign languages you can't learn programming on decent level. (And especially assembler, where the literature is missing)
Post 25 Nov 2014, 17:27
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
How to apply MultiSelect for Open dialog???

Code:
  .openseq:
        mov     dword[of.lStructSize],sizeof.OPENFILENAME
        mov     dword[of.lpstrFile],OFN_ALLOWMULTISELECT ;that's is not correctly
        mov     dword[of.lpstrFile],OpenFileString
        mov     dword[of.nMaxFile],1024
        invoke  GetOpenFileNameA,of
        test    rax,rax
        jz      .returnz
        invoke  CreateFileA,OpenFileString,GENERIC_READ,0,0,OPEN_EXISTING,0,0
        mov     r15,rax
        test    rax,rax
        jz      .returnz     
Post 26 Nov 2014, 23:11
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> + How to decompress file using deflate algorithm.

3 options:

0. use ZLIB.DLL
1. implement it natively
2. find some C code, compile and include into your program

Please open a separate thread about Deflate.

> It fully English (My English is not amazing!!!) + I badly
> undertand C++. It is hard for me.

Indeed it's hard to learn programming without English.

Moving this from "Main" into "Windows".
Post 01 Dec 2014, 03:01
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-2020, Tomasz Grysztar.

Powered by rwasa.