Announcement

Collapse
No announcement yet.

VB Picture Box Equivalent

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VB Picture Box Equivalent

    Forgive me if this is a simple question, but how do you use create an area on a dialog which can be drawn on like a VB picture box. I need an area which has an hDC property and can draw in pixel units. Can this be done using DDT to create the dialog?

    TIA

    Jeff

  • #2
    Absolutely! My personal favorite technique is you use a label control as the "container".

    1. Add the %WS_CLIPCHILDREN style to your DDT dialog.
    2. Create a LABEL control, with the style %SS_GRAYFRAME
    3. In the %WM_PAINT event, get the DC of the LABEL control, and draw your graphics.

    Here is a snippet from one of my own applications that uses a DDT label control as a container for graphics:
    Code:
    CALLBACK FUNCTION dlgcallback()
        ...
        IF CBMSG = %WM_PAINT THEN
            ' Set the client area of the dialog dark for effect
            hDC = BeginPaint(CBHNDL, Ps)
            GetClientRect CBHNDL, Rct
            FillRect hDC, Rct, GetStockObject(%DKGRAY_BRUSH)
            EndPaint CBHNDL, Ps
    
            ' Get the DC to the label control and draw the graphics
            hDC = GetDC(GetDlgItem(CBHNDL, %ID_LABEL))
            TextOut hDC, ....more graphics...
            ReleaseDC GetDlgItem(CBHNDL, %ID_LABEL), hDC
    
            ' signal DDT engine we processed the event ourselves
            FUNCTION = 1
            EXIT FUNCTION
        ELSEIF...
            ...

    -------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X