Results 1 to 22 of 22

Thread: Change desktop.

Threaded View

  1. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change desktop.

    Here it is but the background of the textbox can not be made transparent
    without loosing the digits visibility. A label will not be any better since it is
    not a real transparent backcolor.

    This is a screenshot of it on my desktop (clouds).




    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, _
    4. ByVal Y2 As Long) As Long
    5.  
    6. Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, _
    7. ByVal nCombineMode As Long) As Long
    8.  
    9. Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, _
    10. ByVal bRedraw As Boolean) As Long
    11.  
    12. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    13.  
    14. ' Constants used by the CombineRgn function
    15. Private Const RGN_AND = 1
    16. Private Const RGN_OR = 2
    17. Private Const RGN_XOR = 3
    18. Private Const RGN_DIFF = 4
    19. Private Const RGN_COPY = 5
    20.  
    21. Private Sub Form_Activate()
    22.  
    23.     Dim rgnForm As Long, rgnCombined As Long
    24.     Dim rgnControl As Long, X As Long
    25.     Dim formWidth As Single, formHeight As Single
    26.     Dim borderWidth As Single, titleHeight As Single
    27.     Dim ctlLeft As Single, ctlTop As Single
    28.     Dim ctlWidth As Single, ctlHeight As Single
    29.     Dim ctl As Control
    30.  
    31.     ' Calculate the form area
    32.     borderWidth = (Me.Width - Me.ScaleWidth) / 2
    33.     titleHeight = Me.Height - Me.ScaleHeight - borderWidth
    34.     ' Convert to Pixels
    35.     borderWidth = ScaleX(borderWidth, vbTwips, vbPixels)
    36.     titleHeight = ScaleY(titleHeight, vbTwips, vbPixels)
    37.     formWidth = ScaleX(Me.Width, vbTwips, vbPixels)
    38.     formHeight = ScaleY(Me.Height, vbTwips, vbPixels)
    39.    
    40.     ' Create a region for the whole form
    41.     rgnForm = CreateRectRgn(0, 0, formWidth, formHeight)
    42.    
    43.     rgnCombined = CreateRectRgn(0, 0, 0, 0)
    44.     ' Make the graphical area transparent by combining the two regions
    45.     X = CombineRgn(rgnCombined, rgnForm, rgnForm, RGN_DIFF)
    46.  
    47.     ' Make the controls visible
    48.     For Each ctl In Controls
    49.         ' Make the regions of controls whose container is the form visible
    50.         If ctl.Name <> "Timer1" Then
    51.             If TypeOf ctl.Container Is Form Then
    52.                 ctlLeft = ScaleX(ctl.Left, vbTwips, vbPixels) + borderWidth
    53.                 ctlTop = ScaleX(ctl.Top, vbTwips, vbPixels) + titleHeight
    54.                 ctlWidth = ScaleX(ctl.Width, vbTwips, vbPixels) + ctlLeft
    55.                 ctlHeight = ScaleX(ctl.Height, vbTwips, vbPixels) + ctlTop
    56.                 rgnControl = CreateRectRgn(ctlLeft, ctlTop, ctlWidth, ctlHeight)
    57.                 X = CombineRgn(rgnCombined, rgnCombined, rgnControl, RGN_OR)
    58.             End If
    59.         End If
    60.     Next ctl
    61.    
    62.     ' Set the clipping area of the window using the resulting region
    63.     SetWindowRgn hWnd, rgnCombined, True
    64.    
    65.     ' Tidy up
    66.     X = DeleteObject(rgnCombined)
    67.     X = DeleteObject(rgnControl)
    68.     X = DeleteObject(rgnForm)
    69.    
    70. End Sub
    71.  
    72. Private Sub Command1_Click()
    73.     Unload Me
    74. End Sub
    75.  
    76. Private Sub Form_Load()
    77.     Timer1.Interval = 1000
    78.     Timer1.Enabled = True
    79.     Text1.Text = Format(Now, "MM/DD/YYYY hh:mm:ss AMPM")
    80. End Sub
    81.  
    82. Private Sub Timer1_Timer()
    83.     Text1.Text = Format(Now, "MM/DD/YYYY hh:mm:ss AMPM")
    84. End Sub
    I hope this is what you were wanting.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by RobDog888; Feb 16th, 2005 at 11:54 PM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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