Hi folks
Another win32asm newbie here, and this one is struggling with part 10 of the tutorial.
Basically, the example source files 10-1 and 10-2 will assemble but will not run properly, although the included exe files did work.
With tut10-1 the assembled exe runs, but produces no window and does not exit.
I took the liberty of making a few additions to the supplied source, in the way of some error checking after the API calls and found this mofication....
(I'll just post the relevant bits)
.data
ClassName db "DLGCLASS",0
MenuName db "MyMenu",0
DlgName db "MyDialog",0
AppName db "Our First Dialog Box",0
TestString db "Wow! I'm in an edit box now",0
MsgCaption db "Error",0
MsgBoxClassErr db "Failed Registering class",0
cdpErr db "Failed Create Dialog Param",0
HinstanceErr db "The Hinstance is invalid",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
.IF eax==0
invoke MessageBox, NULL,addr MsgBoxClassErr, addr MsgCaption, MB_OK
invoke ExitProcess,NULL
mov eax,0
ret
.ENDIF
invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL
mov hDlg,eax
.IF eax==0
invoke MessageBox, NULL,addr cdpErr, addr MsgCaption, MB_OK
invoke ExitProcess,NULL
mov eax,0
ret
.ENDIF
........ produced a message box telling me that CreateDialogParam has failed (which explains the lack of a window on screen!)
But that's as far as I can get, I just can't understand why the call has failed, the two parameters passed to the call seem perfectly valid to me. I made some mods to prove hinstance is valid (not null) and the other param is just the address of a zero terminated string.
I did find a problem in the .rc file where IDM_EXIT equ 32002 did not match the value in the .rc file and I fixed that but still the program will not run :roll:
So what's the big deal here? Can anyone help to un-confuse me??
I feel confident with the assembler side of things (I used to program a lot of assembler on my Amiga in the 90s) but I seem to be struggling with the win32 API side of things which appears to me like a big black hole with no way to understand what is actually happening inside it. :shock:
I can't get tut10-2 to work either, it appears to just exit. From what I can see, DlgProc never receives any messages.
I'm working under winXP if that is relevant.
dicky
Another win32asm newbie here, and this one is struggling with part 10 of the tutorial.
Basically, the example source files 10-1 and 10-2 will assemble but will not run properly, although the included exe files did work.
With tut10-1 the assembled exe runs, but produces no window and does not exit.
I took the liberty of making a few additions to the supplied source, in the way of some error checking after the API calls and found this mofication....
(I'll just post the relevant bits)
.data
ClassName db "DLGCLASS",0
MenuName db "MyMenu",0
DlgName db "MyDialog",0
AppName db "Our First Dialog Box",0
TestString db "Wow! I'm in an edit box now",0
MsgCaption db "Error",0
MsgBoxClassErr db "Failed Registering class",0
cdpErr db "Failed Create Dialog Param",0
HinstanceErr db "The Hinstance is invalid",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
.IF eax==0
invoke MessageBox, NULL,addr MsgBoxClassErr, addr MsgCaption, MB_OK
invoke ExitProcess,NULL
mov eax,0
ret
.ENDIF
invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL
mov hDlg,eax
.IF eax==0
invoke MessageBox, NULL,addr cdpErr, addr MsgCaption, MB_OK
invoke ExitProcess,NULL
mov eax,0
ret
.ENDIF
........ produced a message box telling me that CreateDialogParam has failed (which explains the lack of a window on screen!)
But that's as far as I can get, I just can't understand why the call has failed, the two parameters passed to the call seem perfectly valid to me. I made some mods to prove hinstance is valid (not null) and the other param is just the address of a zero terminated string.
I did find a problem in the .rc file where IDM_EXIT equ 32002 did not match the value in the .rc file and I fixed that but still the program will not run :roll:
So what's the big deal here? Can anyone help to un-confuse me??
I feel confident with the assembler side of things (I used to program a lot of assembler on my Amiga in the 90s) but I seem to be struggling with the win32 API side of things which appears to me like a big black hole with no way to understand what is actually happening inside it. :shock:
I can't get tut10-2 to work either, it appears to just exit. From what I can see, DlgProc never receives any messages.
I'm working under winXP if that is relevant.
dicky
Just to rule out the obvious, did you build the resources? If you assemble and link the program without it's resources you'll get no error messages, but the program of course won't run.
Also, what's the error code from CreateDialogParam? Try out this code:
Also, what's the error code from CreateDialogParam? Try out this code:
invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL
mov hDlg,eax
.IF eax==0
.data?
szNumber db 20 dup (?)
.code
invoke GetLastError
invoke dwtoa,eax,offset szNumber
invoke MessageBox, NULL,offset szNumber, addr MsgCaption, MB_OK
invoke ExitProcess,NULL
mov eax,0
ret
I'm sure the obvious is where I'm going wrong.
I have a file in the folder with the dialog.asm called DIALOG.RC (and another called resource.h) if that is what you mean.... Not sure about "building the resources" though.
Basically I have taken the Iczelion tut 10-1 zip file, unzipped it and tried the included .exe file and that runs.
Then i have deleted the .exe file, opened the .asm file in Masm8 and tried to assemble the code "as provided"
I find the code will assemble but will not run as explained above. I've had a look at the .rc file with vc6 and I've also had a look at it with notepad. I don't know anything about building it. Is this where I am going wrong??
dicky
I have a file in the folder with the dialog.asm called DIALOG.RC (and another called resource.h) if that is what you mean.... Not sure about "building the resources" though.
Basically I have taken the Iczelion tut 10-1 zip file, unzipped it and tried the included .exe file and that runs.
Then i have deleted the .exe file, opened the .asm file in Masm8 and tried to assemble the code "as provided"
I find the code will assemble but will not run as explained above. I've had a look at the .rc file with vc6 and I've also had a look at it with notepad. I don't know anything about building it. Is this where I am going wrong??
dicky
Oh and I tried the above suggested test to find more about the error number.
I can imagine exactly what dwtoa does - but I can't assemble my program with that line.... masm says it is undefined....
Ahhh me thinks, it must be in some include file but which one?.... Nothing on MSDN so a quick search of the net get's me someone else's asm source code that uses dwtoa. Great so I add the includes that were in that source, and not already in my source
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
Then just when I thought I'd done something smart for once I find the program will still not assemble and I now get the error.
DIALOG.obj : error LNK2001: unresolved external symbol _dwtoa@8
DIALOG.exe : fatal error LNK1120: 1 unresolved externals
I thought I was fairly bright, but now I feel really dumb. Stuck yet again.
dicky :oops: :? :oops:
I can imagine exactly what dwtoa does - but I can't assemble my program with that line.... masm says it is undefined....
Ahhh me thinks, it must be in some include file but which one?.... Nothing on MSDN so a quick search of the net get's me someone else's asm source code that uses dwtoa. Great so I add the includes that were in that source, and not already in my source
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
Then just when I thought I'd done something smart for once I find the program will still not assemble and I now get the error.
DIALOG.obj : error LNK2001: unresolved external symbol _dwtoa@8
DIALOG.exe : fatal error LNK1120: 1 unresolved externals
I thought I was fairly bright, but now I feel really dumb. Stuck yet again.
dicky :oops: :? :oops:
Dialog boxes are usually stored as "resources", to do this you have to compile the file DIALOG.RC with RC.EXE that comes with masm32. If you're using QEditor, check out the menu item "Compile RC" (or something similar).
If there's a .bat file, you might want to check that out too. If I recall correctly some of Iczelion's tutorials came with a batch file to do the compiling.
The includes were a good idea :) not sure why it failed though. The dwtoa function is not an API, but part of the masm32.lib library, that's why you won't find it in MSDN.
If there's a .bat file, you might want to check that out too. If I recall correctly some of Iczelion's tutorials came with a batch file to do the compiling.
The includes were a good idea :) not sure why it failed though. The dwtoa function is not an API, but part of the masm32.lib library, that's why you won't find it in MSDN.
I don't see a dialog procedure. The create-dialog function needs one.
@tenkey
From what I understand of iczelion tutorial, thre are two sorts of dialog, modal and modeless - and one of them does not need a dialog procedure, and this example is the type that doesn't?
@qvasimodo
I'm sure you are on the right track to this problem, but I still can't sort it out. Let's just get back to the VERY basics because I am obviosly needing to learn more here to understand what is happening.
Right, I'm downloading this zip from Iczelion tutorial
When I unzip it I find the following files
DIALOG.ASM
DIALOG.EXE
DIALOG.RC
MAKEFILE
README.TXT
RESOURCE.H
Now if I run the DIALOG.EXE it works OK.
If I delete the DIALOG.EXE and then double click on the DIALOG.ASM it opens up in masm (Qedit)
If I then choose Project->Build All I get the following new files created
DIALOG.EXE
DIALOG.OBJ
This dialog.exe will not run (as explained above)
If I double click on DIALOG.RC it opens up in VC6 and I can look at the dialog box and menu. When I close VC6 this also automatically creates a file caled DIALOG.APS which seems to be a binary file. Another attempt at Project->Build All will still produce a non working exe file.
The other thing I tried is like you said, Project->Compile Resource File and that produces the following error message. It never asked me WHICH rc file I wanted to compile :?
---------------------------
Microsoft (R) Windows (R) Resource Compiler, Version 5.00.1823.1 - Build 1823
Copyright (C) Microsoft Corp. 1985-1998. All rights reserved.
Using codepage 1252 as default
Creating rsrc.RES
RC: RCPP -CP 1252 -f C:\masm32\tut10-1\RCa03640 -g C:\masm32\tut10-1\RDa0364
0 -DRC_INVOKED -D_WIN32 -pc\:/ -E -I. -I .
RC : fatal error RC1110 : could not open rsrc.rc
Microsoft (R) Windows Resource To Object Converter Version 5.00.1736.1
Copyright (C) Microsoft Corp. 1992-1997. All rights reserved.
CVTRES : fatal error CVT1101: cannot open rsrc.res for reading
Press any key to continue . . .
------------------------------
So back to the very very basics, could anyone explain what all these files are, and where I am going wrong?
Thanks for all the help so far though. Like I said I can handle the assembler programming side of things, it's this win32 related stuff that's frying my brains right now :P
dicky
From what I understand of iczelion tutorial, thre are two sorts of dialog, modal and modeless - and one of them does not need a dialog procedure, and this example is the type that doesn't?
@qvasimodo
I'm sure you are on the right track to this problem, but I still can't sort it out. Let's just get back to the VERY basics because I am obviosly needing to learn more here to understand what is happening.
Right, I'm downloading this zip from Iczelion tutorial
When I unzip it I find the following files
DIALOG.ASM
DIALOG.EXE
DIALOG.RC
MAKEFILE
README.TXT
RESOURCE.H
Now if I run the DIALOG.EXE it works OK.
If I delete the DIALOG.EXE and then double click on the DIALOG.ASM it opens up in masm (Qedit)
If I then choose Project->Build All I get the following new files created
DIALOG.EXE
DIALOG.OBJ
This dialog.exe will not run (as explained above)
If I double click on DIALOG.RC it opens up in VC6 and I can look at the dialog box and menu. When I close VC6 this also automatically creates a file caled DIALOG.APS which seems to be a binary file. Another attempt at Project->Build All will still produce a non working exe file.
The other thing I tried is like you said, Project->Compile Resource File and that produces the following error message. It never asked me WHICH rc file I wanted to compile :?
---------------------------
Microsoft (R) Windows (R) Resource Compiler, Version 5.00.1823.1 - Build 1823
Copyright (C) Microsoft Corp. 1985-1998. All rights reserved.
Using codepage 1252 as default
Creating rsrc.RES
RC: RCPP -CP 1252 -f C:\masm32\tut10-1\RCa03640 -g C:\masm32\tut10-1\RDa0364
0 -DRC_INVOKED -D_WIN32 -pc\:/ -E -I. -I .
RC : fatal error RC1110 : could not open rsrc.rc
Microsoft (R) Windows Resource To Object Converter Version 5.00.1736.1
Copyright (C) Microsoft Corp. 1992-1997. All rights reserved.
CVTRES : fatal error CVT1101: cannot open rsrc.res for reading
Press any key to continue . . .
------------------------------
So back to the very very basics, could anyone explain what all these files are, and where I am going wrong?
Thanks for all the help so far though. Like I said I can handle the assembler programming side of things, it's this win32 related stuff that's frying my brains right now :P
dicky
This might be silly but:
rsrc.rc is what resource compiler is looking for and DIALOG.RC is what you got. Try renaming dialog. rc to rsrc.rc and try again or change the commandline to use dialog.rc instead.
rsrc.rc is what resource compiler is looking for and DIALOG.RC is what you got. Try renaming dialog. rc to rsrc.rc and try again or change the commandline to use dialog.rc instead.
dicky96,
JimmyCliff is right, you need to rename dialog.rc to Rsrc.rc. After from the project option, you select "Compile resource file" and the "Assemble&link"
For resources, the only accepted name by qeditor is rsrc.rc.
JimmyCliff is right, you need to rename dialog.rc to Rsrc.rc. After from the project option, you select "Compile resource file" and the "Assemble&link"
For resources, the only accepted name by qeditor is rsrc.rc.
@jimmycliff
I can see that it is trying to compile rsrc.rc but it never gives me the choice of any other resourcefile to compile.
I have this other file in the folder called MAKEFILE which contains this
NAME=dialog
$(NAME).exe: $(NAME).obj $(NAME).res
Link /SUBSYSTEM:WINDOWS /VERSION:4.0 /LIBPATH:c:\masm32\lib $(NAME).obj $(NAME).res
$(NAME).res: $(NAME).rc
rc $(NAME).rc
$(NAME).obj: $(NAME).asm
ml /c /coff /Cp $(NAME).asm
but it's all gibberish to me, so if anyone could explain that......
I can see that it is trying to compile rsrc.rc but it never gives me the choice of any other resourcefile to compile.
I have this other file in the folder called MAKEFILE which contains this
NAME=dialog
$(NAME).exe: $(NAME).obj $(NAME).res
Link /SUBSYSTEM:WINDOWS /VERSION:4.0 /LIBPATH:c:\masm32\lib $(NAME).obj $(NAME).res
$(NAME).res: $(NAME).rc
rc $(NAME).rc
$(NAME).obj: $(NAME).asm
ml /c /coff /Cp $(NAME).asm
but it's all gibberish to me, so if anyone could explain that......
@Vortex
Thanks m8
Our posts crossed there, but I ried what you said and it works :-D
Was the Iczelion tutorial designed for a different assembler to MASM, hence this confusion?
Also if you or any other could explain what the MAKEFILE is for, and what the stuff in it means (or where I can read up on that stuff) then I would much appreciate that.
One last niggle remains.... the idea from qvasimodo about getting the error number and using dwtoa. I still get the error mentioned above about dwtoa@8 being an undeifined external if I leave that code in. I'd like to know why for future reference.
But a big Thanks to all who put up with me and helped with what must seem a simple question to most of you.
dicky 8)
Thanks m8
Our posts crossed there, but I ried what you said and it works :-D
Was the Iczelion tutorial designed for a different assembler to MASM, hence this confusion?
Also if you or any other could explain what the MAKEFILE is for, and what the stuff in it means (or where I can read up on that stuff) then I would much appreciate that.
One last niggle remains.... the idea from qvasimodo about getting the error number and using dwtoa. I still get the error mentioned above about dwtoa@8 being an undeifined external if I leave that code in. I'd like to know why for future reference.
But a big Thanks to all who put up with me and helped with what must seem a simple question to most of you.
dicky 8)
Hi,
You try compiling the files in the console (in DOS Prompt).
Thomas Antony :)
You try compiling the files in the console (in DOS Prompt).
Thomas Antony :)
It was designed for masm but you should be using makefiles for it to work properly... I am not very sure what makefile does, but I think it is something like a bat file.
<<Shameless proclaimation>>
Me uses RADasm as an ide. It could be found on KetilO's site (You can find him on this forum).
<<Shameless proclaimation>>
Me uses RADasm as an ide. It could be found on KetilO's site (You can find him on this forum).
Makefiles are (sort of) like bat files, only their "language" was specifically designed for compiling sources. I think MASM comes with a makefile interpreter but I never use those, don't know much about them. :(
You surely want to try a better editor, like WinAsm (my personal favorite for MASM), and it's big brother RadAsm (supports multiple assembler flavors). :)
As for the dwtoa issue, maybe you have installed Masm32 in another folder (not \masm32 where it's expected). Try copying masm32.lib to \masm32\lib and see if that helps... :?:
You surely want to try a better editor, like WinAsm (my personal favorite for MASM), and it's big brother RadAsm (supports multiple assembler flavors). :)
As for the dwtoa issue, maybe you have installed Masm32 in another folder (not \masm32 where it's expected). Try copying masm32.lib to \masm32\lib and see if that helps... :?: