code using device context

Hi experts

Havent used device contest. Need to see a basic code to use device context to paint on a provided client area

PradeepYadhavAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PradeepYadhavAuthor Commented:
Havent used device context. Need to see a basic code to use device context to paint on a provided client area
0
fds_fatboyCommented:
How about this - I dragged it out of an activeX control I wrote a while time ago.

Public Sub DayGraphic(X As Long, Y As Long, Graphic As HighlightGraphic, Color As OLE_COLOR)
    Dim pic As StdPicture
    Dim hBmp As Long
    Dim bmp As BITMAP
    Dim SrcDC As Long
    Dim HoldingDC As Long
    Dim HoldingBmp As Long
    Dim PrevHoldingBmp As Long
    Dim RGBColor As Long
    Dim rcPaint As RECT
    Dim LlnghBrush As Long

    Const LstrPROCEDURE As String = MstrMODULE & ".DayGraphic" ' The procedure name.
    On Error GoTo ErrorHandler

    Select Case Graphic
    Case [Crossed out date]
        If MlnghCrossDC = 0 Then
            MlnghCrossDC = CreateCompatibleDC(picDates.hdc)
            Set pic = LoadResPicture("CrossedOut", vbResBitmap)

            MlnghCrossBmp = pic.Handle
            MlnghPrevCrossBmp = SelectObject(MlnghCrossDC, MlnghCrossBmp)
        End If

        hBmp = MlnghCrossBmp
        SrcDC = MlnghCrossDC
    Case [Ringed date]
        If MlnghRingDC = 0 Then
            MlnghRingDC = CreateCompatibleDC(picDates.hdc)
            Set pic = LoadResPicture("ringedDate", vbResBitmap)

            MlnghRingBmp = pic.Handle
            MlnghPrevRingBmp = SelectObject(MlnghRingDC, MlnghRingBmp)

        End If

        hBmp = MlnghRingBmp
        SrcDC = MlnghRingDC
    End Select

    GetObject hBmp, Len(bmp), bmp

    rcPaint.Left = 0
    rcPaint.Top = 0
    rcPaint.Right = bmp.bmWidth
    rcPaint.Bottom = bmp.bmHeight

    HoldingDC = CreateCompatibleDC(MlnghBufferDC)
    HoldingBmp = CreateCompatibleBitmap(MlnghBufferDC, rcPaint.Right, rcPaint.Bottom)
    PrevHoldingBmp = SelectObject(HoldingDC, HoldingBmp)

    RGBColor = TranslateOLEColor(Color)

    If RGBColor <> vbWhite Then
        LlnghBrush = CreateSolidBrush(RGBColor)
        FillRect HoldingDC, rcPaint, LlnghBrush
        DeleteObject LlnghBrush
        BitBlt HoldingDC, 0, 0, rcPaint.Right, rcPaint.Bottom, SrcDC, 0, 0, vbSrcPaint
        ReleaseDC HoldingBmp, SrcDC
        TransparentBlt MlnghBufferDC, X, Y, rcPaint.Right, rcPaint.Bottom, HoldingDC, 0, 0, rcPaint.Right, rcPaint.Bottom, vbWhite
        ReleaseDC MlnghBufferBmp, HoldingDC
    Else
        BitBlt HoldingDC, 0, 0, rcPaint.Right, rcPaint.Bottom, SrcDC, 0, 0, vbNotSrcCopy
        ReleaseDC HoldingBmp, SrcDC
        TransparentBlt MlnghBufferDC, X, Y, rcPaint.Right, rcPaint.Bottom, HoldingDC, 0, 0, rcPaint.Right, rcPaint.Bottom, vbBlack
        ReleaseDC MlnghBufferBmp, HoldingDC
    End If

    SelectObject HoldingDC, PrevHoldingBmp
    DeleteObject HoldingBmp
    DeleteDC HoldingDC

    Exit Sub
ErrorHandler:
'Error handler code [Generated 18/05/04 Using LCPEditToolbox Ver 1.2 build 90]
'This code block must be the last code in the procedure.
    'Clean up
    Set pic = Nothing

    With Err
        If .Source = App.Title Then
            .Source = App.Title & "::" & LstrPROCEDURE
        End If

        .Raise .Number, .Source, .Description, .HelpFile, .HelpContext
    End With

End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fds_fatboyCommented:
Looking at it that's probably a bit hefty. I haven't got time to knock up an example now and tonight I will be out drinking, but:
The first example here is probably a bit better
http://www.gameprogrammer.com/archive/html/msg06473.html
0
fds_fatboyCommented:
I'm sure we could have got there in a while with more dialogue, but frankly the question was a little vague and my answers were not relly up to much due to being a bit busy.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.