News:

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

Results of too much coding

Started by Magnum, December 17, 2010, 05:26:33 AM

Previous topic - Next topic

Magnum


; C:\masm32\SOURCE\Txt_From_HK.asm(27) : error A2006: undefined symbol : WinMa
;
; Txt_From_HK.asm

include \masm32\include\masm32rt.inc

.data

hglb dd 0 ; ',\ ; need space before quote
str1 db 'Ich habe keine Ahnung.'

ClassName db "DLGCLASS",0
DlgName db "MyDialog",0
AppName db "Hotkey Example",0
loaded db "Ctrl+Alt+A was pressed.",0
Voila db "PPPPP",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
LOCAL msg:MSG
LOCAL hWnd: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,NULL
push  hInst
pop   wc.hInstance
mov   wc.hbrBackground,COLOR_WINDOW+1
mov   wc.lpszMenuName,NULL
mov   wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov   wc.hIcon,eax
mov   wc.hIconSm,0
invoke LoadCursor,NULL,IDC_ARROW
mov   wc.hCursor,eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
          WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
          CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
          hInst,NULL
mov   hWnd,eax
INVOKE ShowWindow, hWnd,SW_SHOWNORMAL
INVOKE UpdateWindow, hWnd

.WHILE TRUE
               INVOKE GetMessage, ADDR msg,NULL,0,0
               .BREAK .IF (!eax)
               invoke IsDialogMessage, hWnd, ADDR msg
               .if eax==FALSE
                       INVOKE TranslateMessage, ADDR msg
                       INVOKE DispatchMessage, ADDR msg
               .endif
.ENDW
mov     eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
       
    .if uMsg==WM_CREATE
           invoke RegisterHotKey,hWnd,065h,MOD_CONTROL or MOD_ALT, 041h ; CTRL ALT A
     .ELSEIF uMsg==WM_DESTROY
           invoke UnregisterHotKey,hWnd,065h
invoke PostQuitMessage,NULL
     .ELSEIF uMsg == WM_HOTKEY

; OpenClipboard
; SetClipboardData
; CloseClipboard

; mov eax,wParam
;              .if eax==065h
;         invoke MessageBox,NULL, ADDR loaded,ADDR Voila,  MB_ICONEXCLAMATION
 
   ; Put text on the clipboard.
 
   invoke OpenClipboard,NULL
   .IF (eax)
     invoke EmptyClipboard
     invoke GlobalAlloc,GMEM_MOVEABLE,SIZEOF str1
     .IF (eax)
       mov hglb, eax
       invoke GlobalLock,hglb
         
       invoke MemCopy,ADDR str1,eax,SIZEOF str1
       invoke GlobalUnlock,hglb
       invoke SetClipboardData,CF_TEXT,hglb
         
       .IF (eax == 0)
         print "SetClipboardData failed",13,10
       .ENDIF

     .ELSE
       print "GlobalAlloc failed",13,10
     .ENDIF
     invoke CloseClipboard

   .ELSE
     print "OpenClipboard failed",13,10
   .ENDIF
   
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor    eax,eax
ret
WndProc endp

end start

Have a great day,
                         Andy

dedndave

had to add...
WinMain PROTO   :DWORD,:DWORD,:DWORD,:DWORD

and
        INVOKE  GlobalFree,hglb
to avoid memory leak

also - you may want to change the print's to MessageBox or something   :P