473,698 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keeping form always on top of fullscreen game

133 New Member
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 8056
VBWheaties
145 New Member
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 New Member
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 Recognized Expert Expert
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 New Member
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
3092
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 code in question follows: <code> this.setUndecorated(true); GraphicsDevice gd = this.getGraphicsConfiguration().getDevice(); if(gd.isFullScreenSupported()) {
179
44383
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
20
3280
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 wants a desktop application made out of Internet technologies. We're writing an application that has JavaScript enabled as a client machine requirement. We need to support Windows with IE 5+ and Netscape 7+ plus Mac with IE 5+ and Netscape 6.2+.
10
11175
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; now I get the title bar and status bar too. Any ideas?
4
3558
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 seem to write anything about that. Here is a little example of what I mean, done in PureBasic : http://rapidshare.de/files-en/263361/Examples.rar.html If it is possible, where can I download some simple C# code examples on that ?
2
10040
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 the form gives the following "Microsoft Development Environment" message: "Compiler errors occured when generating a Windows Forms wrapper for ActiveX control 'AxMSTSCLib'. Source code saved in '...AxInterop.MSTSCLib.cs'. c:Documents and...
0
1190
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 the text. I want to have some info from another program on top. Probebly got more problems coming, but just one at a time :) Anyone have an idea how to do this? havent yet found something that can help me.
0
1575
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 DVDs in fullscreen mode i use directdraw overly but it seems cannot work when other fullscreen directx app is running. the overlay sample code : http://www.gamedev.net/community/forums/topic.asp?topic_id=367591
0
1828
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 application going, the popup will steal focus almost randomly causing the game to minimize. This is extremely annoying. Is there a way to detect if anything is running in fullscreen mode? That way I can prevent the popup from opening if there is....
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8901
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.