Results 1 to 8 of 8

Thread: Only show a region

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    Only show a region

    I want to make a 'sniper' game
    So i need to only display a piece of screen.

    And will change when mouse cursor moves.

    I dont know how to make it show only a small radius of the screen.

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Only show a region

    not too difficult.
    1. Create buffers for the following items:
    your background image
    a black square with a hole in it
    a buffer to hold the background image with the hole drawn on it.
    you then draw this onto a black screen.

    in practice, you would compute which part of the screen is going to be visible in the scope, then copy that to the 2nd buffer. then you copy the black ring onto this (using bitblt). You will be left with a round part of the screen to be shown. You then copy this onto your main display at the appropriate location.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    Re: Only show a region

    Well, I dont really know how to do it.
    I could have a massive black image with the circle. The circle would be transparent.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    Re: Only show a region

    Well, I made the picture, and used the following code to display .png file:
    http://www.vbforums.com/showthread.p...&highlight=png
    the "using ping in VB.zip"

    and so i put this into the form:
    Code:
    Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
    
    Private Sub form_load()
     Dim Token As Long
     Token = InitGDIPlus
     Picture1.Picture = LoadPictureGDIPlus("C:\users\H4X0R\desktop\sniperz.png", 250, 250, 0)
     FreeGDIPlus Token
    End Sub
    However, at the
    Code:
    LoadPictureGDIPlus("C:\users\H4X0R\desktop\sniperz.png", 250, 250, 0)
    I must put 250, 250, 0
    the end 0
    It is the color of the transparent place.
    If i dont put anything there it will be white(not transparent)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    Re: Only show a region

    It is really hard for me to get an answer without a bump.
    Nobody care to look into this topic?

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Only show a region

    Are you talking about your computer screen? The entire screen?

    If so, why don't you make your VB Form the size of the computer screen (also make it borderless). The Form will have a borderless picturebox on it the same size as your Form. Now using one of those sample projects from that link you posted load the picturebox with a black image that has a round transparent circle in it which will allow the background to show through?

  7. #7
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Only show a region

    of course you want it transparent. you are drawing it over another image. Look up in the forum how to use image buffers. You need three of them.
    1. contains the original circle
    2. contains the background image
    3. contains part of the background with the circle pasted over it, leaving a circle visible.
    then you paste #3 onto your black form.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Only show a region

    masterkert3,

    I don't know if you were able to find anything to solve your problem and if you have then great but if you haven't then perhaps this little VB project will be of help to you.

    When you run it a black Form will appear. Just do a mouse down anywhere on the black area and a sniper scope will appear showing the background through a cross-hair round circle.

    The complete image is underneath the black picturebox.
    Attached Files Attached Files

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