Hi all,

Can anyone of you tell me whether it is possible in RadAsm to have a visual project with a window instead of a dialog.
I saw you can start a win32 project, but it doesn't show a window in the editor, does it?

Or do I understand the meaning of the word dialog wrong?
As far as I know, a window can have controls on it, with each control having its own font, while a dialog can only have controls having the same font the dialog has.

Regards,
mdevries.
Posted on 2004-11-10 15:16:02 by mdevries
Hi mdevries

You can design a dialog with controls and then use the Dialog to Window tool.

Example code:


.386
.model flat,stdcall ;32 bit memory model
option casemap:none ;case sensitive

;#########################################################################

include windows.inc
include kernel32.inc
include user32.inc
include Comctl32.inc

includelib user32.lib
includelib kernel32.lib
includelib Comctl32.lib

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :HWND,:UINT,:WPARAM,:LPARAM

;#########################################################################

.const

IDD_DIALOG1 equ 101
IDC_GRP1 equ 1001
IDC_EDT1 equ 1002

.data

RichEditDLL db 'riched20.dll',0
szWinClass db 'WinClass',0
szButton db 'Button',0
szEdit db 'Edit',0
szWinCap1 db 'DialogApp',0
szGroupCap1 db 'IDC_GRP',0

.data?

hInstance dd ?
CommandLine dd ?
hIcon dd ?
hWnd dd ?
iccex INITCOMMONCONTROLSEX <?>

;#########################################################################

.code

start:

invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke InitCommonControls
mov iccex.dwSize,sizeof INITCOMMONCONTROLSEX ;prepare common control structure
mov iccex.dwICC,ICC_DATE_CLASSES
invoke InitCommonControlsEx,addr iccex
invoke LoadLibrary,addr RichEditDLL
mov hRichEdDLL,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
push eax
invoke FreeLibrary,hRichEdDLL
pop eax
invoke ExitProcess,eax

;#########################################################################

WinMain proc hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG

invoke LoadIcon,NULL,IDI_APPLICATION
mov hIcon,eax
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,0
mov wc.lpszClassName,offset szWinClass
push hIcon
pop wc.hIcon
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
push hIcon
pop wc.hIconSm
invoke RegisterClassEx,addr wc
invoke CreateWindowEx,0h,addr szWinClass,addr szWinCap1,14CF0800h,10,10,300,200,0,0,hInst,0
mov hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke GetMessage, addr msg,NULL,0,0
.break .if !eax
invoke TranslateMessage, addr msg
invoke DispatchMessage, addr msg
.endw
mov eax,msg.wParam
ret

WinMain endp

;#########################################################################

WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL rect:RECT
LOCAL hDC:HDC
LOCAL ps:PAINTSTRUCT

mov eax,uMsg
.if eax==WM_CREATE
invoke CreateWindowEx,0h,addr szButton,addr szGroupCap1,50000007h,0,0,130,172,hWin,IDC_GRP1,hInstance,0
invoke CreateWindowEx,200h,addr szEdit,0,50010000h,132,0,160,172,hWin,IDC_EDT1,hInstance,0
.elseif eax==WM_COMMAND
mov eax,wParam
mov edx,eax
shr edx,16
and eax,0FFFFh
.if edx==BN_CLICKED
.endif
.elseif eax==WM_PAINT
.elseif eax==WM_CLOSE
.elseif eax==WM_DESTROY
invoke PostQuitMessage,NULL
xor eax,eax
ret
.endif
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret

WndProc endp

;#########################################################################

end start


KetilO
Posted on 2004-11-10 15:26:06 by KetilO
Hi KetilO,

Thank you for your quick reply.

Do I understand you well? Is it possible in this way to assign a font for each control by the properties window? Or can it only be done programmatically?

Regards,
mdevries.
Posted on 2004-11-10 15:31:25 by mdevries
It has to be done in code.
With the FontBuilder it's easy.



.data
Arial_8 LOGFONT <-11,0,0,0,400,0,0,0,0,3,2,1,34,'Arial'>
Arial_10 LOGFONT <-13,0,0,0,400,0,0,0,0,3,2,1,34,'Arial'>
.code
mov eax,uMsg
.if eax==WM_CREATE
invoke CreateWindowEx,0h,addr szButton,addr szGroupCap1,50000007h,0,0,130,172,hWin,IDC_GRP1,hInstance,0
push eax
invoke CreateFontIndirect,offset Arial_8
pop edx
invoke SendMessage,edx,WM_SETFONT,eax,FALSE
invoke CreateWindowEx,200h,addr szEdit,0,50010000h,132,0,160,172,hWin,IDC_EDT1,hInstance,0
push eax
invoke CreateFontIndirect,offset Arial_10
pop edx
invoke SendMessage,edx,WM_SETFONT,eax,FALSE


KetilO
Posted on 2004-11-10 15:46:26 by KetilO
Hi KetilO,

Thanks again you for your reply.
Wouldn't it be a nice idea to incapsulate it in the visual editor?

Regards,
mdevries.
Posted on 2004-11-10 15:50:08 by mdevries