News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

problem assembling deckaration in windows app

Started by eeoam, October 14, 2007, 10:59:28 AM

Previous topic - Next topic

eeoam

I've writtten the following program:

***
include \masm32\include\masm32rt.inc


.data
  wnd_name BYTE "Windows App",0
  cls_name BYTE "Window0",0
  MainWin WNDCLASS <NULL, WinProc, NULL,NULL,NULL, NULL, NULL, COLOR_WINDOW, NULL, cls_name>
  msg     MSGStruct <>
  winRect RECT <>
  hMainWnd DWORD ?
  hInstance DWORD ?

.code
WinMain proc
      ; Get a handle to the current process
      INVOKE GetModuleHandle, NULL
      mov hInstance, eax
      mov MainWin.hInstance, eax

      ; Register the window class
      INVOKE RegisterClass, ADDR MainWin
     
      ; Create the application's main window
      INVOKE CreateWindowEx, 0, ADDR cls_name, ADDR wnd_name, NULL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL

      ; Save the window handle, show the window
      mov hMainWnd, eax
      INVOKE ShowWindow, hMainWnd, SW_SHOW
      INVOKE UpdateWindow, hMainWnd

      ; Begin the program's message loop
      Message_Loop:
        INVOKE GetMessage, ADDR msg, NULL, NULL, NULL

        .IF eax == 0
          jmp Exit_Program
        .ENDIF
       
        INVOKE DispatchMessage, ADDR msg
        jmp Message_Loop
     
     Exit_Program:
       INVOKE ExitProcess, 0
WinMain endp


WinProc PROC,
  hWnd:DWORD, localMsg:DWORD, wParam:DWORD, lParam:DWORD
 
  mov eax, localMsg
  .IF eax == WM_LBUTTONDOWN
    ret
  .ENDIF
WinProc ENDP
end WinMain

***

When i attempt to assemble it I get the following errors:

***
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: c:\asm\window0.asm
c:\asm\window0.asm(8) : error A2008: syntax error : msg
c:\asm\window0.asm(33) : error A2006: undefined symbol : msg
c:\asm\window0.asm(33) : error A2114: INVOKE argument type mismatch : argument :
1
c:\asm\window0.asm(39) : error A2006: undefined symbol : msg
c:\asm\window0.asm(39) : error A2114: INVOKE argument type mismatch : argument :
1
_
Assembly Error
***

It seems to be saying that something is wrong with the declaration of msg. But what could that be?

E.

Vortex


eeoam

Thanks! It assembles now! But when I try to run the program I get the message:

"window0.exe has encountered a problem and needs to close.  We are sorry for the inconvenience."

I can't see what I've done wrong...

E.

Vortex

I guess there is problem with the initialization of your variables, have a look at Iczelion's tutorial #3 to see an example :

.
.
.
.data
ClassName db "SimpleWinClass",0
AppName  db "Our First Window",0

.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.code
start:
invoke GetModuleHandle, NULL
mov    hInstance,eax
invoke GetCommandLine
mov    CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX      ; <----- structures here defined
LOCAL msg:MSG            ; <-----
LOCAL hwnd:HWND
.
.
.