draw on a frame control


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: draw on a frame control

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    draw on a frame control

    [Originally posted by harshad]

    how to draw on a frame using api's
    though i get hdc using Getdc function still
    drawing on a frame is not possible

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:draw on a frame control

    [Originally posted by neophile]

    You could make your own Frame with a PictureBox and a Label...

    ' On a Form, place a PictureBox with a
    ' a Label control inside it...
    Option Explicit

    Private Const BDR_SUNKENOUTER = &H2
    Private Const BDR_RAISEDINNER = &H4
    Private Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
    Private Const BF_BOTTOM = &H8
    Private Const BF_LEFT = &H1
    Private Const BF_RIGHT = &H4
    Private Const BF_TOP = &H2
    Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)

    Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type

    Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long

    Private Sub Form_Load()
    Dim vR As RECT

    With Picture1
    .BorderStyle = 0
    .AutoRedraw = True
    .ScaleMode = vbPixels
    vR.Right = .ScaleWidth - 1
    vR.Bottom = .ScaleHeight - 1
    End With
    With Label1
    .Top = 0
    .Left = 8
    vR.Top = .Height / 2
    End With
    Call DrawEdge(Picture1.hdc, vR, EDGE_ETCHED, BF_RECT)
    Picture1.Refresh
    End Sub


    ... that way, you have a PictureBox to draw on ;)
    The only other way I could think to do it would be to hook into the Frame control's window and process WM_PAINT messages yourself (but that sounds a little messy to me.)
    The above code isn't a perfect clone of a Frame, so you may want to look up DrawText() instead of using a Label.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center