The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: nathanpc on October 10, 2009, 03:40:02 PM

Title: Error In DialogBoxParam
Post by: nathanpc on October 10, 2009, 03:40:02 PM
Hello,
I'm now learning how to develop graphical apps, but i'm getting a error when using DialogBoxParam, see my code:
.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comctl32.inc
include \masm32\include\winmm.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\winmm.lib

ID_BUTTON1 equ 201

.data
        hInstance   dd ?
        dlgname     db "MAINSCREEN",0


.data?
        icex INITCOMMONCONTROLSEX <> ;structure for Controls

.code

start proc
        invoke GetModuleHandle,NULL
        mov hInstance,eax
        mov icex.dwSize,sizeof INITCOMMONCONTROLSEX
        mov icex.dwICC,ICC_DATE_CLASSES
        invoke InitCommonControlsEx,ADDR icex
        invoke DialogBoxParam,hInstance,ADDR dlgname,0,ADDR Dialog,0
        invoke ExitProcess,eax
Ret
start EndP

Dialog proc hWin:DWORD, uMsg:DWORD, aParam:DWORD, bParam:DWORD
        .if uMsg == WM_COMMAND
                                    mov eax,aParam
               
                .if eax == ID_BUTTON1
                invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
                .endif
        .elseif uMsg == WM_CLOSE
                                invoke EndDialog,hWin,NULL
        .endif
        xor eax,eax
Ret
Dialog EndP
End start

And the compiler log:
D:\Masm32\Bin\ML /c /coff /Cp /nologo /I"D:\Masm32\Include" "D:\Test Dialog\test.asm"

Assembling: D:\Test Dialog\test.asm
D:\Test Dialog\test.asm(34) : error A2006: undefined symbol : Dialog
D:\Test Dialog\test.asm(34) : error A2114: INVOKE argument type mismatch : argument : 4

D:\Masm32\Bin\Link @"D:\Test Dialog\link.war"

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 "/LIBPATH:D:\Masm32\Lib" "D:\Test Dialog\test.obj" "D:\Test Dialog\test.res" "/OUT:D:\Test Dialog\test.exe"
LINK : fatal error LNK1181: cannot open input file "D:\Test Dialog\test.obj"

Make finished. 3 error(s) occured.


Best Regards,
Nathan Paulino Campos
Title: Re: Error In DialogBoxParam
Post by: PBrennick on October 10, 2009, 03:47:16 PM
You need to prototype that procedure.

Dialog PROTO :DWORD,:DWORD,:DWORD,:DWORD

Place that line right after your include statements. When you fix that error, the object file will be successfully created and the errors should disappear.

Paul
Title: Re: Error In DialogBoxParam
Post by: nathanpc on October 10, 2009, 09:14:50 PM
Thanks very much PBrennick! :)