flat assembler
Message board for the users of flat assembler.
Index
> Windows > How to change the font of a dialog box during runtime? |
Author |
|
Ali.Z 07 Jun 2020, 17:59
it is most likely you did not properly defined that.
here is the resource format for dialog boxes in fasm: Code: ; dialog label,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize dialog main_dialog,'window name',0,0,100,100,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME,0,0,'terminal',8 ; dialogitem class,title,id,x,y,cx,cy,style,exstyle dialogitem 'static','some text',-1,10,10,90,90,WS_VISIBLE enddialog _________________ Asm For Wise Humans |
|||
07 Jun 2020, 17:59 |
|
ProMiNick 07 Jun 2020, 18:18
WS_CAPTION or WS_POPUP or WS_SYSMENU or DS_MODALFRAME it is all good.
But where DS_SETFONT? without this flag 0,0,'terminal',8 is ignored. |
|||
07 Jun 2020, 18:18 |
|
Ali.Z 07 Jun 2020, 18:46
ProMiNick wrote: WS_CAPTION or WS_POPUP or WS_SYSMENU or DS_MODALFRAME it is all good. well, that is not true. before posting my previous post, i did actually made a quick dialog and kept changing the fonts and it did work without issues. DS_SETFONT, is used when you want to have a custom font made by you or any other personl and font data must be in resource section i.e. RT_FONT. not specifying DS_SETFONT means the application is going to use system fonts; where system font means any font is loaded by the OS or built-in or in font directory of the operating system; which in this case terminal is a system font. _________________ Asm For Wise Humans |
|||
07 Jun 2020, 18:46 |
|
DimonSoft 07 Jun 2020, 18:49
MSDN wrote: typeface |
|||
07 Jun 2020, 18:49 |
|
ProMiNick 07 Jun 2020, 20:33
Ali.Z, if thou so sured that DS_SETFONT is for using only RT_FONT
before this Code: dialog main_dialog,'window name',0,0,100,100,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME,0,0,'terminal',8 ; dialogitem class,title,id,x,y,cx,cy,style,exstyle dialogitem 'static','some text',-1,10,10,90,90,WS_VISIBLE enddialog Code: DS_SETFONT=0 or replace this Code: dialog main_dialog,'window name',0,0,100,100,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME,0,0,'terminal',8 ; dialogitem class,title,id,x,y,cx,cy,style,exstyle dialogitem 'static','some text',-1,10,10,90,90,WS_VISIBLE enddialog with this Code: dialog main_dialog,'window name',0,0,100,100,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME+0*0,0,0,'terminal',8 ; dialogitem class,title,id,x,y,cx,cy,style,exstyle dialogitem 'static','some text',-1,10,10,90,90,WS_VISIBLE enddialog Code: from adding +0*0 nothing changed (if nothing covered from pure newbie) Oh, how thou will be suprised. That is because of cheating: no matter willing programmer using DS_SETFONT or not, - it hardcoded in fasm macros. Thou could see that other assemblers & compilers have dialog resourse both without & with this flag. SO FOR CLEARNESS ALWAYS list DS_SETFONT in dialog resource flags. BE HONIEST WITH PEOPLE THAT THEY WOULD READ THOUR CODE. they shouldn`t make assumpions about this flag absense. |
|||
07 Jun 2020, 20:33 |
|
revolution 08 Jun 2020, 06:27
I don't know if it is important, but the title says "at runtime" but the comments are discussing "at compile time".
|
|||
08 Jun 2020, 06:27 |
|
ProMiNick 08 Jun 2020, 09:44
revolution, in 1st post requester says that he have to change programmatically "at runtime", but he wants via resource "at compile time".
|
|||
08 Jun 2020, 09:44 |
|
edfed 08 Jun 2020, 16:27
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlonga
ressources are not necessary, you can also compose your windows by calling win32 functions related to window programming. |
|||
08 Jun 2020, 16:27 |
|
sinsi 08 Jun 2020, 22:48
During runtime you would use WM_SETFONT.
edit: WM_SETFONT for each control, not just the dialog. |
|||
08 Jun 2020, 22:48 |
|
Ali.Z 09 Jun 2020, 18:33
ProMiNick wrote: Oh, how thou will be suprised. oh yeah, i just checked fasm's resource macro and yes as you said it was hardcoded. that means if we want to make a dialong from memory i.e. at runtime using CreateDialogIndirectParam or DialogBoxIndirectParam not from resource section, then we will need to specify the DS_SETFONT. _________________ Asm For Wise Humans |
|||
09 Jun 2020, 18:33 |
|
ProMiNick 09 Jun 2020, 18:49
no DS_SETFONT needed only for initialization of dialog resource with current structure of items, without this flags members for font are excluded from structure - this behavior absent in standart fasm dialog init structure.
|
|||
09 Jun 2020, 18:49 |
|
extra_12345 11 Jun 2020, 11:01
Well I'm creating my dialog using resources but I do prefer to change the font of the main dialog later programmatically during the runtime, let's just say I'm interested to know how also learn something new.
|
|||
11 Jun 2020, 11:01 |
|
extra_12345 11 Jun 2020, 21:07
well here's the contents of .rc file:
Code: //Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // 150 RCDATA "devil.bmp" 151 RCDATA "bloody_font.bmp" 152 RCDATA "enochian_font.bmp" 160 RCDATA "devil.txt" 100 DIALOG DISCARDABLE 0, 0, 0, 0 STYLE DS_CENTER | WS_POPUP FONT 12, "Terminal" BEGIN END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED i've tried everything mentioned in this thread but still terminal font is ignored.... also WM_SETFONT for some reason is not working for me,so this brings us back to the zero ground,how can i change the font during the runtime using win32 api? |
|||
11 Jun 2020, 21:07 |
|
sinsi 11 Jun 2020, 22:07
Code: invoke CreateFont,16,0,0,0,0,0,0,0,0,0,0,0,0,facename mov ebx,eax invoke GetDlgItem,[hwnddlg],control1_id invoke SendMessage,eax,WM_SETFONT,ebx,TRUE invoke GetDlgItem,[hwnddlg],control2_id invoke SendMessage,eax,WM_SETFONT,ebx,TRUE |
|||
11 Jun 2020, 22:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.