Results 1 to 13 of 13

Thread: I need to ask a real stupid question

  1. #1

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774

    Angry I need to ask a real stupid question

    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
    Code:
       
            '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?
    ?
    'What's this bit for anyway?
    For Jono

  2. #2
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    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
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  3. #3

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774

    Unhappy Thanx

    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
    ?
    'What's this bit for anyway?
    For Jono

  4. #4
    Zaei
    Guest
    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.

  5. #5

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    (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'
    Last edited by Matt_T_hat; Dec 5th, 2001 at 06:43 PM.
    ?
    'What's this bit for anyway?
    For Jono

  6. #6
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    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
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  7. #7
    Zaei
    Guest
    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.

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    In 007Shalid's post, there is a link to it at the last line (Source: Sastraxi)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    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.
    ?
    'What's this bit for anyway?
    For Jono

  10. #10
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    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.
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  11. #11

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    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.
    ?
    'What's this bit for anyway?
    For Jono

  12. #12
    Junior Member
    Join Date
    Sep 2001
    Posts
    22
    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
    Two Wrongs May Not Make A Right, But Three Rights Make A Left....

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    VB Code:
    1. If X + ScrollWidth > ABBAckWidth Then 'We ned to glue at the beginnig again
    2.            'Calculate the remaining width
    3.             OX = X - SW
    4.            'Blit the first part
    5.            BitBlt Me.hdc, X, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
    6.            'Now draw from the beginning again
    7.            BitBlt Me.hdc, OX, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
    8.         ElseIf X + ScrollWidth < ABBAckWidth Then
    9.            OX = X + ScrollWidth
    10.            'Blit the first part
    11.            BitBlt Me.hdc, X, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
    12.            'Now draw from the beginning again
    13.            BitBlt Me.hdc, OX, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
    14.         Else
    15.            BitBlt Me.hdc, 0, 0, ScrollWidth, ABBackHeight, DCABBAck, 0, 0, vbSrcCopy
    16.         End If
    That's (I think) working code. I would try it myself but I've just gotten up and must go do some errands
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width