Solved

transparency

Posted on 2004-08-22
18
617 Views
Last Modified: 2013-12-25
van i makt the background form the exe file
transparant

i load a progra into the exe fule and i know how i disalble the window but i stil get the background

how do disable this
0
Comment
Question by:davyquyo
  • 10
  • 8
18 Comments
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11867924
I'm not sure I understood your question completely but try this:

It works on Win2000 and WinXP. I'm not sure that it will work on older Windows O.S.

 - create a textbox and a command button
 - paste this code:
'----------------------------------------------------------
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2&

Sub SetSemiTransparent(frm As Object, TransparencyAmount As Byte)
    SetWindowLong frm.hwnd, GWL_EXSTYLE, GetWindowLong(frm.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
    SetLayeredWindowAttributes frm.hwnd, 0, TransparencyAmount, LWA_ALPHA
End Sub

Private Sub Command1_Click()
    If Val(Text1.Text) > 255 Then Text1.Text = "255"
    If Val(Text1.Text) < 0 Then Text1.Text = "0"
   
    Call SetSemiTransparent(Form1, Val(Text1.Text))
End Sub

Private Sub Form_Load()
    Text1.Text = 100
End Sub
'------------------------------------------------------------

 - type the amount of transparency into the textbox ( 0 to 255 ) and press command button
 - the complete form should now become semi-transparent or even completely invisible
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11868254
this is very cool bu not exactly what i ment

i have somthing that looks what i want

http://www.davyquyo.be/xfire.doc 

on this url there's a picture tou can see that there's a program open that have no window and no window background how do i do that
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11872123
ok i should say a little more

i'm a flash scripter and i want to import de flash into
the exe file and if you open it that you can see the flash but not the window

i know how i import flash but i don't know how i get lost of the window
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 11

Expert Comment

by:dbrckovi
ID: 11874480
Oh.

This is also possible, but again, I'm not sure about Win9x OS'es

 - create a form with 3 command buttons and paste this
'----------------------------------------------------------------------------
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Dim Shape As Long

Private Sub Command1_Click()
    Shape = CreateEllipticRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
    SetWindowRgn Me.hWnd, Shape, True
End Sub

Private Sub Command2_Click()
    Shape = CreateRoundRectRgn(50, 50, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, 20, 20)
    SetWindowRgn Me.hWnd, Shape, True
End Sub

Private Sub Command3_Click()
    Shape = CreateRectRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
    SetWindowRgn Me.hWnd, Shape, True
End Sub
'-------------------------------------------------------------------------------------------------------

The idea is to create some Region (shape) using 'Create....Rgn' API function and then assign this shape to a window using SetWindowRgn

This example shows only predefined shapes: Ellipse, Round Rectangle and normal rectangle, but it is possible to create more complex shapes by combining simple shapes.
So it is even possible to create holes in the window but I can't remember how to do this at the moment.

I'll know it tommorow when I get to my computer at work. I have it saved somewhere there.

Regards!  Until tommorow.....
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11875143
fore al the troble you have done for me

i'l raise it with 100 points but
this is what i can and what i have
this is the result:
http://www.davyquyo.be/Project1.exe

this is what i want without the window
this is the project i have
http://www.davyquyo.be/Project1.vbp
http://www.davyquyo.be/Project1.vbw

thanx for the help
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11875407
ok it seems you also wil need this
http://www.davyquyo.be/intro.swf

the intro is the flash that's been loaded into the exe
the intro must bu placed on this location
c:\intro.swf
there is where he load it for now

i just want thet the flash canbeen seen wthout a window or background

that's was the point al allong
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11876769
Ok. Another try.... :)

If I understand it correctly now, then all you have to do is the following:

 - set form's Borderstyle property to 0-None
 - stretch form to desired size
 - set form's StartUpPosition property to 2-CenterScreen
 - create a ShockwaveFlash control
 - paste this code
'--------------------------------------------------------------------------------------
Private Sub Form_Activate()
    ShockwaveFlash1.LoadMovie 0, "c:\intro.swf"
    ShockwaveFlash1.Play
End Sub

Private Sub Form_Load()
    ShockwaveFlash1.Top = 0
    ShockwaveFlash1.Left = 0
    ShockwaveFlash1.Width = Me.Width
    ShockwaveFlash1.Height = Me.Height
End Sub
'----------------------------------------------------------------------------------------
When you compile it to exe it should show the intro without surrounding background.

However I didn't implement the code which would exit after the intro stops playing yet, becouse it seems that you didn't implement it in your EXE.






To exit the application when the intro stops playing do the following:
 - create Timer control
 - replace previous code with this:
'------------------------------------------------------------------------------------------
Private Sub Form_Activate()
    ShockwaveFlash1.LoadMovie 0, "D:\davor\Gluposti\Happy Tree Friends\05_HAVIN_A_BALL.SWF"
    ShockwaveFlash1.Play
    DoEvents
    Timer1.Interval = 10
    Timer1.Enabled = True
End Sub

Private Sub Form_Load()
    ShockwaveFlash1.Top = 0
    ShockwaveFlash1.Left = 0
    ShockwaveFlash1.Width = Me.Width
    ShockwaveFlash1.Height = Me.Height
