flat assembler
Message board for the users of flat assembler.

Index > Windows > setting font

Author
Thread Post new topic Reply to topic
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
my program crashes when trying to set a child controls font, with the following code

Code:
  wmcreate:
        invoke  CreateWindowEx,WS_EX_CLIENTEDGE,_lb,0,WS_VISIBLE+WS_CHILD+LBS_STANDARD,5,5,110,75,[hwnd],0,[hinstance],NULL
        or      eax,eax
        jz      failed
        mov     [lbhwnd],eax
        invoke  CreateWindowEx,0,_btn,_btn_text,WS_VISIBLE+WS_CHILD+BS_PUSHBUTTON,5,85,55,20,[hwnd],0,[hinstance],NULL
        or      eax,eax
        jz      failed
        mov     [btnhwnd],eax
        invoke  CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL
        or      eax,eax
        jz      failed
        mov     [childfont],eax
        invoke  SendMessage,[lbhwnd],WM_SETFONT,eax,FALSE
        invoke  SendMessage,[btnhwnd],WM_SETFONT,eax,FALSE
        xor     eax,eax
        jmp     finish
       failed:
        or      eax,-1
        jmp     finish 
    


if i comment out the CreateFont line it doesnt crash
Post 08 Apr 2004, 00:34
View user's profile Send private message Reply with quote
VitalOne



Joined: 29 Jul 2003
Posts: 54
Location: USA
VitalOne
I haven't tested this, but try this:
Code:
  wmcreate: 
        invoke  CreateWindowEx,WS_EX_CLIENTEDGE,_lb,0,WS_VISIBLE+WS_CHILD+LBS_STANDARD,5,5,110,75,[hwnd],0,[hinstance],NULL 
        or      eax,eax 
        jz      failed 
        mov     [lbhwnd],eax 
        invoke  CreateWindowEx,0,_btn,_btn_text,WS_VISIBLE+WS_CHILD+BS_PUSHBUTTON,5,85,55,20,[hwnd],0,[hinstance],NULL 
        or      eax,eax 
        jz      failed 
        mov     [btnhwnd],eax 
        invoke  CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL 
        or      eax,eax 
        jz      failed 
        mov     [childfont],eax 
        invoke  SendMessage,[lbhwnd],WM_SETFONT,[childfont],FALSE 
        invoke  SendMessage,[btnhwnd],WM_SETFONT,[childfont],FALSE 
        xor     eax,eax 
        jmp     finish 
       failed: 
        or      eax,-1 
        jmp     finish
    
Post 08 Apr 2004, 05:10
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
changed it, still crashes at the same point.. strange the same code works in the MiniPad example. could it be the type of controls im trying to work with dont support the font being created?
Post 08 Apr 2004, 21:13
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Maybe its because last parameter of CreateFont is zero? needs to point to asciiz string

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 08 Apr 2004, 21:18
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
zenek_tm



Joined: 21 Mar 2004
Posts: 33
Location: Poland
zenek_tm
The last parameter must be a pointer to a string with font name.
Post 08 Apr 2004, 22:31
View user's profile Send private message Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
how would i send a pointer to


_font db 'Times New Roman',0


is that like using ADDR in masm?
Post 08 Apr 2004, 23:29
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
just write _font

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 09 Apr 2004, 03:02
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
Code:
_sfont db "Times New Roman",0
    
invoke  CreateFont,13,0,0,0,0,0,0,0,0,0,0,0,0,_sfont
    


works - thanks
Post 10 Apr 2004, 05:37
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.