From: Mike Williams on 11 Oct 2005 09:27 "Bart Steur" <solnews(a)xs4all.nl> wrote in message news:uIhVU8lzFHA.2924(a)TK2MSFTNGP15.phx.gbl... > No, that's not what I meant. Sorry. It should be semi-transparent, > something like a fade or drop shadow. With SetLayeredWindow > Attributes you can set the transparency from 0 (fully transparent) > to 255 (Fully visible) Thats what I need for my picturebox. Sorry > for setting you guys on the wrong track That's okay. Now we know what you're after we may be able to help a little more. Actually I haven't used semi transparent windows before, but I've just checked it out and it appears that you are correct. It works fine for VB Forms but doesn't appear to work at all for VB Picture Boxes (at least as far as I can see at the moment). But now we know what you're after perhaps we can suggest another way to achieve the same effect. How about a semi transparent borderless VB Form on top of your main VB form (Loaded with the "Me" attribute to keep it on top of the main Form). We can certainly make that second Form semi transparent, and with a bit of "jiggery pokery" we can also make it nicely follow the main Form as the main Form is dragged (behaving in much the same way as a Picture Box would). Try the following code. Start a new VB project which uses two Forms (Form1 is the main form and Form2 the second). In the IDE set the BorderStyle of Form 2 to none and "sprinkle it" with a few Text Boxes and Command Buttons and such like. Also add a standard code module. Then paste in the following two code blocks (Module 1code and Form1 code). By the way, change the hard coded "c:\tulips.jpg" filename in the LoadPicture function to a picture that exists on your own machine. I know it's probably not exactly what you want (just a simple test bed at the moment), but is it perhaps "on the way there"? Mike ' ************** START MODULE CODE ****************** Option Explicit Public lOldWndProc As Long Public lOldWndProc2 As Long Private Const WM_MOVE = &H3 Private Const WM_SIZE = &H5 Public Const GWL_WNDPROC = (-4) Public Declare Function SetWindowLongA Lib "user32.dll" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function CallWindowProcA Lib "user32.dll" _ (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, _ ByVal Msg As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long Public Const LWA_COLORKEY = &H1 Public Const LWA_ALPHA = &H2 Public Const GWL_EXSTYLE = (-20) Public Const WS_EX_LAYERED = &H80000 Public Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" (ByVal hWnd As Long, _ ByVal nIndex As Long) As Long Public Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" (ByVal hWnd As Long, _ ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function SetLayeredWindowAttributes _ Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, _ ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Public Function WndProc(ByVal hWnd As Long, ByVal Msg As _ Long, ByVal wParam As Long, ByVal lParam As Long) As Long If Msg = WM_MOVE Then Form2.Top = Form1.Top + 2000 Form2.Left = Form1.Left + 2000 ElseIf Msg = WM_SIZE Then Form2.Top = Form1.Top + 2000 Form2.Left = Form1.Left + 2000 End If WndProc = CallWindowProcA(lOldWndProc, hWnd, Msg, _ wParam, lParam) End Function ' ************** END MODULE CODE ****************** ' ' ' ' ************** START FORM1 CODE ****************** Option Explicit Private Sub Form_Load() Dim ret As Long Me.Picture = LoadPicture("c:\tulips.jpg") Me.Move 0, 0, 10000, 8000 DoEvents Form2.Move Form1.Left + 2000, Form1.Top + 2000, 6000, 4000 Form2.Show , Me ret = GetWindowLong(Form2.hWnd, GWL_EXSTYLE) ret = ret Or WS_EX_LAYERED SetWindowLong Form2.hWnd, GWL_EXSTYLE, ret SetLayeredWindowAttributes Form2.hWnd, 0, 128, LWA_ALPHA lOldWndProc = SetWindowLongA(Me.hWnd, GWL_WNDPROC, _ AddressOf WndProc) End Sub Private Sub Form_QueryUnload(Cancel As Integer, _ UnloadMode As Integer) SetWindowLongA hWnd, GWL_WNDPROC, lOldWndProc End Sub Private Sub Form_Unload(Cancel As Integer) Unload Form2 End Sub ' ************** END FORM1 CODE ******************
First
|
Prev
|
Pages: 1 2 3 4 Prev: MapiReadMail() Next: Converting decimal to BCD (binary coded decimal)... |