Ancien code - CreateWindowEx ne fonctionne pas

TehWan Messages postés 8 Date d'inscription vendredi 24 octobre 2003 Statut Membre Dernière intervention 26 octobre 2003 - 26 oct. 2003 à 02:44
TehWan Messages postés 8 Date d'inscription vendredi 24 octobre 2003 Statut Membre Dernière intervention 26 octobre 2003 - 26 oct. 2003 à 05:28
Je ne comprends vraiment pas pourquoi CreateWindowEx ne fonctionne pas. Je code en ancien code avec MASM32. J'ai même essayé la nouvelle syntaxe (invoke) et cela ne fonctionne pas plus. Peut-être que le code va vous en dire plus...

.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib

    .data?
        msg MSG <?>
        wc WNDCLASS <?>

    .data
        hWnd dword 0
        hInstance dword 0

        hWin dword 0
        uMsg dword 0
        lParam dword 0
        wParam dword 0

        szDisplayName byte "Wolf Rules", 0
        szClassName byte "Wolf", 0

    .code
start:
;WinMain
    push 0
    call GetModuleHandle
    mov hInstance, eax

    mov wc.style, CS_HREDRAW or CS_VREDRAW
    lea eax, WndProc
    mov wc.lpfnWndProc, eax
    mov wc.cbClsExtra, 0
    mov wc.cbWndExtra, 0
    mov wc.lpszMenuName, 0
    lea eax, szClassName
    mov wc.lpszClassName, eax
    push hInstance
    pop wc.hInstance

    push 0
    call CreateSolidBrush
    mov wc.hbrBackground, eax

    push IDI_APPLICATION
    push 0
    call LoadIcon
    mov wc.hIcon, eax

    push IDC_ARROW
    push 0
    call LoadCursor
    mov wc.hCursor, eax

    lea eax, wc
    push eax
    call RegisterClass

    push 0
    push hInstance
    push 0
    push 0
    push 600
    push 800
    push 0
    push 0
    push WS_OVERLAPPED or WS_VISIBLE
    lea eax, szDisplayName
    push eax
    lea eax, szClassName
    push eax
    push WS_EX_WINDOWEDGE
    call CreateWindowEx
    mov hWnd, eax

    push SW_SHOW
    push hWnd
    call ShowWindow

    push hWnd
    call UpdateWindow

StartLoop:
    push 0
    push 0
    push 0
    lea eax, msg
    push eax
    call GetMessage

    cmp eax, 0
    je ExitLoop

    lea eax, msg
    push eax
    call TranslateMessage

    lea eax, msg
    push eax
    call DispatchMessage

    jmp StartLoop

ExitLoop:
    mov eax, msg.wParam
    ret
;WinMain End

WndProc:
    mov eax, [esp+4]
    mov hWnd, eax

    mov eax, [esp+8]
    mov uMsg, eax

    mov eax, [esp+12]
    mov wParam, eax

    mov eax, [esp+16]
    mov lParam, eax

    cmp uMsg, WM_CREATE
    je _CREATE

    cmp uMsg, WM_DESTROY
    je _DESTROY

    cmp uMsg, WM_COMMAND
    je _COMMAND

    jmp _END

_CREATE:
    push hWin
    pop hWnd
    jmp _END

_DESTROY:
    push 0
    call PostQuitMessage
    jmp _END

_COMMAND:
    mov eax, wParam
    jmp _END

_END:
    push lParam
    push wParam
    push uMsg
    push hWin
    call DefWindowProc
    ret
;WndProc End

end start


Avec des compares (cmp) et des jumps (je et jmp), j'ai pu déterminer ce qui ne fonctionnait pas. Pourtant, CreateWindowEx fonctionnait plus tôt. Pourriez-vous me dire ce qui ne fonctionne pas dans mon code? Merci.

-- Wolf --

NB: Je ne veux pas être méchant mais les débutants qui vont me dire que je n'ai pas de procédure ou que c'est à cause du déroulement linéaire feraient mieux de retourner étudier les bases du assembly.

1 réponse

TehWan Messages postés 8 Date d'inscription vendredi 24 octobre 2003 Statut Membre Dernière intervention 26 octobre 2003
26 oct. 2003 à 05:28
Je l'ai trouvé! Dans le WndProc, simplement changer
mov hWnd, eax
pour
mov hWin, eax

-- Wolf --
0
Rejoignez-nous