Results 1 to 3 of 3

Thread: Forms ontop of Everything

  1. #1

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211

    Forms ontop of Everything

    I'm making a program that lets you see the time while you're in a game so you dont have alt tab. Right now it stays above everything BUT the game here is my code:

    Code:
    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 Const HWND_TOPMOST = -1 'bring to top and stay there
    Private Const HWND_NOTOPMOST = -2 'put the window into a normal position
    Private Const SWP_NOMOVE = &H2 'don't move window
    Private Const SWP_NOSIZE = &H1 'don't size window
    Private Declare Function GetForegroundWindow Lib "user32" () As Long
    
    Private Sub Timer1_Timer()
    'If the window on top is not this window...
        If Me.hwnd = GetForegroundWindow Then
            'Make this form be on top
            Call SetWindowPos(GetForegroundWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) 'Make the window on top below 'this form
            Call SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
        End If
    
    End Sub
    Last edited by Motoxpro; Oct 2nd, 2007 at 09:23 PM.

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Forms ontop of Everything

    Hardware accelerated windows are above everything. The only way you'll possibly get it above the game is to try one of two things:

    a) Draw directly to the desktop device context, and make sure it refreshes either at the exact same fps as the game, or more frequently.

    b) Hook the game window and draw it using the library that the game uses (DirectX or OpenGL).. Note that, this could lead to Anti-Cheat programs picking your application up as a cheat.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Re: Forms ontop of Everything

    get a small second display

    or a desk clock!
    Last edited by ididntdoit; Jan 17th, 2008 at 05:32 PM.
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

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