Hi,

I am trying to display a dialog box in HLA, but it just work.

I haven't inluded the resource file, but the rest is obvious.
The resource file was created with radasm.

Can someone please help me to understand what I am doing wrong.

Please see code below,

Thanks,

Yao.

program Script_Generator;

#include( "w.hhf" ) // Standard windows stuff.

#include ("comctl32.hhf")



#asm
includelib \masm32\lib\comctl32.lib
#endasm

#asm
includelib \masm32\lib\user32.lib
#endasm


const
myMENU := 10000;
IDM_NRFILE := 10002;
IDM_RANGEFILE := 10003;
IDM_RUN := 10005;
IDM_VIEWFILE := 10006;
IDM_EXIT := 10008;
IDM_RESET := 10009;
IDM_ABOUT := 10010;
myIcon := 100;
IDC_BTN1 := 1005;
IDD_DLG01 := 1000;

static
hInstance :dword;
hMenu :dword;
hEdit :dword;
hDlg :dword;
CommandLine :string;


readonly

ClassName :string := "Win32ASMEditClass";
EditClass :string := "edit";
AppName :string := "AppNameStr";
DlgName :string := "aboutDialog";

procedure DlgProc( hDlg:dword; uMsg:uns32; wParam:dword;
lParam:dword );
@nodisplay;
@stdcall;

begin DlgProc;


if ( uMsg = w.WM_INITDIALOG ) then

elseif ( uMsg = w.WM_CLOSE ) then

w.EndDialog ( hDlg, 0 );

elseif ( uMsg = w.WM_COMMAND ) then

if ( wParam = IDC_BTN1 ) then

w.SendMessage (hDlg, w.WM_CLOSE, 0, 0);

endif;

else

mov ( 0 , eax );
exit DlgProc;

endif;

mov ( 1, eax );

end DlgProc;


procedure WndProc( lParam:dword; wParam:dword; uMsg:uns32;
hWnd:dword );
@nodisplay;

begin WndProc;

if( uMsg = w.WM_DESTROY ) then

w.PostQuitMessage( 0 );

elseif( uMsg = w.WM_CREATE ) then

w.CreateWindowEx
(
NULL,
EditClass,
NULL,
w.WS_VSCROLL|w.WS_HSCROLL|w.WS_VISIBLE|
w.WS_CHILD | w.ES_LEFT | w.ES_MULTILINE|
w.ES_AUTOVSCROLL|w.ES_AUTOHSCROLL,
w.CW_USEDEFAULT,
w.CW_USEDEFAULT,
w.CW_USEDEFAULT,
w.CW_USEDEFAULT,
hWnd,
NULL,
hInstance,
NULL
);

elseif( uMsg = w.WM_SIZE ) then

mov( lParam, eax );
mov ( eax, edx );
shr( 16, edx );
and( $FFFF, eax );
w.MoveWindow( hEdit, 0, 0, eax, edx, true );

elseif( uMsg = w.WM_COMMAND ) then

mov( wParam, eax );
if( lParam = 0 ) then

if( ax = IDM_ABOUT ) then
w.CreateDialogParam( hWnd,IDD_DLG01, NULL,
&DlgProc, NULL );
mov(eax,hDlg);

endif;
endif;
else

w.DefWindowProc( hWnd, uMsg, wParam, lParam );
exit WndProc;

endif;
sub( eax, eax );

end WndProc;

procedure WinMain
(
hInst:dword;
hPrevInst: dword;
CmdLine: string;
CmdShow: dword
); @nodisplay;

var
wc: w.WNDCLASSEX;
msg: w.MSG;
hWnd: dword;

begin WinMain;


// Set up the window class (wc) object:

mov( @size( w.WNDCLASSEX ), wc.cbSize );
mov( w.CS_HREDRAW | w.CS_VREDRAW, wc.style );
mov( &WndProc, wc.lpfnWndProc );
mov( NULL, wc.cbClsExtra );
mov( NULL, wc.cbWndExtra );

mov( hInstance, wc.hInstance );
mov( w.COLOR_WINDOW+1, wc.hbrBackground );
mov( myMENU, wc.lpszMenuName );
mov( ClassName, wc.lpszClassName );

// Get the icons and cursor for this application:

w.LoadIcon( hInstance, myIcon );
mov( eax, wc.hIcon );
mov( eax, wc.hIconSm );

w.LoadCursor( NULL, w.IDC_ARROW );
mov( eax, wc.hCursor );


// Okay, register this window with Windows so it
// will start passing messages our way. Once this
// is accomplished, create the window and display it.

w.RegisterClassEx( wc );

w.CreateWindowEx
(
w.WS_EX_CLIENTEDGE,
ClassName,
AppName,
w.WS_OVERLAPPEDWINDOW,
w.CW_USEDEFAULT,
w.CW_USEDEFAULT,
w.CW_USEDEFAULT,
w.CW_USEDEFAULT,
NULL,
NULL,
hInst,
NULL
);
mov( eax, hWnd );

// createStatusBar(hWnd);

w.GetMenu(hWnd);
mov(eax,hMenu);


w.ShowWindow( hWnd, w.SW_SHOWNORMAL );
w.UpdateWindow( hWnd );

// Here's the event loop that processes messages
// sent to our window. On return from GetMessage,
// break if EAX contains false and quit the
// program.

forever

w.GetMessage( msg, NULL, 0, 0 );
breakif( !eax );
w.TranslateMessage( msg );
w.DispatchMessage( msg );

endfor;
mov( msg.wParam, eax );


end WinMain;



begin Script_Generator;

w.GetModuleHandle( NULL );
mov( eax, hInstance );

// Get a copy of the command line string passed to this code:

w.GetCommandLine();
mov(eax,CommandLine);

WinMain( hInstance, NULL, CommandLine, w.SW_SHOWDEFAULT );

// WinMain returns a return code in EAX, exit the program
// and pass along that return code.

w.ExitProcess( eax );

end Script_Generator;

-----------------------------------
Yao knows he's new to the ASM scene, but yao loves a challenge.
Posted on 2003-06-03 14:14:39 by Yao_Rules