منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
كيف اجعل ادوات شفافه - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم أسئلة واستفسارات الأعضاء - المنتدى القديم (http://vb4arb.com/vb/forumdisplay.php?fid=94)
+--- قسم : قسم Visual Basic 6 وما قبله (http://vb4arb.com/vb/forumdisplay.php?fid=167)
+--- الموضوع : كيف اجعل ادوات شفافه (/showthread.php?tid=7619)



كيف اجعل ادوات شفافه - شمس الدين 03 - 11-02-13

السلام عليكم

اود اعرف كيف اجعل الادوات شفافه

اداة البتون
والتكست بوكس

والادوات الاخرى

بارك الله فيكم


كيف اجعل ادوات شفافه - ولد رائع - 12-02-13

هذا كود لاخفاء الفورم واظهار الادوات الموجوده فيه ان شاء الله تستفيد منها

PHP كود :
Option Explicit
    
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As LongByVal Y1 As LongByVal X2 As LongByVal Y2 As Long) As Long
    
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As LongByVal hSrcRgn1 As LongByVal hSrcRgn2 As LongByVal nCombineMode As Long) As Long
    
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As LongByVal hRgn As LongByVal bRedraw As Boolean) As Long
    
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    
' Constants used by the CombineRgn function
    Private Const RGN_AND = 1
    Private Const RGN_OR = 2
    Private Const RGN_XOR = 3
    Private Const RGN_DIFF = 4
    Private Const RGN_COPY = 5

Private Sub Form_Activate()
    Dim rgnForm As Long, rgnCombined As Long
    Dim rgnControl As Long, x As Long
    Dim formWidth As Single, formHeight As Single
    Dim borderWidth As Single, titleHeight As Single
    Dim ctlLeft As Single, ctlTop As Single
    Dim ctlWidth As Single, ctlHeight As Single
    Dim ctl As Control
    ' 
Calculate the form area
    borderWidth 
= (Me.Width Me.ScaleWidth) / 2
    titleHeight 
Me.Height Me.ScaleHeight borderWidth
    
' Convert to Pixels
    borderWidth = ScaleX(borderWidth, vbTwips, vbPixels)
    titleHeight = ScaleY(titleHeight, vbTwips, vbPixels)
    formWidth = ScaleX(Me.Width, vbTwips, vbPixels)
    formHeight = ScaleY(Me.Height, vbTwips, vbPixels)
    ' 
Create a region for the whole form
    rgnForm 
CreateRectRgn(00formWidthformHeight)
    
rgnCombined CreateRectRgn(0000)
    
' Make the graphical area transparent by combining the two regions
    x = CombineRgn(rgnCombined, rgnForm, rgnForm, RGN_DIFF)
    ' 
Make the controls visible
    
For Each ctl In Controls
        
' Make the regions of controls whose container is the form visible
        If TypeOf ctl.Container Is Form Then
            ctlLeft = ScaleX(ctl.Left, vbTwips, vbPixels) + borderWidth
            ctlTop = ScaleX(ctl.Top, vbTwips, vbPixels) + titleHeight
            ctlWidth = ScaleX(ctl.Width, vbTwips, vbPixels) + ctlLeft
            ctlHeight = ScaleX(ctl.Height, vbTwips, vbPixels) + ctlTop
            rgnControl = CreateRectRgn(ctlLeft, ctlTop, ctlWidth, ctlHeight)
            x = CombineRgn(rgnCombined, rgnCombined, rgnControl, RGN_OR)
        End If
    Next ctl
    ' 
Set the clipping area of the window using the resulting region
    SetWindowRgn hWnd
rgnCombinedTrue
    
' Tidy up
    x = DeleteObject(rgnCombined)
    x = DeleteObject(rgnControl)
    x = DeleteObject(rgnForm)
End Sub 



كيف اجعل ادوات شفافه - ولد رائع - 12-02-13

وهذا كود لجعل الفورم شفاف والادوات الموجوده فيه شفافه

PHP كود :
Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As LongByValcrKey As LongByVal bAlpha As ByteByVal dwFlags As Long) As Boolean
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As LongByVal nIndex As LongByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As LongByVal nIndex As Long) As Long
Const LWA_ALPHA 2
Const GWL_EXSTYLE = (-20)
Const 
WS_EX_LAYERED = &H80000

Private Sub Form_Load()
SetWindowLong hwndGWL_EXSTYLEGetWindowLong(hwndGWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes hwnd
0128LWA_ALPHA
End Sub