|
-
Jul 8th, 2006, 05:02 AM
#1
Thread Starter
Addicted Member
Add a picture on screen?
Hello,
I'm searching to draw a picture on screen. My picture would be always on top and you can follow to click under the element as if my picture doesn't exist. It's simply graphic, an image, no form or other thing...
Does exit a way to perform that? Can we think we can make a transparent picture as we can see what happen under the picture?
Thanks
-
Jul 8th, 2006, 08:30 PM
#2
Addicted Member
Re: Add a picture on screen?
While I can't figure out why someone would need/want to do this. I've played around with transparent windows. And I can give you a start.
Create a new project and copy and paste this code. It will make the form transparent.
VB 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 crKey As Long, ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = &H2
Const LWA_COLORKEY = &H1
Private Sub Form_Load()
'pass sub form name, level form 0 to 255, zero being invisible
MakeTransparent Me, 100
End Sub
Public Sub MakeTransparent(F As Form, Level As Byte)
Dim rtn As Long
rtn = GetWindowLong(F.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong F.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes F.hwnd, 0, Level, LWA_ALPHA
End Sub
This code will make it always on top. Add to form or a module, and call with MakeTop FormName,True to enable, MakeTop FormName,False to disable.
VB Code:
'in declaration section of form or module
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
'in main section of form or module
'ex. MakeTop form1,True
Public Sub MakeTop(FormName As Form, WindowState As Boolean)
Dim wFlags As Long
Dim posFlag As Long
Const Swp_Nosize = &H1
Const SWP_Nomove = &H2
Const Hwnd_TopMost = -1
Const Hwnd_NoTopMost = -2
wFlags = SWP_Nomove Or Swp_Nosize
If WindowState = True Then
SetWindowPos FormName.hwnd, Hwnd_TopMost, 0, 0, 0, 0, wFlags
Else
SetWindowPos FormName.hwnd, Hwnd_NoTopMost, 0, 0, 0, 0, wFlags
End If
End Sub
Now, even if the form is transparent. It's still going to receive the mouse clicks and retain focus. So, you still need to figure that part out.
Keith_VB6
If you have any further questions, just ask.
If this solves things, then please mark the thread resolved.
[Thread Tools] --> [Mark Thread Resolved]
-
Jul 13th, 2006, 08:07 AM
#3
Thread Starter
Addicted Member
Re: Add a picture on screen?
Thanks for these ideas...
But now I would prefer using no form and drawing only on the desk dc, paint only pixels... . I know using APIs for catching and playing with DCs. But if I managed to draw continously on screen throught Timers, this way draws a flickering image... Is a way to avoid these flashes?
-
Jul 13th, 2006, 07:14 PM
#4
Addicted Member
Re: Add a picture on screen?
I don't know what you're drawing. But the only advice I can give is to draw to another DC and then BitBlt to the desktop. But then, you probably knew that.
Maybe, there's a way with DirectX. But, I've never played with DirectX.
Keith_VB6
If you have any further questions, just ask.
If this solves things, then please mark the thread resolved.
[Thread Tools] --> [Mark Thread Resolved]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|