I can change all the font attributes except color from the FontDialog, why? thanks...
.586
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include gdi32.inc
include comdlg32.inc
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
includelib comdlg32.lib
.const
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
.data
ClassName db "MainWinClass",0
AppName db "Main Window",0
StaticClass db "STATIC",0
ButtonClass db "BUTTON",0
CreateText db "CreateFont",0
ButtonIndirectText db "Crete Indirect",0
ChooseText db "ChooseFont",0
ButtonChooseText db "Choose Font",0
fontFace db "Tahoma",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hWin dd ?
hCreate dd ?
hSTC dd ?
hBUT_Create dd ?
hIndirect dd ?
hBUT_Indirect dd ?
hBUT_Choose dd ?
cf CHOOSEFONT<?>
lf LOGFONT<?>
buffer byte 256 dup(?)
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
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 hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,400,\
200,400,200,NULL,NULL,\
hInst,NULL
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 hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_CREATE
push hWnd
pop hWin
invoke CreateWindowEx,NULL,addr ButtonClass,addr ButtonChooseText,\
WS_VISIBLE or BS_PUSHBUTTON or WS_CHILD,\
6,62,90,20,hWin,NULL,hInstance,0
mov hBUT_Choose,eax
invoke CreateWindowEx,NULL,addr StaticClass,addr CreateText,\
WS_VISIBLE or WS_CHILD or SS_SUNKEN,\
140,60,200,26,hWin,NULL,hInstance,0
mov hSTC,eax
; Initialize the LOGFONT structure
mov lf.lfHeight,-12
mov lf.lfWidth,0
mov lf.lfEscapement,0
mov lf.lfOrientation,0
mov lf.lfWeight,400
mov lf.lfItalic,0
mov lf.lfUnderline,0
mov lf.lfStrikeOut,0
mov lf.lfCharSet,0
mov lf.lfOutPrecision,3
mov lf.lfClipPrecision,2
mov lf.lfQuality,1
mov lf.lfPitchAndFamily,34
lea eax,lf.lfFaceName
invoke wsprintf,eax,addr fontFace
; CHOOSEFONT structure
mov cf.lStructSize,SIZEOF CHOOSEFONT
push hWnd
pop cf.hWndOwner
lea eax,lf
mov cf.lpLogFont,eax
mov cf.Flags,CF_EFFECTS OR CF_SCREENFONTS OR CF_LIMITSIZE OR\
CF_FORCEFONTEXIST OR CF_INITTOLOGFONTSTRUCT
mov cf.hDC,0
mov cf.iPointSize,0
mov cf.rgbColors,0
mov cf.lCustData,0
mov cf.lpfnHook,0
mov cf.lpTemplateName,0
mov cf.hInstance,0
mov cf.lpszStyle,0
mov cf.nFontType,0
mov cf.Alignment,0
mov cf.nSizeMin,8
mov cf.nSizeMax,28
.elseif uMsg==WM_COMMAND
mov eax,lParam
.if eax==hBUT_Choose
invoke SetWindowText,hSTC,addr ChooseText
invoke ChooseFont,addr cf ; Get font info from FontDialog
invoke CreateFontIndirect, addr lf
mov hIndirect,eax
invoke SendMessage,hSTC,WM_SETFONT,hIndirect,TRUE
.endif
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
The color returned is not applied to the font, if you look at a LOGFONT structure there is no slot for color. You must apply the color to the control usually in the WM_PAINT handler or using SetTextColor in conjunction with DrawText.
http://msdn.microsoft.com/en-us/library/ms646829(VS.85).aspx
Thanks donkey. Back to the M$ drawing board.