flat assembler
Message board for the users of flat assembler.

Index > Windows > Changing a font for window

Author
Thread Post new topic Reply to topic
KostX



Joined: 19 Sep 2012
Posts: 41
KostX 19 Sep 2012, 12:47
How do I can to change a font for window? (all items of window)

I tried to use:

Code:
     invoke CreateFont,7,0,0,0,0, 0,0,0, RUSSIAN_CHARSET, OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, FIXED_PITCH + FF_DONTCARE, 0
     cmp eax, 0
     je error

     mov [font], eax

     invoke SendMessage,[hwnd_Static], WM_SETFONT, 0, 0
     mov eax,0
    


Bud it isn't work.
This code I've pasted in WM_CREATE event.
Post 19 Sep 2012, 12:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 19 Sep 2012, 12:49
If you send a WM_SETFONT message to a window then you should tell it what font you want to use:
Code:
invoke SendMessage,[hwnd_Static], WM_SETFONT, [font], 0    
Post 19 Sep 2012, 12:49
View user's profile Send private message Visit poster's website Reply with quote
KostX



Joined: 19 Sep 2012
Posts: 41
KostX 19 Sep 2012, 12:53
Thanks, bud it isn't work too.
Post 19 Sep 2012, 12:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 19 Sep 2012, 12:59
hwnd_Static appears to be nothing. You have not initialised it, there is no window there.

edit: The OP removed the source code, so maybe now my message makes no sense!
Post 19 Sep 2012, 12:59
View user's profile Send private message Visit poster's website Reply with quote
KostX



Joined: 19 Sep 2012
Posts: 41
KostX 19 Sep 2012, 13:01
That's full sourse code:

Code:
format PE GUI 4.0

entry start

include 'win32a.inc'

section 'data' data readable writeable

; 03>;>2>: >:=0
     MainWin_Title           db 'ZX-folder', 0
; 0720=8O :;0AA>2
     MainWin_Class           db 'Win32', 0
     Button_Class            db 'Button', 0
     Edit_Class              db 'Edit', 0
     StaticText_Class        db 'Static', 0
; "0:ABK :=>?>:
     ButtonCol_Text          db '&25B B5:AB0', 0
     ButtonSave_Text         db '!>E@0=8BL', 0
     ButtonExtra_Text        db '>?>;=8B5;L=>', 0
     ButtonAbout_Text        db ' ?@>3@0<<5', 0
; "5:ABK 8=D>@<0F8>==KE AB@>:
     ChangeFolder_Text       db 'K18@5B5 ?0?:C:', 0
     ChangeIcon_Text         db 'K18@5B5 8:>=:C ?0?:8', 0
     ChangeFolderImage       db 'K18@5B5 D>=>2CN :0@B8=:C', 0
     ChangeFolderDescription db '7<5=8BL >?8A0=85 ?0?:8', 0
; "5:ABK >H81>:
     ErrorText               db 'H81:0', 0


;  575@28@C5B 109BK ?>4 ?5@5<5==CN 4;O E@0=5=8O B5:AB0:
     TextComp           db 100 dup (?)
     TextTemp           db 100 dup (?)

; 5A:@8?B>@K >:>=
     hwnd               dd ?
     hwnd_Edit          dd ?
     hwnd_Static        dd ?
     hwnd_C             dd ?

