News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Change font it button doesn't work!!!Help!!!

Started by xandaz, March 10, 2021, 04:28:33 AM

Previous topic - Next topic

xandaz

    Hi guys. I'm using WM_SETFONT in a button but the font doesn't change. Any ideas why?SendMessage,hButton,WM_SETFONT,hFont,TRUE

HSE

Quote from: xandaz on March 10, 2021, 04:28:33 AM
    Hi guys. I'm using WM_SETFONT in a button but the font doesn't change. Any ideas why?SendMessage,hButton,WM_SETFONT,hFont,TRUE

Which were your ideas?
Equations in Assembly: SmplMath

jj2007

Strange, here invoke SendMessage, hButton, WM_SETFONT, hFont, 0 works perfectly :cool:

Btw ever heard of the Masm32 SDK macro LastError$()?
print LastError$()

six_L

Hi, xandaz
Test on setting the hButton,hFont into the global variable.

option casemap:none
option win64:7

include \UASM64\include\windows.inc

includelib \UASM64\Lib\user32.lib
includelib \UASM64\Lib\kernel32.lib
includelib \UASM64\Lib\gdi32.lib

ICO_MAIN equ 1000
DLG_MAIN equ 100
IDC_STAR equ 101
IDC_EXIT equ 102
IDC_DEMO equ 103

.data?
hInstance dq ?
hBTNwnd dq ?
hFont_1 dq ?
hFont_2 dq ?

.data
fontFlag BOOL FALSE

.code

_ProcDlgMain proc  hWnd:qword,wMsg:dword,wParam:qword,lParam:qword

mov eax,wMsg
.if eax == WM_INITDIALOG
invoke LoadIcon,hInstance,ICO_MAIN
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
invoke GetDlgItem,hWnd,IDC_DEMO
mov hBTNwnd,rax

invoke  CreateFont,124,0,0,0,FW_BOLD,FALSE,FALSE,FALSE, \
    DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
    DEFAULT_QUALITY,FIXED_PITCH, CStr("Cambria")
mov hFont_1, rax

invoke  CreateFont,62,0,0,0,FW_BOLD,TRUE,TRUE,FALSE, \
    DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
    DEFAULT_QUALITY,FIXED_PITCH, CStr("Ravie")
mov hFont_2, rax

.elseif eax == WM_COMMAND
mov rax,wParam
.if ax == IDC_EXIT
invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL
.elseif ax == IDC_STAR
.if fontFlag == TRUE
invoke SendMessage,hBTNwnd,WM_SETFONT,hFont_1,TRUE
mov fontFlag, FALSE
.else
invoke SendMessage,hBTNwnd,WM_SETFONT,hFont_2,TRUE
mov fontFlag, TRUE

.endif

.elseif ax == IDC_DEMO
invoke MessageBox, 0,CStr("Hello from Button!"), CStr("Test"), MB_OK
.endif
.elseif eax == WM_CLOSE
invoke DeleteObject, hFont_1
invoke DeleteObject, hFont_2
invoke EndDialog,hWnd,NULL
.else
mov rax,FALSE
ret
.endif
mov rax,TRUE
ret

_ProcDlgMain endp

WinMainCRTStartup Proc
invoke GetModuleHandle,NULL
invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
WinMainCRTStartup Endp


end


#include <\UASM64\include\resource.h>
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define ICO_MAIN 1000
#define DLG_MAIN 100
#define IDC_STAR 101
#define IDC_EXIT 102
#define IDC_DEMO 103
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_MAIN DIALOG 0, 0, 357, 164
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "FONT_Test"
FONT 10, "Consolas"
{
PUSHBUTTON "Click Me!", IDC_DEMO,30, 25, 295, 100
PUSHBUTTON "SW-BTN-F", IDC_STAR,2, 148, 40, 14
PUSHBUTTON "Exit", IDC_EXIT, 314, 148, 40, 14, WS_TABSTOP
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAIN ICON "MICON.ico"

Say you, Say me, Say the codes together for ever.

xandaz

   hi guys. Six L your file is corrupt. Still couldnt't fix it.

jj2007

No, six_L's file isn't corrupt. If your code doesn't work, you should post it (the complete code).

xandaz