Is it possible to change the origin of the display? (Win32)

I have a number of applications that I can’t change (no source), they are hardcoded to paint at 0,0. Usually this is not a problem, but a new project (kiosk) has appeared in which I need to draw a border guard outside of these applications. I am looking for a way to change the display range:

X: 0 to 1200 Y: 0 to 900 

to something like:

 X: -100 to 1100 Y: -100 to 800 

I saw a couple of functions on MSDN, such as SetViewportExtEx, SetWorldTransform, that meet the needs, but if I understand them correctly, they do not change the system change. They are for the current process only.

I program in C ++, but if there are settings in the registry / control panel / etc that will also work.

Has anyone else done something like this before?

Edit 1: Window position hardcoded to 0.0

+4
source share
3 answers

This may be redundant, but if you really want to have full control, you can always use the API connection to intercept window creation by connecting CreateWindow, CreateWindowEx in the target process and changing the XY coordinates before transferring control back to the system.

Popular APIs for connecting: Microsoft Detours , Madshi madCodeHook , and free, open source EasyHook .

+1
source

The route that I could do is to make a shell application with a window, and then set the parent of another using "SetParent"

for example in C # I did this ...

 var info = new ProcessStartInfo {FileName = "NotePad.exe", WindowStyle = ProcessWindowStyle.Normal}; var runProcess = Process.Start(info); Thread.Sleep(1000); // ugly, but more just proving a point SetParent(runProcess.MainWindowHandle, Handle); 

and he placed the notebook in my forms window

So, just place the window, change the size of your host to the size of the client + bits, place the client in your host window wherever you want, and then circle it outside.

easy peasy :)

0
source

Could you clarify what you mean by "applications hardcoded to paint at 0.0"? Does this mean that the position of their windows is set to 0.0, or do they have code for drawing at 0.0?

Decision No. 1
One possible solution would be to use SetWindowPosition to simply move each application to the desired position.

All you have to do is enumerate the HWNDS list that calls SetWindowPosition by default.

Decision number 2
Set your workspace smaller. This should cause your applications to process the workspace, not the entire screen. Then you could freely place any additional windows that you need, manually place them and draw a border.

In fact, you might consider registering your border windows as “application bars” that will automatically resize the workspace.

0
source

Source: https://habr.com/ru/post/1341722/


All Articles