flat assembler
Message board for the users of flat assembler.

Index > Windows > changing the font in edit control

Author
Thread Post new topic Reply to topic
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 18 Jun 2006, 01:43
How can I change the font in a edit control to Terminal ? Can I do it without using CreateFontIndirect ? As I know I have to use something like
invoke SendMessage, [hwnd],WM_SETFONT,[hFont],TRUE
,but I dont know what is hFont pointing to ..
Also how can I change the colour of the font and the background? I tryed with SetTextColor,[hEdit],$ffff and SetBkColor,[hEdit],$ff on WM_CREATE, but it don't work this way ..
Post 18 Jun 2006, 01:43
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 18 Jun 2006, 02:38
hi slai,
the hfont is a return value from CreateFontIndirect, if you don't want to use CreateFontIndirect, you could try GetStock ~ ANSI_FIXED_FONT, ANSI_VAR_FONT, SYSTEM_FONT ... to return stocked font handle.
Post 18 Jun 2006, 02:38
View user's profile Send private message Visit poster's website Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 18 Jun 2006, 05:40
thanks vbVeryBeginner, this is almost what I needed just I can't change the font to Terminal with it. After that I tryed :
Code:
        lf      LOGFONTA  0,0,0,0,0,0,0,0,0,0,0,0,0,'Terminal'    
and than on WM_CREATE after creating the edit control and setting the focus on it :
Code:
        invoke  CreateFontIndirect, lf
        invoke  SendMessage, [hEdit],WM_SETFONT,eax,1    
, but this don't work Confused What am I missing?
Post 18 Jun 2006, 05:40
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 18 Jun 2006, 08:23
Smile check it
for the muldiv, please reffer to http://board.flatassembler.net/topic.php?t=1933


Description: source to change edit font to terminal
Download
Filename: edit1.zip
Filesize: 936 Bytes
Downloaded: 230 Time(s)

Post 18 Jun 2006, 08:23
View user's profile Send private message Visit poster's website Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 19 Jun 2006, 00:23
strange but the font isn't Terminal on my PC ..
I just want to put a DOS ascii font in the edit control, and as I know the only font that suports the DOS ascii is Terminal.

Anyways, how can I change the font colour and the background colour in the edit control ?
Post 19 Jun 2006, 00:23
View user's profile Send private message Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 21 Jun 2006, 17:53
I guess this question is too boring to get response Confused

Anyway I found how to change the background and font colour from those examples : http://www.pbrennick.com/asmtools/Progress.zip (in MASM)
Code:
  WM_CTLCOLOREDIT:
        invoke  SetTextColor, [wParam], $ffff00
        invoke  SetBkColor, [wParam], 0    ; test background color (for all lines with text)
        invoke  CreateSolidBrush, 0       ; background colour for the rest of the lines
        jmp     finish    
but still can't change the font to Terminal
Post 21 Jun 2006, 17:53
View user's profile Send private message Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 21 Jun 2006, 23:51
I noticed that in the exe file of a dialog made with fasm, there is a part in the recource section that is "MS Sans Serif" in Unicode. If I change that part to Terminal will this change the font in the edit control to Terminal, or that is used for something else ?
Post 21 Jun 2006, 23:51
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 22 Jun 2006, 08:33
It will change the font used by all controls in that dialog box.
You can specify this parameter by giving tenth and eleventh parameter to the "dialog" macro, see Resource macros documentation.
Post 22 Jun 2006, 08:33
View user's profile Send private message Visit poster's website Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 23 Jun 2006, 02:06
that worked perfectly Very Happy. Thanks!

I am planning to use this as a base of a compiler/editor that I am trying to do, so is it a bad idea to use dialog window for that instead of the normal way with CreateWindowEx ? Will the productivity/speed be less with dialog based window ?

and another question off topic Smile - why fasm doesn't recognise 'DialogBox' and 'CreateWindow' ? Aren't they functions of the library as their extended versions ?
Post 23 Jun 2006, 02:06
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 23 Jun 2006, 07:33
Is it possible to add bold typeface when changing the font?
Post 23 Jun 2006, 07:33
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 25 Jun 2006, 19:25
<empty>


Last edited by Vasilev Vjacheslav on 27 Jun 2006, 11:04; edited 1 time in total
Post 25 Jun 2006, 19:25
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 26 Jun 2006, 17:13
Thanks Vasilev, But, didn't have any luck making it work. Anyways, I was hoping there would be a way using the resource macros. I'll keep trying different things until I get the effect i'm looking for.
MadMatt
Post 26 Jun 2006, 17:13
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 27 Jun 2006, 11:01
here is ported code:

Code:
  ; hWnd - handle of main window
  ; hId  - id of control on main window

  proc _makebold hWnd,hId
  locals
        hmlf    LOGFONT
  endl
        
        xor     ebx,ebx
        invoke  SendDlgItemMessage,[hWnd],[hId],WM_GETFONT,ebx,ebx

        lea     edi,[hmlf]
        invoke  GetObject,eax,sizeof.LOGFONT,edi
        test    eax,eax
        jz      @F
        
        mov     [edi+LOGFONT.lfWeight],FW_BOLD
        mov     [edi+LOGFONT.lfQuality],ANTIALIASED_QUALITY
        invoke  CreateFontIndirect,edi
        invoke  SendDlgItemMessage,[hWnd],[hId],WM_SETFONT,eax,1

  @@:
        ret
  endp          
    
Post 27 Jun 2006, 11:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.