Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Reticule On Screen In Game


Reticule On Screen In Game

Author
Message
toothpick
toothpick
Forum God
Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)

Group: Forum Members
Posts: 5, Visits: 1

Hello

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


Keithuk
Keithuk
Forum God
Forum God (291K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K

To make the Form stay on top then use:

Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const SWP_SHOWWINDOW = &H40
Const SWP_NOACTIVATE = &H10
Const HWND_NOTOPMOST = -2
Const HWND_TOPMOST = -1

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Sub FormOnTop(Handle As Long, OnTop As Boolean)

Dim wFlags As Long
Dim PosFlag As Long

wFlags = SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE

Select Case OnTop
    Case True
        PosFlag = HWND_TOPMOST
       
    Case False
        PosFlag = HWND_NOTOPMOST
       
End Select

SetWindowPos Handle, PosFlag, 0, 0, 0, 0, wFlags

End Sub

Private Sub Form_Load()

FormOnTop Me.hwnd, True

End Sub

Private Sub Form_Unload(Cancel As Integer)

FormOnTop Me.hwnd, False

End Sub



Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

toothpick
toothpick
Forum God
Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)

Group: Forum Members
Posts: 5, Visits: 1

That method you posted did not stay ontop of a game window, from what i tested. I tryed about 4 various games, and none stayed ontop.

Still stuck with this one, looks like its going to prove trickyer then i first thought.


Keithuk
Keithuk
Forum God
Forum God (291K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K

Well you must be doing something wrong in the code. That code I supplied will always make the Form stay on top. Unless you are calling it from different Forms then the last Form called will be on top. How many Forms do you want on top?

I use that code in all my apps where I need a Form on top, it works perfectly.



Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

toothpick
toothpick
Forum God
Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)

Group: Forum Members
Posts: 5, Visits: 1

I dont think you understand, i need something, such as a form, to stay ontop of a actual Game. such as one you buy from the shops, like ghost recon or doom. I need a dot to stay in the center of the screen ONTOP of the game.


Keithuk
Keithuk
Forum God
Forum God (291K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K

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



Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

toothpick
toothpick
Forum God
Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)

Group: Forum Members
Posts: 5, Visits: 1

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.


waynespangler
waynespangler
Forum God
Forum God (95K reputation)Forum God (95K reputation)Forum God (95K reputation)Forum God (95K reputation)Forum God (95K reputation)Forum God (95K reputation)Forum God (95K reputation)Forum God (95K reputation)Forum God (95K reputation)

Group: Forum Members
Posts: 910, Visits: 5.4K

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.

 



Wayne

I know enough to be dangerious.

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.

Cao
Cao
Forum God
Forum God (481 reputation)Forum God (481 reputation)Forum God (481 reputation)Forum God (481 reputation)Forum God (481 reputation)Forum God (481 reputation)Forum God (481 reputation)Forum God (481 reputation)Forum God (481 reputation)

Group: Forum Members
Posts: 1, Visits: 1

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


dannyrose12
dannyrose12
Forum God
Forum God (5.5K reputation)Forum God (5.5K reputation)Forum God (5.5K reputation)Forum God (5.5K reputation)Forum God (5.5K reputation)Forum God (5.5K reputation)Forum God (5.5K reputation)Forum God (5.5K reputation)Forum God (5.5K reputation)

Group: Forum Members
Posts: 13, Visits: 5
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.


Remote Control Cars | HGH supplements | Dissertation Help
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search