well im extremely new to this, but my little test program wont actually appear. i've tried fiddling around with stuff for a couple of hours, but i work out whats wrong ------------------------------------------------------ ------------------------------------------------------ ------------------------------------------------------

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib        ;gdi atm for just GetStockObject

WinMain proto:DWORD,:DWORD,:DWORD,:DWORD

.DATA
ClassName db "wc1",0
WindowName db "MooCow",0

.DATA?
hMainWnd HINSTANCE ?
CommandLine LPSTR ?

.CODE
start:
invoke GetModuleHandle,NULL
mov hMainWnd,eax
invoke GetCommandLine
mov CommandLine, eax
invoke WinMain,hMainWnd,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_VREDRAW or CS_HREDRAW
    mov wc.lpfnWndProc, OFFSET WindowProc
    mov wc.cbClsExtra,NULL
    mov wc.cbWndExtra,NULL
    push hMainWnd
    pop wc.hInstance
    invoke GetStockObject,BLACK_BRUSH
    mov wc.hbrBackground, eax
    mov wc.lpszClassName, OFFSET ClassName
    mov wc.lpszMenuName, NULL
    invoke LoadIcon,NULL,IDI_APPLICATION
    mov wc.hIcon, eax
    invoke LoadCursor,NULL,IDC_ARROW
    mov wc.hCursor, eax
    mov wc.hIconSm, eax
    
    invoke RegisterClass, ADDR wc
    
    invoke CreateWindowEx, NULL, ADDR ClassName, ADDR WindowName\
    , WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT\
    , CW_USEDEFAULT, NULL, NULL, hMainWnd, NULL

    mov hWnd, eax
    
    invoke ShowWindow,hWnd,CmdShow          ; SW_SHOW dosnt seem to work?
    invoke UpdateWindow,hWnd

    .WHILE TRUE
        invoke GetMessage, ADDR msg,NULL,0,0
        .BREAK .IF (!eax)
        invoke TranslateMessage, ADDR msg
        invoke DispatchMessage, ADDR msg
    .ENDW

    ;---------------------------
    ; Real-time alternative to the loop above
    ; continually processing and not waiting for msgs
    ; good for games??
    ; dosnt work yet tho (havnt worked out the syntax)
    ; so for now its in C
    ;
    ; while(1)
    ; {
    ;    if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
    ;        {
    ;            if (msg.message == WM_QUIT) break;
    ;            TranslateMessage(&msg);
    ;            DispatchMessage(&msg);
    ;        }
    ;      // processing in here. goes thru messages than does game logic etc.
    ;  }
    ;--------------------------------------  
    
    mov eax,msg.wParam
    ret
    WinMain endp
    
WindowProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
    .IF uMsg == WM_DESTROY
        invoke PostQuitMessage,NULL
    .ELSE
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
        ret
    .ENDIF
    xor eax,eax
    ret
WindowProc endp
end start
Use
tags to disable smilies from destroying your code :) This message was edited by Hiroshimator, on 5/2/2001 5:53:13 AM
Posted on 2001-05-02 05:43:00 by Jester
Two things: 1) Change "push hMainWnd" to "push hInst", won't change anything, just "the right way to do it"! 2) Change "invoke RegisterClass, ADDR wc" to "invoke RegisterClassEx, ADDR wc" 2 is the REAL problem.... Mirno
Posted on 2001-05-02 07:34:00 by Mirno
ahh cheers but whats wrong with hMainWnd? :D
Posted on 2001-05-03 01:53:00 by Jester
In larger projects you will create many windows, some of which you will want to be children. By using hMainWnd, they will all be on the same level (not a child of some other window), where as if you use hWnd, then it depends on what you use in the call in "invoke WinMain,...". Not important in this example, but if you cut'n'paste it to a big project you'll tear your hair out when it doesn't work :D Mirno
Posted on 2001-05-03 05:25:00 by Mirno
made a c/c and changed invoke RegisterClassEx, ADDR wc and got this ther must be a big pb whith my includes \masm32\include\user32.inc(142) : error A2119: language type must be specified \masm32\include\user32.inc(143) : error A2119: language type must be specified
Posted on 2001-05-04 07:31:00 by franz
i made the change but it worked fine for me i dunno whats going on there
Posted on 2001-05-04 09:56:00 by Jester
Are you sure you've included the line: ".model flat, stdcall" As this tells the assembler the default function calling method. Mirno
Posted on 2001-05-04 10:29:00 by Mirno
made c/c but got 386 ant not .386 .386 <<
Posted on 2001-05-04 11:29:00 by franz