From: R on
Wow, thank you very much Mike.

I use Active Reports 6 for .net printing output so I'll take a look to see
if I can get a form image of it to get the transparent look.

I'll work with this and hopefully learn some along the way. It sure looks
like you've given me a lot to work with. Thank you very much,

Rich




"Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote in message
news:ug3S9Vn2KHA.4336(a)TK2MSFTNGP04.phx.gbl...
>
> "R" <a(a)b.com> wrote in message
> news:e2Dr0el2KHA.5480(a)TK2MSFTNGP05.phx.gbl...
>
>> Has anyone done this before or can provide me with a bit of advice on
>> where/how to go for this. I'm looking to click on a purchase order from
>> a list and then drag the PO (rendering the PO and therefore the
>> transparent image) and when dropped on some other process have
>> that process execute. The drag/drop is fine, I'm looking for the GUI
>> of the PO form being dragged.
>
> Not sure which parts you are having trouble with but for rendering the
> image of your Purchase Order simply draw it into a suitably sized
> invisible Autoredraw PictureBox and then set the PictureBox's Image
> property as the Picture property of a similarly sized Borderless Form,
> setting the desired translucency of the Form using
> SetLayeredWindowAttributes, which is capable of handling whatever
> translucency level you desire and which is also capable of treating any
> one specified colour as totally transparentl if you wish (for example if
> you require rounded corners).
>
> Regarding drawing the thumbnail size image of your purchase Order into the
> PictureBox, much depends on how you are constructing it. If you are
> already actually drawing a copy of it (perhaps for printing purposes)
> using GDI drawing and text outpout methods and if you are creating it as a
> metafile then drawing the thumbnail image of it at any desired size into a
> PictureBox will be trivial, but if you are drawing it some other way, or
> if perhaps you are not currently creating a "drawn" copy of it at all and
> if it is perhaps just a group of Controls on a Form or whatever then there
> are other ways of grabbing an image of it and of drawing a resized copy
> into a PictureBox. Perhaps if you post again with more details it would be
> helpful. In the meantime, if it is only the translucent Form to drag you
> are having trouble with then here is a simple example of that part of it.
> I've not included any actual dragging code because you said you have that
> part covered, so this example covers only the translucency and / or
> trabsparency). Paste it into a VB Form containing a PictureBox:
>
> Mike
>
> Option Explicit
> 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
> Private Const GWL_EXSTYLE = (-20)
> Private Const WS_EX_LAYERED = &H80000
> Private Const LWA_COLORKEY = &H1
> Private Const LWA_ALPHA = &H2
>
> Private Sub Form_Load()
> Dim retVal As Long, n As Long, clr As Long
> Dim pixwide As Long, pixhigh As Long
> Dim Translucency As Long, InvisibleColour As Long
> pixwide = 240: pixhigh = 320
> Me.ScaleMode = vbPixels
> With Picture1
> .ScaleMode = vbPixels
> .BorderStyle = vbBSNone
> .AutoRedraw = True
> .Visible = False
> .Move 200, 200, pixwide, pixhigh
> End With
> Me.Width = Me.ScaleX(pixwide, vbPixels, vbTwips)
> Me.Height = Me.ScaleY(pixhigh, vbPixels, vbTwips)
> ' draw something into picbox
> With Picture1
> .BackColor = vbWhite
> .DrawWidth = 4
> .ForeColor = vbBlue
> .FillStyle = vbFSSolid
> .FillColor = vbCyan
> Picture1.Circle (120, 120), 116
> .FillColor = vbYellow
> Picture1.Circle (120, 160), 116
> .FillColor = vbMagenta
> Picture1.Circle (120, 200), 116
> End With
> Me.Picture = Picture1.Image
> InvisibleColour = vbWhite ' or whatever you wish
> Translucency = 128 ' or whatever you wish
> retVal = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
> retVal = retVal Or WS_EX_LAYERED
> SetWindowLong Me.hwnd, GWL_EXSTYLE, retVal
> ' if you don't want transparency as well as
> ' translucency then omit the LWA_COLORKEY flag
> SetLayeredWindowAttributes Me.hwnd, InvisibleColour, _
> Translucency, LWA_COLORKEY Or LWA_ALPHA
> End Sub
>
>
>
>