程式語言 - High Level Assembly (HLA) - Win32 API (HLA v1.x) - Single Document Interface (SDI) - Create Window



參考網站:
http://winapi.freetechsecrets.com/win32/
http://masm32.com/board/index.php?topic=3584.0
https://www.plantation-productions.com/Webster/
https://www.plantation-productions.com/Webster/Win32Asm/win32API.html

Windows的視窗可以分成:Dialog、Single Document Interface(SDI)、Multiple Document Interface(MDI)三種類別,相對於SDI、MDI,Dialog類別是比較容易上手學習的一個類別,相當適合初次學習Windows視窗設計的使用者,而Windows視窗程式設計的核心就是圍繞着事件處理(處理Message),任何的視窗設定或者溝通都是以事件導向為原則,因此,寫出一個簡單的視窗框架,將有助於了解Windows視窗程式的運作

main.hla

program main;
 
#include("w.hhf")
#include("args.hhf")
#include("memory.hhf")
#include("strings.hhf")
 
static
    hInstance:   dword;
    CommandLine: string;
    wndClass:    w.WNDCLASS;
 
readonly
    szName: string:= "main";
 
procedure WinMain(hInst:dword; hPrevInst:dword; CmdLine:string; CmdShow:dword);
var
    msg: w.MSG;
 
begin WinMain;
    mov(w.DefWindowProc, wndClass.lpfnWndProc);
    mov(szName, wndClass.lpszClassName);
    w.RegisterClass(wndClass);

    w.CreateWindowEx(w.WS_EX_LEFT, szName, szName, w.WS_OVERLAPPEDWINDOW | w.WS_VISIBLE, 0, 0, 320, 240, 0, 0, NULL, NULL);
     
    forever
        w.GetMessage(msg, NULL, 0, 0);
        breakif(!eax);
 
        w.DispatchMessage(msg);
    endfor;
    mov(msg.wParam, eax);
end WinMain;
 
begin main;
    w.GetModuleHandle(NULL);
    mov(eax, hInstance);
    mov(arg.cmdLn(), CommandLine);
 
    WinMain(hInstance, NULL, CommandLine, w.SW_SHOWNORMAL);
 
    w.ExitProcess(eax);
end main;

完成