Message Box class implementation
This is an OOP example that implements a messagebox wrapper.
# Class implementation for OOP message box handling
require "auto";
require "dialog";
class CMessageBox {
member mTitle string;
member mContent string;
member mType int;
member mHandle int;
method construct void()
{
set %this.mTitle <= "";
set %this.mContent <= "";
set %this.mTitle <= 0;
set %this.mHandle <= 0;
};
method raise int()
{
local iResultValue int;
msgbox "%%this.mContent" "%%this.mTitle" %%this.mType %%this.mHandle iResultValue;
result %iResultValue;
};
method applyForegroundWindow void()
{
local hForegroundWindow int;
aut_getfgwindow hForegroundWindow;
set %this.mHandle <= %hForegroundWindow;
};
method setTitle void(expr string)
{
set %this.mTitle <= "%expr";
};
method setContent void(expr string)
{
set %this.mContent <= "%expr";
};
method setType void(bitmask int)
{
set %this.mType <= %bitmask;
};
method setHandle void(handle int)
{
set %this.mHandle <= %handle;
};
method getTitle string() { result "%%this.mTitle"; };
method getContent string() { result "%%this.mContent"; };
method getType int() { result "%%this.mType"; };
method getHandle int() { result "%%this.mHandle"; };
};
global msg class;
global gTitle string;
global gContent string;
global gType int;
global gHandle int;
global gResult int;
set @msg <= CMessageBox;
bitop "or" (%MB_YESNOCANCEL, %MB_ICONQUESTION) gType;
call @msg.setTitle("Question");
call @msg.setContent("Do you want to proceed?");
call @msg.setType(%gType);
call @msg.setHandle(0);
call @msg.applyForegroundWindow();
call @msg.getTitle() => gTitle;
call @msg.getContent() => gContent;
call @msg.getType() => gType;
call @msg.getHandle() => gHandle;
print "Title: %gTitle";
print "Content: %gContent";
print "Type: %gType";
print "Handle: %gHandle";
call @msg.raise() => gResult;
if (%gResult, -eq, %IDYES) {
print "You clicked YES";
} elseif (%gResult, -eq, %IDNO) {
print "You clicked NO";
} elseif (%gResult, -eq, %IDCANCEL) {
print "You clicked ABORT";
} else {
print "Result: %gResult";
};
unset @msg;