BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect
BitBlt diagonal roll over effect BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
Go Back  Xtreme Visual Basic Talk > > > BitBlt diagonal roll over effect


Reply
 
Thread Tools Display Modes
  #1  
Old 10-06-2012, 03:50 AM
nirolf nirolf is offline
Newcomer
 
Join Date: Jan 2012
Posts: 6
Default BitBlt diagonal roll over effect


Hello!

I have a little big problem about how can I move a picture on the diagonal (roll over effect).

I attached the example of roll over effect from right to left.

So how is done diagonally effect?

Any ideas are welcome. Thank you very much!
Attached Files
File Type: zip Waves.zip (37.4 KB, 24 views)

Last edited by nirolf; 10-06-2012 at 03:57 AM.
Reply With Quote
  #2  
Old 10-06-2012, 08:00 PM
Cerian Knight's Avatar
Cerian KnightBitBlt diagonal roll over effect Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,193
Default

I'm not sure if this is what you want, but all I did was replicate your X code for Y and plug it in so the movement is diagonal:
Code:
Private Sub waves_Timer()
Static xval As Long
Static yval As Long
Dim EndScrollX As Long
Dim EndScrollY As Long
    EndScrollX = Picture1.Width - xval
    EndScrollY = Picture1.Height - yval
    BitBlt pic1.hDC, 0, 0, EndScrollX, EndScrollY, Picture1.hDC, xval, yval, vbSrcCopy
    BitBlt pic1.hDC, EndScrollX, EndScrollY, xval, yval, Picture1.hDC, 0, 0, vbSrcCopy

mdp:
xval = (xval Mod Picture1.Width) + 3
yval = (yval Mod Picture1.Height) + 3
pic1.Refresh
End Sub
I imagine that it wouldn't be to hard to make it wrap in any direction with some modifications to the xval/yval equations, etc.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #3  
Old 10-06-2012, 11:46 PM
passel's Avatar
passelBitBlt diagonal roll over effect passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

If you're going to move it vertically, you will need to have two bitblts for the vertical split, so four bitblts altogether.

If you watch, you should notice the streaks in the lower-left, and upper right quadrants when you aren't bitblting in those areas.
To make it easy to see what areas the bitlbt is actually doing, put a pic1.Cls in front of the bitblts
Code:
'
    pic1.Cls
    BitBlt pic1.hDC, 0, 0, EndScrollX, EndScrollY, Picture1.hDC, xval, yval, vbSrcCopy
    BitBlt pic1.hDC, EndScrollX, EndScrollY, xval, yval, Picture1.hDC, 0, 0, vbSrcCopy
Even in the original code, if you add the pic1.Cls temporarily, you will see a white vertical gap at the wrap point because you are using Picture1.Width, instead of Picture1.ScaleWidth.

You should use ScaleWidth and ScaleHeight, so you get the size of the client area in the Picturebox's Scalemode, rather than the size of the picturebox (including border) in its container's scalemode.

So, to do the four quandrants, the code could be:
Code:
    BitBlt pic1.hDC, 0, 0, EndScrollX, EndScrollY, Picture1.hDC, xval, yval, vbSrcCopy
    BitBlt pic1.hDC, 0, EndScrollY, EndScrollX, yval, Picture1.hDC, xval, 0, vbSrcCopy
    BitBlt pic1.hDC, EndScrollX, 0, xval, EndScrollY, Picture1.hDC, 0, yval, vbSrcCopy
    BitBlt pic1.hDC, EndScrollX, EndScrollY, xval, yval, Picture1.hDC, 0, 0, vbSrcCopy
You should see first and last are the same as Cerian Knights.
Just added the other two quandrants in between.
Also changed the four .Width .Height to .ScaleWidth, .ScaleHeight (not shown in this snippet).
Did not leave the pic1.cls in, after verifying it works without leaving gaps or unbitblt areas.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 10-07-2012 at 12:47 AM.
Reply With Quote
  #4  
Old 10-07-2012, 12:44 AM
passel's Avatar
passelBitBlt diagonal roll over effect passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Some other things to note.
Using Mod to limit the values between 0 and .ScaleWidth (or .ScaleHeight) works as long as you're always adding (i.e. xval = (xval + 3) mod Picture1.ScaleWidth).
But, if in the future if you wanted to scroll the other way, xval = (xval - 3), the mod function would allow the number to go negative, up to -Picture1.ScaleWidth.
The BitBlt functions would not work in the negative coordinates, so you would get streaking again as the texture moved to the right.
So, for flexibility, rather than use Mod, you should just compare the computed value against 0 and your maximum, and if the value goes below 0, add the maximum, or if it goes above the maximum, then subtract the maximum, to keep the value in the positive, 0 to maximum range.

For a possibly entertaining example, I changed the code to allow dragging on the scrolling window to set the speed and direction of the scroll. You should probably also set the timer interval to something like 25 to see smoother scrolling.
This is the given code, with some variables added to track how far the mouse moves between timer ticks, and keep moving that same value when the mouse is released.
Code:
Option Explicit
Private Declare Function BitBlt Lib "gdi32" _
(ByVal desthdc As Long, ByVal destX As Long, ByVal destY As Long, _
ByVal destWidth As Long, ByVal destHeight As Long, _
ByVal srchdc As Long, ByVal srcX As Long, ByVal srcY As Long, ByVal rOp As Long) As Long

Dim mdx As Single, mdy As Single
Dim mx As Single, my As Single
Dim lx As Single, ly As Single
Dim dragging As Boolean

Private Sub pic1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  lx = X
  ly = Y
  mdx = X
  mdy = Y
  mx = 0: my = 0
End Sub

Private Sub pic1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  
  If Button = vbLeftButton Then
    dragging = True
    mdx = X
    mdy = Y
  Else
    dragging = False
  End If
  
End Sub

Private Sub waves_Timer()
  Static xval As Long
  Static yval As Long
  Dim EndScrollX As Long
  Dim EndScrollY As Long
      
  EndScrollX = Picture1.ScaleWidth - xval
  EndScrollY = Picture1.ScaleHeight - yval
  
  BitBlt pic1.hDC, 0, 0, EndScrollX, EndScrollY, Picture1.hDC, xval, yval, vbSrcCopy
  BitBlt pic1.hDC, 0, EndScrollY, EndScrollX, yval, Picture1.hDC, xval, 0, vbSrcCopy
  BitBlt pic1.hDC, EndScrollX, 0, xval, EndScrollY, Picture1.hDC, 0, yval, vbSrcCopy
  BitBlt pic1.hDC, EndScrollX, EndScrollY, xval, yval, Picture1.hDC, 0, 0, vbSrcCopy
     
  
mdp:
  
  If dragging Then
    mx = lx - mdx
    lx = mdx
  End If
  xval = xval + mx
  If xval < 0 Then xval = xval + Picture1.ScaleWidth
  If xval > Picture1.ScaleWidth Then xval = xval - Picture1.ScaleWidth
  
  If dragging Then
    my = ly - mdy
    ly = mdy
  End If
  yval = yval + my
  If yval < 0 Then yval = yval + Picture1.ScaleHeight
  If yval > Picture1.ScaleHeight Then yval = yval - Picture1.ScaleHeight
  
  pic1.Refresh
  
End Sub
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #5  
Old 10-07-2012, 05:01 AM
nirolf nirolf is offline
Newcomer
 
Join Date: Jan 2012
Posts: 6
Default

Thank you very much passel ! The code works great!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
 
BitBlt diagonal roll over effect
BitBlt diagonal roll over effect
 
-->