Solved

RasterOps

Posted on 2002-06-06
19
374 Views
Last Modified: 2012-05-04
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
Comment
Question by:luckie
  • 13
  • 6
19 Comments
 
LVL 3

Expert Comment

by:TheRedGuy
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
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
 
LVL 3

Expert Comment

by:TheRedGuy
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
Well, not many points left... :)
0
 

Author Comment

by:luckie
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
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
 
LVL 3

Expert Comment

by:TheRedGuy
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
the control seems to be invisible at the designated positions...
Thanks
JAck
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:luckie
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
It seems only working for a bmp, not a transparent gif!
Any ideas?
Rgds
Jack
0
 

Author Comment

by:luckie
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
Am I forced to use ActiveX controls?
0
 
LVL 3

Expert Comment

by:TheRedGuy
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
Thanks. I need time...getting there :)
0
 

Author Comment

by:luckie
Comment Utility
I come back, but the image still flickering (refreshing)? Any help further?
0
 
LVL 3

Expert Comment

by:TheRedGuy
Comment Utility
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
 
LVL 3

Accepted Solution

by:
TheRedGuy earned 50 total points
Comment Utility
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
 

Author Comment

by:luckie
Comment Utility
Ok now, thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In this second Micro Tutorial in the series,  viewers will learn more basic shortcuts and functions of Illustrator. In this tutorial you will learn about the eyedropper tool, zoom , ellipses and more.
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now