End Sub

Private Sub Timer1_Timer()
    If ShockwaveFlash1.IsPlaying = False Then End
End Sub
'-------------------------------------------------------------


I hope this solves it, but if this is not what you wanted, feel free to ask. You don't need to increase the points.
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11876808
Correction...

Note that in second piece of code I gave you in my last comment, the line:     ShockwaveFlash1.LoadMovie 0, "D:\davor\Gluposti\Happy Tree Friends\05_HAVIN_A_BALL.SWF"
should be the same as before:                                                                   ShockwaveFlash1.LoadMovie 0, "c:\intro.swf"

I was having trouble downloading your intro.swf file so I was using one of the files from my comp for testing.
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11879630
ok but youre last code it says sothing from
object required

so it's not correct i think

and i love it what you did but stil there's is a problem

in flash we can't create a movie without a background so i alwys make the background transparand
but dan is tsil get a window
can it be created that this background can not been seen
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11879856
Where does this error message appear?

The following steps should work:

 - start New Standard EXE project
 - click on Project -> Components, find and select Shockwave Flash, click OK.
 - create Shockwave control on the form, its name should be:      ShockwaveFlash1         (It is the default name for which the code is designed)
 - create Timer control. (It is represented as a stopwatch icon in toolbar)
 - follow the steps from my previous comment



To make the control's background transparent, just click on (custom) property and change WindowMode field to Transparent.
However there is still form's background behind all of this. And this is a bit harder to remove than control's background.

There is no other way to do it (at least I don't know any) than to cut out all background based on the color of the pixels, using the method similar to my second comment.
But this is very slow becouse program has to check every pixel on the form as fast as possible.

I'll try to find another some faster way.
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11879893
you did great help but how do these programe do this

for example

msn they have a winow of there own and not the standard window
how do they do that
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11880006
Maybe it goes faster in other languages, but everything I try in VB is really slow.
Maybe I'm just not aware of any faster method, but I have seen many similar questions and they all end up cutting unwanted pixels out from the window.

It is acceptable if the transparent regions are allways in the same place, becouse then it is enough to define the region once and leave it alone, but if each frame has different areas transparent,
then it's just too much processor work to cut out everything 25 times per second.

I have some unexplored ideas left, but I'm not sure the will work. I'm trying it at hte moment but I can't promiss anything yet.
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11880118
hmmm i think it's not realy possible then

i'm very new wit h this al and how do you cut pixels in a window then

and

how do i change
form's Borderstyle property to 0-None
with a click on a button
if i have this i think it wil do a lot
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11880267
To change properties of the form on design time, just select the form, press F4 and the list of available properties will appear.

Find     Borderstyle      and double click it until you get the value you want ( or click the downarrow icon and select the value from the list)

This also works for all controls you placed on the form.



I'm examining the example from:   http://www.vb-helper.com/howto_clock_face.html

But as I said, it removes unwanted pixels only once, and you can see how much time it needs to do it. (Note the delay before the clock is actualy displayed)
It takes almost a whole second on my computer.

This is not a good method for repeating.
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11880296
Unfortunately BorderStyle property is Read only at Run-Time.

So you can't use a button in running programm to add or remove the border and titlebar.
0
 
LVL 11

Accepted Solution

by:
dbrckovi earned 200 total points
ID: 11880474
Try something like this:

 - change form's Borderstyle property back to Sizable
 - you need the timer with Interval set to 1, and a ShockwaveFlash control

'-------------------------------------------------------------
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Dim Shape As Long

Private Sub Form_Activate()
    ShockwaveFlash1.LoadMovie 0, "c:\intro.swf"
    ShockwaveFlash1.Play
End Sub

Private Sub Form_Resize()
    ShockwaveFlash1.Top = 0
    ShockwaveFlash1.Left = 0
    ShockwaveFlash1.Width = Me.Width
    ShockwaveFlash1.Height = Me.Height
End Sub

Private Sub Timer1_Timer()
    Dim IsOut As Boolean
    Dim MousePos As POINTAPI
    GetCursorPos MousePos

    IsOut = False
    If MousePos.X < Me.Left / Screen.TwipsPerPixelX + 4 Then IsOut = True
    If MousePos.X > (Me.Left + Me.Width) / Screen.TwipsPerPixelX - 4 Then IsOut = True
    If MousePos.Y < Me.Top / Screen.TwipsPerPixelY + 23 Then IsOut = True
    If MousePos.Y > (Me.Left + Me.Height) / Screen.TwipsPerPixelY - 4 Then IsOut = True

    If IsOut = True Then
        Shape = CreateRectRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
        SetWindowRgn Me.hWnd, Shape, True
    Else
        Shape = CreateRectRgn(4, 23, Me.Width / Screen.TwipsPerPixelX - 4, Me.Height / Screen.TwipsPerPixelY - 4)
        SetWindowRgn Me.hWnd, Shape, True
    End If
End Sub
'-------------------------------------------------------------------------
0
 
LVL 1

Author Comment

by:davyquyo
ID: 11881360
thanx, i wil do it with that
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11889638
Thanks for accepting.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question