Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

RasterOps

There are quite a few rasterop constants in VB6, but I don't know which one to use. I run into a problem that when I 'paintpicture' with an image control and that when this control passes thru other controls, it starts to flicker and very seriously. I tried the vbMergePaint, vbMergeCopy and vbpatinvert options, but neither overcomes this problem, any advice?
Regards
luckie
0
luckie
Asked:
luckie
  • 13
  • 6
1 Solution
 
TheRedGuyCommented:
More info, please!

What do you mean by 'passes through other controls'? Are you allowing users to drag an image control around the screen or something?

Note, also, that whilst I may be able to help, I think this Q belongs in the VB topic area...
0
 
luckieAuthor Commented:
for example, I create an image control,  the control moves from the left side to the right side. And there is another image control in the middle of the screen, when the first control overlaps with the second control, it starts to flicker... Thanks
Jacky
0
 
TheRedGuyCommented:
Have you tried BitBlt instead of the PaintPicture method? Also, how important is this type of behaviour? Are you writing a game, for instance? If you post some code I'll play around with it for you with some API calls. Depends what youu are trying to achieve, though....

btw, did you post to VB topic area, too?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
luckieAuthor Commented:
Well, not many points left... :)
0
 
luckieAuthor Commented:
My background is a bitmap (bmp) and my image control is a transparent gif (gif), What rasterops do I use? I want the image's back to be seen thru with the background...
Thanks
Jack
0
 
luckieAuthor Commented:
some code:

Dim x123 As Long
Dim y123 As Long


Private Sub Form_Load()
    WindowState = 2
    x123 = 11640
    y123 = 5880
    Image1.Picture = LoadPicture("C:\images\vna7.gif")
    Image1.Stretch = True
   
    Timer1.Enabled = True
    Timer1.Interval = 10
   
End Sub

Private Sub Timer1_Timer()
   x123 = x123 + 10
   y123 = y123 + 10
   PaintPicture Image1, x123, y123, 1620, 1455, 10, 10, 1620, 1455, vbSrcPaint
End Sub
0
 
TheRedGuyCommented:
OK, let's make sure I understand the problem...

I ran your code and you are not moving an Image control anywhere. You are a painting a picture of the Image control directly onto the form at points X and Y. The image control remains stationary but flickers whenever you paint a picture of it onto the form. That is what you want to fix, correct?
0
 
luckieAuthor Commented:
But according to the code snippet, it should be moving at the positions of x123,y123,and yes, i want to fix the flickering happened when the image object is moving across the screen (and when two objects overlap each other)
Regards
Jacky
0
 
luckieAuthor Commented:
the control seems to be invisible at the designated positions...
Thanks
JAck
0
 
luckieAuthor Commented:
When I use vbSrcCopy, there is a patch of whiteness at the designated positions. However, the image can't be seen with other ops.
Thanks
Jack
0
 
luckieAuthor Commented:
It seems only working for a bmp, not a transparent gif!
Any ideas?
Rgds
Jack
0
 
luckieAuthor Commented:
I find out that the rasterops only work for bmp images, it should be left out when loading a transparent gif. But on the other hand, the transparent gif is not displayed as 'transparent'... pls help
Regards
Jack
0
 
luckieAuthor Commented:
Am I forced to use ActiveX controls?
0
 
TheRedGuyCommented:
Jack,

you are NOT moving the image control at all in your code snippet! You are merely painting a picture of it ON THE FORM whilst leaving the Image control in its original location.

If you were moving the image control, then your code snippet would look more like this....

Dim x123 As Long
Dim y123 As Long


Private Sub Form_Load()
   WindowState = 2
   x123 = 11640
   y123 = 5880
   Image1.Picture = LoadPicture("C:\images\vna7.gif")
   Image1.Stretch = True
   
   Timer1.Enabled = True
   Timer1.Interval = 10
   
End Sub

Private Sub Timer1_Timer()
  x123 = x123 + 10
  y123 = y123 + 10
  With Image 1
    .Move x123, y123
  End With
End Sub


Try it and you'll see what I mean....
0
 
luckieAuthor Commented:
Thanks. I need time...getting there :)
0
 
luckieAuthor Commented:
I come back, but the image still flickering (refreshing)? Any help further?
0
 
TheRedGuyCommented:
OK, I'll check that when I get home (at work currently and don't have VB)

We now agree, though, that the image control is moving now whereas it was not before, correct? However, you still have a problem with flickering which I think I can fix.
0
 
TheRedGuyCommented:
Right, add a new module to your project and paste this in:

Declare Function LockWindowUpdate Lib "user32" (ByVal hWnd As Long) As Long

Paste this into the code for your form:

Private Sub LockWindow(hWnd As Long)
    LockWindowUpdate hWnd
End Sub

Private Sub UnlockWindow()
    LockWindowUpdate 0
End Sub

Modify your snippet, replacing....

 With Image1
   .Move x123, y123
 End With
 
with this....

 LockWindow (Form1.hWnd)
 
 With Image1
   .Move x123, y123
 End With
 
 UnlockWindow


Is it OK, now? Are you running on NT or Win 95/98/2000/XP....???
0
 
luckieAuthor Commented:
Ok now, thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 13
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now