PDA

Click to See Complete Forum and Search --> : I need to ask a real stupid question


Matt_T_hat
Dec 5th, 2001, 10:00 AM
BITBLT! here is I useing the fella but I must confess that I do not entirely know what I am doing.

This has rather slowed me down on


'Draw the absolute background
If X + ScrollWidth > ABBAckWidth Then 'We ned to glue at the beginnig again
'Calculate the remaining width
GlueWidth = X + ScrollWidth - ABBAckWidth
EndScroll = ScrollWidth - GlueWidth

'Blit the first part
BitBlt Me.hdc, 0, 0, EndScroll, ABBackHeight, DCABBAck, X, 0, vbSrcCopy
'Now draw from the beginning again
BitBlt Me.hdc, EndScroll, 0, GlueWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
Else
BitBlt Me.hdc, 0, 0, ScrollWidth, ABBackHeight, DCABBAck, X, 0, vbSrcCopy
End If


as I don't actually know how to go from right to left.
http://vbforums.com/showthread.php?s=&threadid=124545this is also mentioned here.

Please help this is makeing me feel realy stupid

Can anyone please explain what each var in BITBLT is used for?

007shahid
Dec 5th, 2001, 10:37 AM
I hope this answers your question

First off, what is BitBlt? It is a graphical API that lets you copy one image to another place with a bunch of different options. You can make the object non-square, with a mask, or you can flip it, rotate it, or stretch it with a bunch of it's "sister" APIs. This is the syntax of declaration as of VB6 SP4:

Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

hDestDC is the hDC of the destination. This means you can use a form, a picturebox, or anything with an hDC. EX. Picture1.hDC. The second one, X, is where you want the left of the image to be on the destination. This value is in PIXELS, not twips. The third value (Y) is where you want the top of the image. This is also a pixel value. nWidth is how large the image is, horizontally in PIXELS. If you specify the wrong width, it will not stretch, however, it will copy too much or too little. The height is the same as nWidth, except for the fact that it is called nHeight. hSrcDC is the hDC of the source, where you are getting the image from. xSrc is where you want the left of the image to be on the source. This is also a PIXEL value. ySrc is where you want the top of the image on the source to begin. Once again, this is a PIXEL value.

dwRop: This is also know as RASTER OPERATION FLAG. There are several different styles, using different RASTER OPERATION flags each

SRCCOPY = &HCC0020 - Copys the RECTANGULAR Source Region to the Destination Region.

SRCAND = &H8800C6 - Used for MASKS, ANDS the Source and Destination Regions together.

SRCPAINT = &HEE0086 - Used for SPRITES with MASKS, Paints the SPRITE onto the Non-Transparent Regions specified by the MASK.

MERGEPAINT = &HBB0226 - Used for when the Background of a SPRITE is not BLACK. Use this instead of SRCAND and use SRCAND instead of SRCPAINT.

