Results 1 to 5 of 5

Thread: SelectObject problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    11

    SelectObject problem

    Can someone help me out? I am new to using DC's and working with pictures, and I am running into a problem. I am trying to select an object to create a dc by doing the following:

    Dim DC As Long
    Dim Temp As IPictureDisp

    DC = CreateCompatibleDC(frmHold.hdc)

    Set Temp = frmHold.imgBeginner.Picture

    SelectObject DC, Temp

    srcDC=DC

    DeleteObject Temp
    Set Temp = Nothing

    Everything works fine up to this point. The DC is created that I want to work with, and I can manipulate the picture just like I want. However, when I go and take a look at my imgBeginner picture, it is wiped out and I can't access it anymore. Why is this?

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Its because this kind of thing actually creates some kind of pseudo-pointer, selectobject it with nothing again and it'll be changed (I think).
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    11
    Sastraxi,

    How would I SelectObject it again with nothing in it? Would I just use something like

    SelectObject 0, Empty

    If so, I tried that and it didn't change anything

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    11
    I figured out my problem.

    I wasn't releasing the DC when I was done with it. All I needed to do was to put in:

    DeleteDC srcDC

    when I was finished using it, and everythig works fine now.

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Ah. I see; it must've been something else that had that DC pointer prob, glad you figured it out.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width