ورود

View Full Version : فرم با شفافیت 50 درصد



احمد ذبیحی
دوشنبه 22 فروردین 1384, 18:06 عصر
با سلام به همه دوستان
می خواستم بدونم میشه یک فرم با شفافیت 50 درصد در vb6 ساخت یا نه

بابک زواری
دوشنبه 22 فروردین 1384, 18:43 عصر
بله اگر XP داری یک API خاص این کار هست و اگر در 98 هستی از API به نام
BitBlt

احمد ذبیحی
دوشنبه 22 فروردین 1384, 18:51 عصر
نام api موجود در ویندوز xp رو هم ممنون می شم اگه به من بدید

بابک زواری
دوشنبه 22 فروردین 1384, 19:02 عصر
باید بگردم الان اصلا حضور ذهن ندارم

mohsengrisly
دوشنبه 22 فروردین 1384, 23:44 عصر
بازم سلام خدمت همه عزیزان
اینم یه نمونه خوب از صفر تا 100 هر چقدر که خواستی شفاف کن
امیدوارم بدرد بخور باشه
:موفق:

علی جباری
سه شنبه 23 فروردین 1384, 08:32 صبح
منم یه چیزی دارم ببینید چطوره. البته یادم نیست از کجا پیداش کردم

mohsengrisly
سه شنبه 23 فروردین 1384, 11:33 صبح
این که مشکلی نیست
اخه منم یادم نیست از کجا پیدا کردم :mrgreen:
مهم اینه که کار دوستمان راه افتاد :موفق:

حامد مصافی
چهارشنبه 24 فروردین 1384, 11:40 صبح
بله اگر XP داری یک API خاص این کار هست و اگر در 98 هستی از API به نام
BitBlt

:strange:
جناب زواری فرمودید BitBlt ???????!!!!!!!!!!! :گیج: :گیج: :گیج:

احمد ذبیحی
چهارشنبه 24 فروردین 1384, 17:29 عصر
با تشکر فراوان از کمک همه دوستان عزیز :flower: :تشویق: :موفق:

بابک زواری
چهارشنبه 24 فروردین 1384, 20:46 عصر
چند وقت پیش یک سری سورس گذاشته بودم همیجا که یکی از اونا افکتهایی رو صفحه نمایش میداد
از قبیل ذوب کردن صفحه نمایش و ریختن پودر و . . . اونا با کمک همین API بود
مشخصات به شرح زیر هست


Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (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

· hdcDest
Identifies the destination device context.

· nXDest
Specifies the logical x-coordinate of the upper-left corner of the destination rectangle.

· nYDest
Specifies the logical y-coordinate of the upper-left corner of the destination rectangle.

· nWidth
Specifies the logical width of the source and destination rectangles.

· nHeight
Specifies the logical height of the source and the destination rectangles.

· hdcSrc
Identifies the source device context.

· nXSrc
Specifies the logical x-coordinate of the upper-left corner of the source rectangle.

· nYSrc
Specifies the logical y-coordinate of the upper-left corner of the source rectangle.

· dwRop
Specifies a raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color.
The following list shows some common raster operation codes:
BLACKNESS
Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.)
DSTINVERT
Inverts the destination rectangle.
MERGECOPY
Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator.
MERGEPAINT
Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.
NOTSRCCOPY
Copies the inverted source rectangle to the destination.
NOTSRCERASE
Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color.
PATCOPY
Copies the specified pattern into the destination bitmap.
PATINVERT
Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator.
PATPAINT
Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator.
SRCAND
Combines the colors of the source and destination rectangles by using the Boolean AND operator.
SRCCOPY
Copies the source rectangle directly to the destination rectangle.
SRCERASE
Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.
SRCINVERT
Combines the colors of the source and destination rectangles by using the Boolean XOR operator.
SRCPAINT
Combines the colors of the source and destination rectangles by using the Boolean OR operator.
WHITENESS
Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)

حامد مصافی
جمعه 26 فروردین 1384, 12:32 عصر
تابع BitBlt برای کپی تصویر یک پنجره بر روی یک کنترل دیگر به کار می رود و قابلیت شفاف کردن پنجره را ندارد

بابک زواری
شنبه 27 فروردین 1384, 00:21 صبح
مثال



'Make the form translucent...
Call MakeTranslucent(Me, tColor)

Option Explicit

'Translucent Forms...
Declare Function ReleaseDC Lib "USER32" (ByVal hWnd As Long, ByVal hdc As Long) As Long
Declare Function GetDC Lib "USER32" (ByVal hWnd As Long) As Long
Declare Function GetDesktopWindow Lib "USER32" () As Long
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
Public Const SRCCOPY = &HCC0020

'For Dragging Borderless Forms...
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "USER32" () As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2

'Prevents function recursion...
Global iRecursion As Boolean
Global tColor As Long
Public Sub DragForm(Who As Form)

On Local Error Resume Next

'Move the borderless form...
Call ReleaseCapture
Call SendMessage(Who.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)

End Sub
Public Sub MakeTranslucent(Who As Form, Optional tColor As Long) 'Was (Who as Object) before...

On Local Error Resume Next

Dim HW As Long
Dim HA As Long
Dim iLeft As Integer
Dim iTop As Integer
Dim iWidth As Integer
Dim iHeight As Integer

If IsMissing(tColor) Or tColor = 0 Then
tColor = RGB(0, 0, 200)
End If

Who.AutoRedraw = True
Who.Hide

DoEvents

HW = GetDesktopWindow()
HA = GetDC(HW)

'Get the Left, Top, Width and Height of the Form...
iLeft = Who.Left / Screen.TwipsPerPixelX
iTop = Who.Top / Screen.TwipsPerPixelY '+ 25 If using a form with a titlebar (border)...
iWidth = Who.ScaleWidth
iHeight = Who.ScaleHeight

'Now, Transfer the contents of the Desktop Window to the Form...
Call BitBlt(Who.hdc, 0, 0, iWidth, iHeight, HA, iLeft, iTop, SRCCOPY) 'iLeft + 4 If using a form with a titlebar (border)...

'Show...
Who.Picture = Who.Image
Who.Show

'Release the DC...
Call ReleaseDC(HW, HA)

'Add color...
Who.DrawMode = 9
Who.ForeColor = tColor
Who.Line (0, 0)-(iWidth, iHeight), , BF

End Sub

بابک زواری
شنبه 27 فروردین 1384, 00:28 صبح
اینم سورس مثال

حامد مصافی
شنبه 27 فروردین 1384, 10:30 صبح
سلام جناب زواری
من قصد مجادله ندارم
ولی این کد یک کپی از دسکتاپ را روی فرم ترسیم می کند و سپس فرم را نمایش می دهد
و این موضوع باعث می شود بیننده تصور کند واقعاً از پشت فرم دسکتاپ دیده می شود

بابک زواری
شنبه 27 فروردین 1384, 12:38 عصر
خوب بله دقیقا با این کلک این کار رو انجام دادم چون در ویندوز 98 امکان این
کار نبود مجبور شدم از این روش استفاده کنم.
وگرنه در XP که راه ساده تری هست ولی چون من میخواستم بدون توجه
به محیط کار کنم از این راه رفتم.