How to resize Game Window with the Windows API? - windows

I am developing a 2D video game and trying to implement a good fullscreen extension to the game maker, Clickteam Fusion.
I've tried using SetWindowPos and I can get the window to look the correct size, but then when using the Steam Overlay the overlay is showing offscreen because it is using the initial window size I set in the game maker.
it is clear that the SetWindowPos is just shrinking the window to fit the aspect ratio of my monitor, but the game still is acting like the game is still the initial window size so content gets loaded that is actually outside the display, including Steam Overlay notifications and such.
Is there a better Windows API command I can use to actually adjust a game window?

Related

Is Direct2D supposed to respect WS_CLIPCHILDREN?

My main window has some child windows that contain movies managed by Media Foundation. The main window is drawn using Direct2D. I'm not doing any clipping when drawing the main window with Direct2D because I expect this to be done by BeginPaint in my WM_PAINT.
When my window is rather small, everything is drawn fine. However, when I maximize it to a 4096x2304px resolution, there is visible flicker and I can quickly see the stuff drawn by Direct2D beneath the Media Foundation child windows before Media Foundation draws its contents to them so it looks like Direct2D clipping doesn't really happen.
Is this true? Do I have to manually set up a Direct2D clipping region to prevent it from overdrawing the Media Foundation child windows or am I doing something wrong here? My main window has WS_CLIPCHILDREN set.

Overlay window drawing which appears in screen captures of other applications

We need to overlay a target window with a custom shape and tracks the position of the target window such that the overlay drawing always appears above it. Also, the overlay drawing should appear in screenshots taken using BitBlt or PrintClient by screen-capturing tools like Camtasia, Debut, etc. Also, moving the target window around should not leave traces of the drawing at earlier location. The target window is not made using our code.
So far we've tried several ways but each method has its problems:
1) Layered Window:
Using a layered window as the child/owned window of the target window is the easiest thing and it works. But the problem is on Windows 7 and XP, layered windows do not appear in a BitBlt done without the CAPTUREBLT flag and the screen-capturing tools may call BitBlt without the flag, thereby skipping our window from the capture.
2) Region Window:
The crude approach to support all Windows versions then is to use a region window using SetWindowRgn and make the target window its owner. However, region windows are generally very slow in rendering complex shapes and also impact the performance of other windows, sometimes to the point of freezing the application. Region window also leaves traces on dragging the application window.
3) Subclassing and Drawing on HDC:
Another approach is to sub-class the target window and draw the shape on its HDC on the OnPaint() event inside the window procedure hook. The shape can be drawn on the desktop window instead too. The problem is that applications may draw without a paint event, like when some text is selected using the cursor, and such drawing may erase a part of the custom drawing. Tracking all possible paint events is not a good way to do this.
4) Drawing continuously in a timer:
The last resort is to draw the custom shape on the target window in a timer continuously so the drawing is always above the target, even on text selection. But this may show a bit of flicker when the text is selected. Not to mention, it is very performance heavy to draw constantly.
Question
What is the best way to achieve an overlay drawing which works on all Windows versions (since XP) at the same time appearing in screen-captures. We've exhausted all approaches. Is there some method I'm missing? Can the above mentioned ways be used with some improvement? Is DirectX an option? I'm looking for methods with fast rendering capacity to achieve this. Appreciate any help!
I think the best solution to draw an overlay window, is to use a double-buffered technique GDI, just like in this example:
Overlay Drawing in CScrollView
I have myself the same task, and the only solution was that one. Hope it help you.

In win32 programming, why can't I see the video in Media Player if I overlay a transparent window (via WS_EX_LAYERED) over it?

I've written an application that overlays a transparent window over the screen. The transparent window is created by applying WS_EX_LAYERED style to it, and calling SetLayeredWindowAttributes(
hWnd,
RGB(0,0,255),
127,
LWA_ALPHA
);
I just run into a problem that when this transparent window is over Media Player that plays a video, the transparent region simply becomes gray and I can't see through it.
Why is that? And what can I possibly do to see the contents of Media Player through the transparent window?
I'm not sure about the following but it is what I believe it may be based on my knowledge.
Usually an overlay surface is created in the rectangle area that plays the video for hardware acceleration purposes and video card controls it (well... an application thru some api like directx controls it)
The overlay surface is draw over, let's call it, the gdi/window surface that usually is painted in black by the application.
And that's why you see the black/grey in the background.

Skinned Window: Win32 API and DirectX

I'm trying to create a borderless window using a WS_EX_LAYERED style window. The objective is to render graphics using DirectX directly to the desktop, using alpha to blend onto the current desktop windows.
Now on my system this technique seems to work perfectly. I can set various alpha levels and achieve different levels of transparency. Unfortunately several users have reported severe performance problems and low frame rate, making this technique unusable.
The code setup is as follows:
Create a layered (WS_EX_LAYERED extended-style) window.
Initialize DirectX using the window HWND.
Create a render target using the CreateRenderTarget DirectX method.
Then during the render loop:
Render graphics to the render target using DirectX calls.
Get the HDC handle to the DirectX render target surface using GetDC method.
Update the window contents using the UpdateLayeredWindow function, specifying the DirectX surface HDC.
My question is: Am I doing something wrong? Is there a way to improve the performance of the window update. I have tried various things, like locking the render target and manually copying the bits to a DIB section to display in the window area, without success.
How big is your window? Note MSDN's documentation at http://msdn.microsoft.com/en-us/library/windows/desktop/ms633556%28v=vs.85%29.aspx says "For best drawing performance by the layered window and any underlying windows, the layered window should be as small as possible."
You may be getting a performance boost if compositing (Aero) is enabled. If Windows is already compositing, it won't have to do as much extra work to draw layered windows.
If you're not seeing any difference in performance depending on compositing, then I am probably completely off base here.

how to Map a window to 3D

I'm searching for how to render window to 3D windows Texture on D3D
for example, the windows aero-glass's preview.
a window or part of window that has a windows handler is rendered to a d3d device(i guess aero glass is maked by d3d).
my project is a 3D interective media. it is an AR project using HMD and Hand Recognizing.(Like a 3d touch interaction )My part is 3D Rendering. The WPF can do this. But i don't find the way how to do it with D3D.
Who knows the way or it is impossible on D3D? if you know, please notice me a KEYWORD that using to Google.
thanks to reading and your attention. i'm not native english user and i'm sorry that if you feel my english seems ugly.
I may suggest using dynamic textures. You first create a texture of the desired size and format. Then you get its surface, obtain HDC and pass it to a window you want be drawn. Showing a texture thru d3d device shouldn't be a problem.

Resources