-
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?
-
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).
-
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
-
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.
-
Ah. I see; it must've been something else that had that DC pointer prob, glad you figured it out.