Source: Sastraxi (http://vbden.tripod.com/articles/invmask.htm)

Matt_T_hat
Dec 5th, 2001, 04:40 PM
Thankyou for the explination.

I feazr this is going to be one of those evil techniques that takes for ever to get my head around

your explination was is nice plain english and still I don't get it.

-I feel thick :(

Zaei
Dec 5th, 2001, 05:12 PM
Look up the documentation for BitBlt in MSDN, or take a look at PaintPicture. It is a method of a PictureBox, that allows the copying from a source picbox to a dest picbox. It is essentially the same thing as BitBlt, but it is a bit more VB friendly. There is info on this in the MSDN as well.

Z.

Matt_T_hat
Dec 5th, 2001, 05:33 PM
(crying)

I hate the MSDN I have the enterprise version and I seem to spend my intire time in there thinking very rude thoughts about Mr Gates and vowing that if ever I get good enough at this languge I am damn well going to write a better version one where for example I can find anything usefull.

It's probably a very good and comprihensive help file but the good stuff is drowned out by mindless MicoSoft drivvle.

I am actually useing BITBLT already I just don't understand it enough to enable a new function I've thought of.

thanks for replying tho'

007shahid
Dec 6th, 2001, 01:50 AM
Thats the problem with Microsoft softwares. Very unreliable, unsecure and so god damn irritating. But you just cannot stay without them. Atleast for now. :(

There was this guy who asked God to make him a writer who, people will always remember, and screame at his work. He now writes help messages for Microsoft :)

Zaei
Dec 6th, 2001, 06:38 AM
MSDN is extremly helpful, but you have to understand what it is saying, or you wont get it. Probably one of the more important things is knowing how to at least read a bit of C++ (function declarations, data types, etc). BitBlt is pretty straightforward. Read Sas's tutorial, and you should get it all figure out (dont know the URL, try doing a search for his name and "invmask").

Z.

[edit]
I also find that Microsoft software is quite reliable. How much does VB crash on you (API usage aside)? MSVC almost NEVER crashes on me, nor my copy of Win2K. Microsoft gets a bad rep, but you all use their software. If you dont like it, go use Linux.

Sastraxi
Dec 6th, 2001, 07:18 AM
In 007Shalid's post, there is a link to it at the last line (Source: Sastraxi)

Matt_T_hat
Dec 7th, 2001, 07:59 PM
I'm actually secretly in awe of Microsoft as a company (ish) but I am sertain those guys think all day in computer language and probably dream in it as well.

as a result they have forgotten how to comunicate with humans the side effect of this being they couldn't write a decent help file if their life depended on it.

following the link now by the way.

Nirces
Dec 8th, 2001, 09:32 AM
MSDN is a Developers resource and not a tutorial on how do do things. as a Developers resource it is VERY good, the only problem with it, is that fact that its groupings are crap, most often stuff you want to do in VB, can be found under SDK documentation or C++.

The problem with advance coding in VB, is your using API, API isn't part of VB its part of windows that is written in C.

Understanding C++ is a must for using API.

Some quick notes.

Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

that is am API decraltion that spilts down into:

Declare <Function name you want to use> Lib <dll name> Alias <Function Name in DLL> (Parameters) as Whatever

Parameters
If it asks for a Pointer then you should put ByRef in front of it, if not ByVal

in the case of a few messages that require both depending on certain situations like SendMessage (a few of the rare messages are different) just declaire it twice changing the first name to something like SendMessageA. use sendmessageA when you need the other.

If the function all or type isn't in APIViewer you can still use it, but you need to find out the declaration from C++ (i just use a file search for containing xxx).

some calls require you be to hooked into an application which means you need to write a DLL and hook it into the application and access it via that.

as for your question on bltblt. it just puts an image where you want, if your not redrawing the entire frame each time, then you need to remove the old image (copy over background for that bit) then copy the image again increase the x value for left to right.

Matt_T_hat
Dec 9th, 2001, 09:01 PM
errrrrrrrrm!

still feel thick after that damn feaver

If it fails to make more headway into my head I think I'll just give up and write some hang man game.

JSG
Dec 12th, 2001, 07:19 AM
Just keep banging away at it!

You'll get it eventully......


Just do some more tutorials, from diffrent sites, then just keep on doing them, again, and again, and again...and eventully, it clicks :)

Sastraxi
Dec 12th, 2001, 07:33 AM
If X + ScrollWidth > ABBAckWidth Then 'We ned to glue at the beginnig again
'Calculate the remaining width
OX = X - SW
'Blit the first part
BitBlt Me.hdc, X, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
'Now draw from the beginning again
BitBlt Me.hdc, OX, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
ElseIf X + ScrollWidth < ABBAckWidth Then
OX = X + ScrollWidth
'Blit the first part
BitBlt Me.hdc, X, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
'Now draw from the beginning again
BitBlt Me.hdc, OX, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
Else
BitBlt Me.hdc, 0, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
End IfThat's (I think) working code. I would try it myself but I've just gotten up and must go do some errands :)