I can assemble this just fine, but when I try and run the executable, it simply does nothing. Any help is greatly appreciated :). ;##################################################################################### ;cldcnt.asm - Creates an Edit and Button Control and places them on a window ;Author: Tim Soderstrom ;Date: January 2001 ;##################################################################################### .386 .model FLAT,STDCALL option casemap:none ;case-sensitive ;############################################################################################ WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD ;function prototypes ;############################################################################################ include \masm32\include\windows.inc ;constants and structure definitions include \masm32\include\kernel32.inc include \masm32\include\user32.inc includelib \masm32\lib\kernel32.lib ;function calls includelib \masm32\lib\user32.lib ;############################################################################################ ;############################################################################################ .DATA ;initialized data ClassName db "WinClass",0 ;main window class AppName db "Child Controls",0 ;main window caption MenuName db "MainMenu",0 ;name of the window's menu BtnClassName db "BUTTON",0 ;class name of the button BtnText db "Display Text",0 ;button's caption EdtClassName db "EDIT",0 ;class name of the edit box TestString db "This is a cheesy example of a edit box.",0 ;default text for edit box ;############################################################################################ .DATA? ;uninitialized data hInstance HINSTANCE ? hwndButton HWND ? ;handles to our child windows hwndEdit HWND ? buffer db 512 dup(?) ;buffer to store text in edit box ;menu structure ;############################################################################################ .CONST ;constants for the menu and window ID's ButtonID equ 1 EditID equ 2 IDM_SAYHELLO equ 1 IDM_CLREDT equ 2 IDM_GETTEXT equ 3 IDM_EXIT equ 4 ;############################################################################################ .CODE start: INVOKE GetModuleHandle,NULL ;get the instance handle of our window mov hInstance,eax INVOKE WinMain,hInstance,NULL,NULL,SW_SHOWNORMAL ;call the main function INVOKE ExitProcess,eax ;############################################################################################ WinMain PROC hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD LOCAL wc:WNDCLASSEX LOCAL msg:MSG LOCAL hwnd:HWND mov wc.cbSize,SIZEOF WNDCLASSEX ;fill the window stucture with needed values mov wc.style,CS_HREDRAW OR CS_VREDRAW mov wc.lpfnWndProc,OFFSET WndProc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL push hInst pop wc.hInstance INVOKE LoadIcon,hInst,500 ;load icon from the resource mov wc.hIcon,eax mov wc.hIconSm,eax INVOKE LoadCursor,hInst,IDC_ARROW mov wc.hCur
Posted on 2001-01-18 20:58:00 by Tim
This seems wrong to me: INVOKE LoadCursor,hInst,IDC_ARROW mov wc.hCursor,eax Unless you have a defined cursor in your resource file, you should use NULL instead of hInst. See if that doesn't give you better results. Oh, and for future reference, if the program doesn't do anything when you're creating a window, then the class didn't register, probably because of invalid data in the WNDCLASS or WNDCLASSEX structure. You should always perform a check to make sure the class is registered.
Posted on 2001-01-18 21:42:00 by Racso
Hi, No the problem doesn't come from the cursor because when there is one defined in the rc file, and if you don't have the rc file, it uses a standard cursor (like icon). The problem is that you create a window but you forgot to put the handle in hwnd so when you want it to be displayed with ShowWindow, hwnd,... the hwnd isn't the handle of your window, you must put "mov hwnd,eax" , just after the CreateWindowEx which define your window. Vom-bonjour:-()
Posted on 2001-01-18 22:04:00 by Vom-bonjour:-()
Actually, the RegisterClassEx failing is only one of many reasons not to see it. Was it created visible? Did the WinProc for WM_CREATE return zero? Is it there just fine, but off screen? Only 0 by 0 pixles large? Lots of stuff. Ya gotta have a way to narrow this down. Message Boxes can help for small general stuff like this. To watch a program under more dynamic condidions, you need a faster way to emit info. See my tut on Debugging Windows ASM applications at: here.is/COMinASM Some handy macro code to make lots of easy to use ways to get the app to talk back to you.
Posted on 2001-01-18 22:22:00 by Ernie
INVOKE CreateWindowEx,NULL,\ ;create the main window ADDR ClassName,\ ADDR AppName,\ WS_OVERLAPPEDWINDOW,\ 300,\ 300,\ 450,\ 200,\ NULL,\ NULL,\ hInst,\ NULL mov hwnd,eax ;!!!!! - you forgot to fill your hwnd ! INVOKE ShowWindow,eax,SW_SHOWNORMAL INVOKE UpdateWindow,hwnd =================== In fact you can make your code without the hwnd var. at all. You can change last three lines of pasted here code to: push eax INVOKE ShowWindow,eax,SW_SHOWNORMAL call UpdateWindow
Posted on 2001-01-18 23:08:00 by The Svin
Thanks for the replys :). I guess I did forget to fill the hwnd with the value from CreateWindowEx. Oh well, live and learn.
Posted on 2001-01-19 14:13:00 by Tim