; (@8DB
     font               dd ?
     FontName           db 'Areal', 0

; !B@C:BC@K 40==KE:
     wc WNDCLASS 0, WindowProc, 0, 0, 0, 0, 0, COLOR_BTNFACE+1, 0, MainWin_Class

     msg MSG

section '.code' code readable executable

     start:

          invoke GetModuleHandle, 0
          mov [wc.hInstance], eax

          invoke LoadIcon, 0, IDI_APPLICATION
          mov [wc.hIcon], eax

          invoke LoadCursor, 0, IDC_ARROW
          mov [wc.hCursor], eax

          invoke RegisterClass, wc
          cmp eax, 0
          je error


          invoke CreateWindowEx, 0, MainWin_Class, MainWin_Title, WS_VISIBLE + WS_SYSMENU + WS_MINIMIZEBOX, 512, 256, 303, 256, 0, 0, [wc.hInstance], 0
          cmp eax, 0
          je error

; !>E@0=8BL 45A:@8?B>@ >:=0 2 ?5@5<5==CN 4;O ?>A;54CNI53> 53> 8A?>;L7>20=8O:
          mov [hwnd], eax

     msg_loop:
          invoke GetMessage, msg, 0, 0, 0
          cmp eax, 0
          je end_loop

; -B0 DC=:F8O >?@545;O5B, 04@5A>20=> ;8 A>>1I5=85 C:070==><C
; 1;>:C 480;>30, 8 5A;8 40  >1@010BK205B A>>1I5=85. =0G5  A>>1I5=85
; 1K;> >1@01>B0=> DC=:F859, 8 =0< =5 =04> 53> ?>2B>@=> >1@010BK20BL.
; >MB><C, 5A;8 ?>A;5 2K?>;=5=8O DC=:F88 eax =5 @025= =>;N, F8:;
; =0G8=05BAO A=0G0;0, 0 5A;8 =>;L, B> >1@01>B:0 A>>1I5=8O ?@>4>;605BAO.
; A?>;L7>20=85 MB>9 DC=:F88 B@51C5BAO, =0?@8<5@, 4;O ?@028;L=>9
; >1@01>B:8 ?5@5:;NG5=8O <564C M;5<5=B0<8, 8<5NI8<8 AB8;L WS_TABSTOP,
; ?> :;028H5 Tab. #15@8B5 55 87 F8:;0 (2<5AB5 A cmp eax,0 8 jne msg_loop),
; 8 ?5@5:;NG5=85 =5 1C45B >ACI5AB2;OBLAO.
          invoke IsDialogMessage, [hwnd], msg
          cmp eax, 0
          jne msg_loop



          invoke TranslateMessage, msg
          invoke DispatchMessage, msg

          jmp msg_loop

     error:
          invoke MessageBox, 0, ErrorText, 0, MB_ICONERROR + MB_OK

     end_loop:
          invoke ExitProcess, [msg.wParam]

     proc WindowProc hwnd, wmsg, wparam, lparam
               push ebx esi edi

               cmp [wmsg], WM_CREATE
               je .wmcreate

               cmp [wmsg], WM_COMMAND
               je .wmcommand

               cmp [wmsg], WM_DESTROY
               je .wmdestroy

          .defwndproc:
               invoke DefWindowProc, [hwnd], [wmsg], [wparam], [lparam]
               jmp .finish

          .wmcreate:
               invoke CreateWindowEx, 0, StaticText_Class, ChangeFolder_Text, WS_VISIBLE + WS_CHILD, 5, 4, 160, 10, [hwnd], 1006, [wc.hInstance], 0

               invoke CreateFont,24,0,0,0,0, 0,0,0, RUSSIAN_CHARSET, OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, FIXED_PITCH + FF_DONTCARE, FontName
               cmp eax, 0
               je error

               mov [font], eax

               invoke SendMessage,[hwnd], WM_SETFONT, [font], 0
               mov eax,0

               jmp .finish

          .wmcommand:

               jmp .finish


          .wmdestroy:
               invoke ExitProcess, 0


          .finish:
               pop edi esi ebx
     ret
     endp

section '.idata' import data readable writeable

     library kernel32, 'KERNEL32.DLL',\
             user32,   'USER32.DLL',\
             Gdi32,    'Gdi32.dll'

     include 'api\kernel32.inc'
     include 'api\user32.inc'

     import Gdi32, CreateFont, 'CreateFontA'
    
Post 19 Sep 2012, 13:01
View user's profile Send private message Reply with quote
KostX



Joined: 19 Sep 2012
Posts: 41
KostX 19 Sep 2012, 13:06
If you have either a sample with using the change window font or link, give me it please.
Post 19 Sep 2012, 13:06
View user's profile Send private message Reply with quote
KostX



Joined: 19 Sep 2012
Posts: 41
KostX 19 Sep 2012, 13:27
I tried assign with hwnd (look source code) to change a font for all units of window. Bub it isn't work too.
Post 19 Sep 2012, 13:27
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 19 Sep 2012, 13:54
You must send WM_SETFONT to the child window, not to the parent.
Post 19 Sep 2012, 13:54
View user's profile Send private message Visit poster's website ICQ Number 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.