473,410 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Keeping form always on top of fullscreen game

133 100+
hi guys ,
i am making a screen capture program and i want my main form to stay on top
so the user can take a screen shot of full screen games, i have found lots of stuff to keep it on top of all window but nothing works for full screen games

Below is 1 i have tried

Expand|Select|Wrap|Line Numbers
  1. Private Const HWND_TOPMOST = -1
  2. Private Const HWND_NOTOPMOST = -2
  3. Private Const SWP_NOACTIVATE = &H10
  4. Private Const SWP_SHOWWINDOW = &H40
  5. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
  6. ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
  7. ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  8.  
  9.  
  10. Private Sub SetWindowOnTop(f As Form, bAlwaysOnTop As Boolean)
  11.    Dim iFlag As Long
  12.  
  13.    iFlag = IIf(bAlwaysOnTop, HWND_TOPMOST, HWND_NOTOPMOST)
  14.  
  15.    SetWindowPos f.hwnd, iFlag, f.Left / Screen.TwipsPerPixelX, f.Top / Screen.TwipsPerPixelY, _
  16.                 f.Width / Screen.TwipsPerPixelX, f.Height / Screen.TwipsPerPixelY, SWP_NOACTIVATE Or SWP_SHOWWINDOW
  17. End Sub
Any help will be appreciated.
<<<Gobble>>>
Feb 19 '08 #1
4 8021
VBWheaties
145 100+
hi guys ,
i am making a screen capture program and i want my main form to stay on top
so the user can take a screen shot of full screen games, i have found lots of stuff to keep it on top of all window but nothing works for full screen games

Below is 1 i have tried

Expand|Select|Wrap|Line Numbers
  1. Private Const HWND_TOPMOST = -1
  2. Private Const HWND_NOTOPMOST = -2
  3. Private Const SWP_NOACTIVATE = &H10
  4. Private Const SWP_SHOWWINDOW = &H40
  5. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
  6. ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
  7. ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  8.  
  9.  
  10. Private Sub SetWindowOnTop(f As Form, bAlwaysOnTop As Boolean)
  11.    Dim iFlag As Long
  12.  
  13.    iFlag = IIf(bAlwaysOnTop, HWND_TOPMOST, HWND_NOTOPMOST)
  14.  
  15.    SetWindowPos f.hwnd, iFlag, f.Left / Screen.TwipsPerPixelX, f.Top / Screen.TwipsPerPixelY, _
  16.                 f.Width / Screen.TwipsPerPixelX, f.Height / Screen.TwipsPerPixelY, SWP_NOACTIVATE Or SWP_SHOWWINDOW
  17. End Sub
Any help will be appreciated.
<<<Gobble>>>
add a timer and call setwindowontop. make your interval like 500 (for half a second).
other apps are probably calling setwindowontop as well, making your form go below theirs.
however, if you notice it flickering, then that means the other apps are doing the same thing (calling setwindowontop in a timer event).
Feb 19 '08 #2
Bullitt
21
Try this, I'm not sure it is working, because this comes from a program that I made a long time ago. It is programmed in vb 6. Let me know if it works.

Expand|Select|Wrap|Line Numbers
  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
  2. Private Const SWP_NOMOVE = &H2
  3. Private Const SWP_NOSIZE = &H1
  4. Private Const HWND_TOPMOST = -1
  5. Private Const HWND_NOTOPMOST = -2
  6.  
  7. Private Sub Form_Activate()
  8.     SetOnTop (True)
  9. End Sub
  10.  
  11.  
  12. ' Make the form topmost or not.
  13. Private Sub SetOnTop(Optional ByVal on_top As Boolean = True)
  14.     If on_top Then
  15.         SetWindowPos hwnd, _
  16.             HWND_TOPMOST, 0, 0, 0, 0, _
  17.             SWP_NOMOVE + SWP_NOSIZE
  18.     Else
  19.         SetWindowPos hwnd, _
  20.             HWND_NOTOPMOST, 0, 0, 0, 0, _
  21.             SWP_NOMOVE + SWP_NOSIZE
  22.     End If
  23. End Sub
Feb 19 '08 #3
Killer42
8,435 Expert 8TB
I'll be really curious to see whether you manage to do this. But to be honest, I don't think it's possible.

If by "full screen" you mean maximised, then obviously it's not a problem. But assuming you mean DirectX (or whatever the latest buzzword is) like games such as World of Warcraft use, I really doubt you'll be able to do so. They effectively take over the screen and push aside the usual windowing interface. So whatever you do with your window isn't likely to have much effect, unless you make it full-screen and push the game out of the way.
Feb 20 '08 #4
gobblegob
133 100+
add a timer and call setwindowontop. make your interval like 500 (for half a second).
other apps are probably calling setwindowontop as well, making your form go below theirs.
however, if you notice it flickering, then that means the other apps are doing the same thing (calling setwindowontop in a timer event).

Good idea VBWheaties but yeah the games seem to be calling the same event because you can see the app flicker in the background.
I wonder if there is a way of forcing a a game into windowed mode

Thanks for the posts guys!!
<<<Gobble>>>
Feb 20 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Paul Munly | last post by:
Hi, I'm attempting to get a Swing application to go into Exclusive Fullscreen mode and am curious if there's something that I need to do prior to attempting to grab the fullscreen window. The...
179
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
20
by: msa | last post by:
Hi there, First off, let me say that I know that launching to full screen is a bad idea. I would never do it given the choice, but I must follow orders from my boss, the boss that desparately...
10
by: aagee | last post by:
Hi all Can someone clue me in on this? I just noticed that following doesn't work as it used to: window.open(... "fullscreen=yes" ...) Used to get a window that occupied the whole screen;...
4
by: BOOGIEMAN | last post by:
Is it possible to make a full screen program (game) in C# ? I started reading "mastering C#" book few days ago and I'm up to page 100 right now. I looked at the forward chapters and it doesn't...
2
by: Bill Struve | last post by:
Need: Auto-logon to a terminal server, start a program, and, when the user is quits the program, auto-logoff. Problem: When msrdp.ocx is added to the Toolbox, attempting to draw the control on...
0
by: Jelle | last post by:
Hi all, I am looking for a way to get text on top of a fullscreen game and still be able to play the game. I just want to use a little piece of the screen and want the game screen still behind...
0
by: n_g | last post by:
how do i popup a message when user is running other fullscreen application? eg: i want to display phone number in corner of screen even user is playing fullscreen directx/opengl game or watching...
0
by: =?Utf-8?B?RnJpam9sZXM=?= | last post by:
Hello everyone, I have a small application I wrote that sits in the systray and pops open a small window if an event occurs. Works fine, except when I'm playing games. :) If I have a fullscreen...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.