A1VBCode Forums

Reticule On Screen In Game


By Keithuk - 3/31/2005

As I said that code will make a Form stay on top, thats all.

By waynespangler - 4/8/2005

Do you mean rectangle? If so then you can use the following code:

Option Explicit
Const RGN_DIFF = 4
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As LongByVal Y1 As Long, _
                                                    ByVal X2 As LongByVal Y2 As LongAs Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, _
                                                 ByVal hSrcRgn1 As Long, _
                                                 ByVal hSrcRgn2 As Long, _
                                                 ByVal nCombineMode As LongAs Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, _
                                                    ByVal hRgn As Long, _
                                                    ByVal bRedraw As LongAs Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As LongAs Long

Private Sub Form_Resize()
    Dim outer_rgn As Long
    Dim inner_rgn As Long
    Dim combined_rgn As Long
    Dim wid As Single
    Dim hgt As Single

    If WindowState = vbMinimized Then Exit Sub
    wid = ScaleX(Width, vbTwips, vbPixels)
    hgt = ScaleY(Height, vbTwips, vbPixels)
    outer_rgn = CreateRectRgn(0, 0, wid, hgt)
    inner_rgn = CreateRectRgn(4, 4, wid - 4, hgt - 4)
    combined_rgn = CreateRectRgn(0, 0, 0, 0)
    CombineRgn combined_rgn, outer_rgn, inner_rgn, RGN_DIFF
    SetWindowRgn hWnd, combined_rgn, True
    DeleteObject combined_rgn
    DeleteObject inner_rgn
    DeleteObject outer_rgn
End Sub


You have a form with only the borders showing. Resize it to any size you want. Use Keith's code to keep it on top. The center will be transparent.


By Cao - 4/9/2005

Indeed you guys don't understand what he means.

Basically, you want your form to appear on top of a full screen game.

For example, if you ever played Counter-Strike or Half-life, it's full screen and your regular apps won't stay on top of it because it's a game.


He want's to know how to make a form appear on top of a full screen game.


Correct me if I'm wrong.


~ Cao

By dannyrose12 - 1/28/2011

Advisable you must be doing something base in the cipher. That cipher I supplied will always hit the Form detain on top. Unless you are job it from polar Forms then the inalterable Change called testament be on top. How numerous Forms do you need on top? I use that codification in all my apps where I status a Mold on top, it mechanism utterly.
By toothpick - 3/28/2005


i have made a program to display a reticule on screen, for a bunch of games i use. What i want to do, is have that reticule which can be displayed ontop of the gaming window. I have made the reticule and it stays ontop of the desktop and applications on the desktop, but as soon as i open a game, it falls behind the window. Doh

Does anyone know how to make it stay ontop of the window? or any solution to make it do so?

The dot stays right in the middle of the screen and doesnt move, during gameplay. Yes i can use bluetack on the screen, but its not as good, and i have to clean the monitor all the time. haha

thanks again - toothpick

By toothpick - 3/31/2005

If you had read my original post, you would find out that is not what i need.

I know how to bring a form to the front, why i posted was to bring a dot to the front of a game.