' a simple transparent frame ' drag it with the mouse ' exit it with esc or q key ' written by Dirk Noack 2017 Option Explicit Dim frame Dim dragPos Function GetRoundBitmap( w, h, r ) Dim maskColor = wxColor(0, 0, 0) Dim shownColor = wxColor(5, 5, 5) Dim b = wxEmptyBitmap(w, h) Dim dc = wxMemoryDC() dc.SelectObject(b) dc.SetBrush(wxBrush(maskColor, wxTRANSPARENT)) dc.DrawRectangle(0, 0, w, h) dc.SetBrush(wxBrush(shownColor, wxSOLID)) dc.SetPen(wxPenFromColor(shownColor, 2, wxSOLID)) dc.DrawRoundedRectangle(0, 0, w, h, r) dc.SelectObject(wxNullBitmap) Dim c = wxImageFromBitmap(b) c.SetMaskColour(maskColor.Red(), maskColor.Green(), maskColor.Blue()) b = wxBitmapFromImage(c) return b End Function Function GetRoundShape(w, h, r) Return wxRegionFromBitmap(GetRoundBitmap(w, h, r)) end Function Sub createFrame() frame = New wxFrame(Nothing, -1, "Fancy", wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN | wxSTAY_ON_TOP | wxFRAME_NO_TASKBAR | wxNO_BORDER | wxFRAME_SHAPED) frame.SetSize(wxSize(300, 120)) frame.SetPosition(wxPoint(400, 300)) frame.SetTransparent(120) Connect(frame, wxEVT_KEY_UP, "OnKeyDown") Connect(frame, wxEVT_MOTION, "OnMouse_Move") Connect(frame, wxEVT_LEFT_UP, "OnMouse_LeftUp") Connect(frame, wxEVT_PAINT, "OnPaint") SetRoundShape() frame.Show(TRUE) End Sub Sub SetRoundShape() Dim w, h w, h = frame.GetClientSizeWH() frame.SetShape(GetRoundShape(w, h, 10)) End Sub Sub OnPaint(event) Dim dc = wxPaintDC(frame) Dim w, h, r w, h = frame.GetClientSizeWH() r = 10 dc.SetPen(wxPenFromColorName(wxBLACK, 1, wxSOLID)) dc.SetBrush(wxBrush(wxColorFromName(wxLIGHT_GREY), wxTRANSPARENT)) dc.DrawRoundedRectangle(0, 0, w, h, r) End Sub Sub OnKeyDown(event) 'quit if user press q, Q or Esc Select Case event.GetKeyCode() Case 27, 81, 113 '27 is Esc frame.Close(TRUE) Case Else event.Skip() End Select End Sub Sub OnMouse_Move(event) 'implement dragging If !event.Dragging() Then dragPos = Nothing Else If !dragPos Then frame.CaptureMouse() dragPos = event.GetPosition() Else Dim Pos = event.GetPosition() frame.Move(wxPoint(frame.GetPositionX() - (dragPos.GetX() - Pos.GetX()), frame.GetPositionY() - (dragPos.GetY() - Pos.GetY()) )) End If End If End Sub Sub OnMouse_LeftUp(event) frame.ReleaseMouse() End Sub 'create the transparent frame createframe()