Results 1 to 5 of 5

Thread: Bitblt transparent effects

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 'used with fnWeight
    2. Const FW_DONTCARE = 0
    3. Const FW_THIN = 100
    4. Const FW_EXTRALIGHT = 200
    5. Const FW_LIGHT = 300
    6. Const FW_NORMAL = 400
    7. Const FW_MEDIUM = 500
    8. Const FW_SEMIBOLD = 600
    9. Const FW_BOLD = 700
    10. Const FW_EXTRABOLD = 800
    11. Const FW_HEAVY = 900
    12. Const FW_BLACK = FW_HEAVY
    13. Const FW_DEMIBOLD = FW_SEMIBOLD
    14. Const FW_REGULAR = FW_NORMAL
    15. Const FW_ULTRABOLD = FW_EXTRABOLD
    16. Const FW_ULTRALIGHT = FW_EXTRALIGHT
    17. 'used with fdwCharSet
    18. Const ANSI_CHARSET = 0
    19. Const DEFAULT_CHARSET = 1
    20. Const SYMBOL_CHARSET = 2
    21. Const SHIFTJIS_CHARSET = 128
    22. Const HANGEUL_CHARSET = 129
    23. Const CHINESEBIG5_CHARSET = 136
    24. Const OEM_CHARSET = 255
    25. 'used with fdwOutputPrecision
    26. Const OUT_CHARACTER_PRECIS = 2
    27. Const OUT_DEFAULT_PRECIS = 0
    28. Const OUT_DEVICE_PRECIS = 5
    29. 'used with fdwClipPrecision
    30. Const CLIP_DEFAULT_PRECIS = 0
    31. Const CLIP_CHARACTER_PRECIS = 1
    32. Const CLIP_STROKE_PRECIS = 2
    33. 'used with fdwQuality
    34. Const DEFAULT_QUALITY = 0
    35. Const DRAFT_QUALITY = 1
    36. Const PROOF_QUALITY = 2
    37. 'used with fdwPitchAndFamily
    38. Const DEFAULT_PITCH = 0
    39. Const FIXED_PITCH = 1
    40. Const VARIABLE_PITCH = 2
    41. 'used with SetBkMode
    42. Const OPAQUE = 2
    43. Const TRANSPARENT = 1
    44.  
    45. Const LOGPIXELSY = 90
    46. Const COLOR_WINDOW = 5
    47. Const Message = "Hello !"
    48.  
    49. Private Type RECT
    50.     Left As Long
    51.     Top As Long
    52.     Right As Long
    53.     Bottom As Long
    54. End Type
    55.  
    56. Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    57. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    58. Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    59. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    60. Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    61. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    62. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    63. Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    64. Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
    65. Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal nHeight As Long, ByVal nWidth As Long, ByVal nEscapement As Long, ByVal nOrientation As Long, ByVal fnWeight As Long, ByVal fdwItalic As Boolean, ByVal fdwUnderline As Boolean, ByVal fdwStrikeOut As Boolean, ByVal fdwCharSet As Long, ByVal fdwOutputPrecision As Long, ByVal fdwClipPrecision As Long, ByVal fdwQuality As Long, ByVal fdwPitchAndFamily As Long, ByVal lpszFace As String) As Long
    66. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    67. 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
    68. Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
    69. Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
    70. Private Declare Function GetSysColorBrush Lib "user32" (ByVal nIndex As Long) As Long
    71. Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
    72. Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    73. Dim mDC As Long, mBitmap As Long
    74. Private Sub Form_Click()
    75.     Unload Me
    76. End Sub
    77. Private Sub Form_Load()
    78.     'KPD-Team 1999
    79.     'URL: [url]http://www.allapi.net/[/url]
    80.     'E-Mail: [email][email protected][/email]
    81.     Dim mRGN As Long, Cnt As Long, mBrush As Long, R As RECT
    82.     'Create a device context, compatible with the screen
    83.     mDC = CreateCompatibleDC(GetDC(0))
    84.     'Create a bitmap, compatible with the screen
    85.     mBitmap = CreateCompatibleBitmap(GetDC(0), Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
    86.     'Select the bitmap nito the device context
    87.     SelectObject mDC, mBitmap
    88.     'Set the bitmap's backmode to transparent
    89.     SetBkMode mDC, TRANSPARENT
    90.     'Set the rectangles' values
    91.     SetRect R, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY
    92.     'Fill the rect with the default window-color
    93.     FillRect mDC, R, GetSysColorBrush(COLOR_WINDOW)
    94.  
    95.     For Cnt = 0 To 350 Step 30
    96.         'Select the new font into the form's device context and delete the old font
    97.         DeleteObject SelectObject(mDC, CreateMyFont(24, Cnt))
    98.         'Print some text
    99.         TextOut mDC, (Me.Width / Screen.TwipsPerPixelX) / 2, (Me.Height / Screen.TwipsPerPixelY) / 2, Message, Len(Message)
    100.     Next Cnt
    101.  
    102.     'Create an elliptical region
    103.     mRGN = CreateEllipticRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
    104.     'Set the window region
    105.     SetWindowRgn Me.hWnd, mRGN, True
    106.  
    107.     'delete our elliptical region
    108.     DeleteObject mRGN
    109. End Sub
    110. Function CreateMyFont(nSize As Integer, nDegrees As Long) As Long
    111.     'Create a specified font
    112.     CreateMyFont = CreateFont(-MulDiv(nSize, GetDeviceCaps(GetDC(0), LOGPIXELSY), 72), 0, nDegrees * 10, 0, FW_NORMAL, False, False, False, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, "Times New Roman")
    113. End Function
    114. Private Sub Form_Paint()
    115.     'Copy the picture to the form
    116.     BitBlt Me.hdc, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, mDC, 0, 0, vbSrcCopy
    117. End Sub
    118. Private Sub Form_Unload(Cancel As Integer)
    119.     'clean up
    120.     DeleteDC mDC
    121.     DeleteObject mBitmap
    122. End Sub

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    why not just use TransparBlt?
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    If would help if we knew what the requirements/questions are.

  4. #4
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Originally posted by Hack
    If would help if we knew what the requirements/questions are.



    Was this one of those broken threads again?
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Thats what I'm thinking, but I figured that orginial poster might have reposted his/her original question.

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