Quote Originally Posted by baka View Post
theres different ways to do it,

one way is to use 2 forms, one is the "original" that you hide and the other is the one you show.
now, using different API you copy the entire client area to a memory DC, and then do all the "effects" you want to do and then render it to the form that is empty but visible.
theres a bit of "mouse" subclassing, as you need to operate the hidden form, but nothing hard to accomplish.

another way is to loop through the hidden form and create "custom" whatever of your choice into the "empty" but visible form.
I'd surely like to see an example of the above approach, which accomplishes the same thing as shown below...:



The above shows the desired "frosted glass effect" in the "Caption-Area" of the two little "Form-like Widgets".
Each of the two Widgets has two editable TextBoxes in it, which are Child-Widgets of these "Form-Widgets" -
and no - it's not that easy to do all that Alpha-rendering correctly, when "things get nested".
(Please move the Widgets around - or resize the Form, which changes the BackGround-Image underneath, to see what I mean).

That's one of the reasons, why the RC5 (and its Alpha-capable Form- and Widget-engine) exists -
to make it easier for VB-devs, to accomplish such complex things in "no time" and with only a handful of code-lines (steps and code shown below):

- open a new empty Form-Project and ensure two Project-References: vbRichClient5 and vbWidgets

- now create a new Class-module and name it: cwFrosted
Code:
Option Explicit
 
Private WithEvents W As cWidgetBase, Blr As cCairoSurface, Offs As Long

Private Sub Class_Initialize()
  Set W = Cairo.WidgetBase 'as usual, set the WidgetBase and define a few defaults
      W.Moveable = -1: W.Alpha = 0.25
      W.FontSize = 11: W.BackColor = vbWhite
  'add two TextBoxes into this little "Form-like" widget-container
  Widgets.Add(New cwTextBox, "txt1", 16, 49, 120, 24).Text = "cwTextBox 1"
  Widgets.Add(New cwTextBox, "txt2", 16, 77, 120, 24).Text = "cwTextBox 2"
End Sub

Public Property Get Widget() As cWidgetBase: Set Widget = W: End Property
Public Property Get Widgets() As cWidgets:  Set Widgets = W.Widgets: End Property
 
Private Sub W_Paint(CC As cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)
  Set Blr = W.BackBuffer.GaussianBlur(4, Offs) 'get a blured Surface from the current BackBuffer
  CC.RoundedRect 0, 0, W.Width, 36, 4.5, , cmTop 'define a clipping-region (using a Path-definition)
  CC.Clip: CC.RenderSurfaceContent Blr, -Offs, -Offs: CC.ResetClip 'render the blurred Surface within the clip
 
  CC.SetLineWidth 1 'the rest is normal Widget-Rendering as usual in the Paint-event
  CC.RoundedRect 0, 0, W.Width, W.Height, 4.5, True, cmTop 'a rounded Rectangle (now in full height)
  CC.Fill True, Cairo.CreateSolidPatternLng(W.BackColor, W.Alpha) 'let's fill it
  CC.Stroke , Cairo.CreateSolidPatternLng(W.BorderColor, 0.8) 'and stroke a border around it
  
  If Len(W.ImageKey) Then CC.RenderSurfaceContent W.ImageKey, 5, 4, 25, 25 'render the Icon
  W.SelectFontSettingsInto CC, W.BackColor: CC.TextOut 36, 10, W.Key, , 0.25 'CaptionText-Effect
  W.SelectFontSettingsInto CC, W.ForeColor: CC.TextOut 36, 9, W.Key 'CaptionText-Output in normal Color
End Sub
- finally put the following code into your Form
Code:
Option Explicit

Private Pnl As cWidgetForm

Private Sub Form_Load()
  With New_c.Downloads 'add a BG-Image to the ImageList (per download from a Web-Resource)...
    If .Download("http://vbRichClient.com/Downloads/bg.jpg").WaitForCompletion(9) Then _
       Cairo.ImageList.AddImage "bg", .Item(0).GetContentData
  End With
  Cairo.ImageList.AddIconFromResourceFile "ico", "shell32", 167, 32, 32 'add an Icon as well
  
  Set Pnl = Cairo.WidgetForms.CreateChild(hWnd) 'create a PicBox-like ChildPanel over the CairoForm-engine
      Pnl.WidgetRoot.ImageKey = "bg" 'set the panel-background to the ImageList-Key we ensured above
      Pnl.Widgets.Add(New cwFrosted, "Frosted_1", 240, 130, 200, 120).Widget.ImageKey = "ico"
      Pnl.Widgets.Add(New cwFrosted, "Frosted_2", 120, 205, 200, 120).Widget.ImageKey = "ico"
End Sub

Private Sub Form_Resize()
  ScaleMode = vbPixels: Pnl.Move 0, 0, ScaleWidth, ScaleHeight
End Sub

Private Sub Form_Terminate()
  If Forms.Count = 0 Then New_c.CleanupRichClientDll
End Sub
Well, that's it.

Olaf