Results 1 to 3 of 3

Thread: Change font in specific windows.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19
    Hi there,
    Do you know how can I send a message to a specific window and change it font.
    Thanks

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    If you can get its window handle, There are loads of different ways to do this depending on your situation.

    insert the following code into a standard module

    Code:
    Option Explicit
    
    Private Const SYSTEM_FONT = 13
     
    
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
    Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    
    
    Public Sub SetWindowFont(TargethWnd As Long, FontModel As PictureBox)
    
    Dim hfont As Long
    Dim hDC As Long
    
    
    'get target DC
    hDC = GetDC(TargethWnd)
    
    'Get Font out of picturebox
    hfont = SelectObject(FontModel.hDC, GetStockObject(SYSTEM_FONT))
    
    'Put font back where you found it
    SelectObject FontModel.hDC, hfont
    
    'put font into target dc and delete old one
    DeleteObject , SelectObject(hDC, hfont)
    
    
    End Sub
    then put a new picturebox on your form, make it invisible and pass it, along with the handle of the window whose font you wish to change to the setwindow font function


    Hope this helps

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19
    That kewl thanks for your reply sam.
    Best wishes,
    vbkids

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width