Results 1 to 2 of 2

Thread: Simple Text On Screen (Like CD Players)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    IL, USA
    Posts
    5

    Simple Text On Screen (Like CD Players)

    I'm looking for a way to make transparent tex appear on the Screen (modal-less). You've probably seen the effect if you have a keyboard with CD controls right on it. The attached image has a perfect example of what I'm talking about.

    Anyone know how to do it?
    Attached Images Attached Images  
    iawix.com software...
    http://www.iawix.com/

  2. #2
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    Could try something like ths, just change strText to be your message. x and y are the screen coords in pixels.

    put this in the declares section of your form
    Code:
    Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
      "CreateFontIndirectA" (lpLogFont As logFont) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc _
      As Long, ByVal hobject As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal _
      hobject As Long) As Long
    Private Const LF_FACESIZE = 32
    
    
    Private Type logFont
      lfHeight As Long
      lfWidth As Long
      lfEscapement As Long
      lfOrientation As Long
      lfWeight As Long
      lfItalic As Byte
      lfUnderline As Byte
      lfStrikeOut As Byte
      lfCharSet As Byte
      lfOutPrecision As Byte
      lfClipPrecision As Byte
      lfQuality As Byte
      lfPitchAndFamily As Byte
      lfFaceName As String * LF_FACESIZE
    End Type
    
    Private myLogfont As logFont
    
    Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" ( _
            ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, _
            ByVal lpString As String, ByVal nCount As Long) As Long
    
    Private Declare Function CreateDCAsNull Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, lpDeviceName As Any, lpOutput As Any, lpInitData As Any) As Long
    
    
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    
    
    Private Const TRANSPARENT = 1
    
    Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
    put this code in a Command button or something
    Code:
    Dim prevFont    As Long
    Dim ret         As Long
    Dim strText     As String
    Dim hfont       As Long
    Dim hdc         As Long
    Dim x            As Long
    Dim y            As Long
    
    
        x = 100
        y = 100
        strText = "Example String"
        
        ' First get the Desktop DC:
        hdc = CreateDCAsNull("DISPLAY", ByVal 0&, ByVal 0&, ByVal 0&)
        
        'Create an indirect font to use on the Desktop
        myLogfont.lfEscapement = 0 
        myLogfont.lfFaceName = "Arial" & Chr$(0) 'Null character at end
        myLogfont.lfHeight = 0 
        myLogfont.lfWidth = 14
        
        myLogfont.lfCharSet = 0
        
        myLogfont.lfQuality = 255
        myLogfont.lfClipPrecision = 255
        myLogfont.lfOutPrecision = 255
        myLogfont.lfWeight = 255
    
        ' Create the font
        hfont = CreateFontIndirect(myLogfont)
        ' make the hDC use this created font
        prevFont = SelectObject(hdc, hfont)
        
        ' Sets transparent mode (1). (0) is opaque
        ret = SetBkMode(hdc, TRANSPARENT)
        
        ' This Actually outputs the text
        ret = TextOut(hdc, x, y, strText, Len(strText))
    
        ' Get the prevoius selected font
        ret = SelectObject(hdc, prevFont)
        ' and delete our font
        ret = DeleteObject(hfont)
    
        ' Make sure you do this to release the GDI
        ' resource:
        DeleteDC hdc
    Dazzer

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