flat assembler
Message board for the users of flat assembler.

Index > Windows > Fasm, DialogBox and Iczelion tut. 10

Author
Thread Post new topic Reply to topic
polygon7



Joined: 14 Aug 2003
Posts: 62
Location: Poznan, Poland
polygon7 28 Aug 2004, 19:38
Hi,
i try to make program which have dialogbox with icons
(like that one in Iczelion tut. 10), but i have problem with
"CreateDialogParam" function. It returns 0 and i dont know why.

Could anybody look into source code and *.res file and tell me what is wrong?


Description:
Download
Filename: Sprzataczka.zip
Filesize: 6.55 KB
Downloaded: 408 Time(s)


_________________
best regards
p7
Post 28 Aug 2004, 19:38
View user's profile Send private message Visit poster's website Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 29 Aug 2004, 05:35
You never passed the id of the dialog, how would u expect the dialog to be created?
Post 29 Aug 2004, 05:35
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
polygon7



Joined: 14 Aug 2003
Posts: 62
Location: Poznan, Poland
polygon7 29 Aug 2004, 07:47
roticv wrote:
You never passed the id of the dialog, how would u expect the dialog to be created?


From Iczelion tut. 10:
Code:
ClassName db "DLGCLASS",0
MenuName db "MyMenu",0
DlgName db "MyDialog",0

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
      LOCAL wc:WNDCLASSEX
     LOCAL msg:MSG
   LOCAL hDlg: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,DLGWINDOWEXTRA
  push  hInst
 pop   wc.hInstance
  mov   wc.hbrBackground,COLOR_BTNFACE+1
      mov   wc.lpszMenuName,OFFSET MenuName
       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 CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL
      mov   hDlg,eax
      invoke GetDlgItem,hDlg,IDC_EDIT
     invoke SetFocus,eax     
    INVOKE ShowWindow, hDlg,SW_SHOWNORMAL
       INVOKE UpdateWindow, hDlg
   .WHILE TRUE
                INVOKE GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax)
                invoke IsDialogMessage, hDlg, ADDR msg
                .if eax==FALSE
                        INVOKE TranslateMessage, ADDR msg
                        INVOKE DispatchMessage, ADDR msg
                .endif
     .ENDW
       mov     eax,msg.wParam
      ret
WinMain endp
    


There is no id of dialog, there is only name.

_________________
best regards
p7
Post 29 Aug 2004, 07:47
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 29 Aug 2004, 08:27
The procedure you provide for the class is not DialogProc, it is WindowProc, so you should follow the rules of standard window procedure, replace it with something like:
Code:
proc MainDialogProc,hwnddlg,msg,wparam,lparam
        push    ebx esi edi
        cmp     [msg],WM_CREATE
        je      .wmcreate
        cmp     [msg],WM_COMMAND
        je      .wmcommand
        cmp     [msg],WM_CLOSE
        je      .wmclose
        cmp     [msg],WM_DESTROY
        je      .wmdestroy
  .default:
        invoke  DefWindowProc,[hwnddlg],[msg],[wparam],[lparam]
        jmp     .finish
  .wmcreate:
        mov     eax,FILE_ATTRIBUTE_DIRECTORY
        mov     [DirAttr1],eax
        mov     [DirAttr2],eax
        mov     eax,TRUE
        jmp     .finish
  .wmcommand:
        cmp     [wparam],BN_CLICKED shl 16 + ID_CANCEL
        je      .wmclose
        ; ...
  .wmclose:
        invoke  DestroyWindow,[hwnddlg]
        jmp     .finish
  .wmdestroy:
        invoke  PostQuitMessage,0
  .finish:
        pop     edi esi ebx
        return
endp    

and it should work.
Post 29 Aug 2004, 08:27
View user's profile Send private message Visit poster's website Reply with quote
polygon7



Joined: 14 Aug 2003
Posts: 62
Location: Poznan, Poland
polygon7 29 Aug 2004, 09:51
Privalov wrote:
(...) and it should work.


Yes, thats work. Big thanks Very Happy

_________________
best regards
p7
Post 29 Aug 2004, 09:51
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.