Steward
分享是一種喜悅、更是一種幸福
程式語言 - High Level Assembly (HLA) - Win32 API (HLA v1.x) - Dialog - 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控制項(如:Button、Edit)也是此類道理,比較需要注意的是,Windows視窗程式設計的核心是圍繞着事件處理(處理Message),任何的視窗設定或者溝通都是以事件導向為原則,因此,寫出一個簡單的視窗框架,將有助於了解Windows視窗程式的運作
main.hla
program main;
#include("w.hhf")
#include("args.hhf")
#include("memory.hhf")
#include("strings.hhf")
static
hInstance: dword;
CommandLine: string;
readonly
szCaption: string:= "main";
procedure WinMain(hInst:dword; hPrevInst:dword; CmdLine:string; CmdShow:dword);
var
msg: w.MSG;
begin WinMain;
w.CreateWindowEx(w.WS_EX_LEFT, w.WC_DIALOG, szCaption, 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;
完成