Now the final part of the WinMain proc. 1.Actually you can use atom ID instead of pointer to class name. CreateWindow works much faster invoke RegisterClassEx,addr wc push eax ;save for future use atom ID Why it works faster - is very simple. First CreateWindowEx check if it's attom id or pointer to ClassName. If high word in lpClassName is 0 then it is an atom iD. Else - pointer. If it's a pointer API perform string comparasion wich is much slower then ID dword comparation in the case if it's an atom ID. 2. If none of your callback changes edi ebx esi you can use them in your loop wich make it shorter and faster. Now instead of this code:

        invoke RegisterClassEx, ADDR wc

        ;================================
        ; Centre window at following size
        ;================================

        mov Wwd, 500
        mov Wht, 350

        invoke GetSystemMetrics,SM_CXSCREEN
        invoke TopXY,Wwd,eax
        mov Wtx, eax

        invoke GetSystemMetrics,SM_CYSCREEN
        invoke TopXY,Wht,eax
        mov Wty, eax

        szText szClassName,"Template_Class"

        invoke CreateWindowEx,WS_EX_LEFT,
                              ADDR szClassName,
                              ADDR szDisplayName,
                              WS_OVERLAPPEDWINDOW,
                              Wtx,Wty,Wwd,Wht,
                              NULL,NULL,
                              hInst,NULL
        mov   hWnd,eax

        invoke LoadMenu,hInst,600  ; menu ID
        invoke SetMenu,hWnd,eax

        invoke ShowWindow,hWnd,SW_SHOWNORMAL
        invoke UpdateWindow,hWnd

      ;===================================
      ; Loop until PostQuitMessage is sent
      ;===================================

    StartLoop:
      invoke GetMessage,ADDR msg,NULL,0,0
      cmp eax, 0
      je ExitLoop
      invoke TranslateMessage, ADDR msg
      invoke DispatchMessage,  ADDR msg
      jmp StartLoop
    ExitLoop:

      return msg.wParam

WinMain endp


You may use something like:

        invoke RegisterClassEx, ADDR wc
        push eax

        ;================================
        ; Centre window at following size
        ;================================


        invoke GetSystemMetrics,SM_CXSCREEN
        mov esi,eax ;esi == screen X
        invoke GetSystemMetrics,SM_CYSCREEN
        mov ecx,eax
        shr esi,1
        shr ecx,1
        sub esi,500/2
        sub ecx,350/2
        szText szClassName,1
        pop edx
        invoke CreateWindowEx,WS_EX_LEFT,
                              edx,
                              ADDR szDisplayName,
                              WS_OVERLAPPEDWINDOW or WS_VISIBLE,
                              esi,ecx,500,350,
                              ebx,ebx,
                              hInstance,ebx
        mov   hWnd,eax

        invoke LoadMenu,hInstance,600  ; menu ID
        invoke SetMenu,hWnd,eax

      ;===================================
      ; Loop until PostQuitMessage is sent
      ;===================================

    StartLoop:
      invoke GetMessage,ADDR msg,ebx,ebx,ebx
      or eax, eax
      je ExitLoop
      invoke TranslateMessage, ADDR msg
      invoke DispatchMessage,  ADDR msg
      jmp StartLoop
    ExitLoop:

      return msg.wParam

WinMain endp

And don't care to answer me before you culculate size, and clock it :) ...to be continued The Svin
Posted on 2001-03-30 14:58:00 by The Svin
The Svin made an optimization without mentioning it. This is a Win32 optimization well-known among seasoned NT programmers. For the first (main) window, if you call CreateWindowEx with WS_VISIBLE, you don't need these two calls at all:

        invoke ShowWindow,hWnd,SW_SHOWNORMAL
        invoke UpdateWindow,hWnd
Posted on 2001-03-30 18:18:00 by tank