how to use the WM_SETFONT message


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: how to use the WM_SETFONT message

  1. #1
    tony bady Guest

    how to use the WM_SETFONT message


    Does any one know how to use wm_setfont in VB5 or later to change the font
    of a control? i write the same program in VC++, and the VC version works
    well, but in vb when i send the WM_SETfont to a control(command), it has
    no response.

    thanks in advance.
    tony

  2. #2
    Mattias Sjögren Guest

    Re: how to use the WM_SETFONT message

    >Does any one know how to use wm_setfont in VB5 or later to change the font
    >of a control? i write the same program in VC++, and the VC version works
    >well, but in vb when i send the WM_SETfont to a control(command), it has
    >no response.


    Tony,

    First, why don't you simple modify the Font proerty of the control?

    If you have a good reason not to, then yes WM_SETFONT can be used from
    VB too. This code works here:


    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam
    As Any) As Long
    Private Const WM_SETFONT = &H30

    Private Sub Command1_Click()

    Dim fnt As IFont

    Me.FontBold = True
    Set fnt = Me.Font
    Call SendMessage(Command1.hwnd, WM_SETFONT, fnt.hFont, ByVal 1&)
    Set fnt = Nothing

    End Sub

    Note that this is not a good way to do it, because you don't know when
    the font handle you got will be destroyed. This is just to prove it
    works.


    Mattias

    __________________________________________________
    Mattias Sjögren (MCP) - mattiass @ hem.passagen.se
    VB+ http://hem.spray.se/mattias.sjogren/
    Please send questions/replies to the newsgroups

  3. #3
    tony bady Guest

    Re: how to use the WM_SETFONT message


    thank you very much Mattias, I found at last it is a bug in win.tlb, if you
    ever use it.(from hardcore visual basic,version 3.5), if i declare the sendmessage
    routine in vb instead of using win.tlb, all problem solved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center