开发者

Is it possible to modify the origin of a display? (win32)

开发者 https://www.devze.com 2023-02-13 20:22 出处:网络
I have a number of applications which I cannot modify(no source), they are hard coded to draw at 0,0. Normally this is not a problem however a new project(kiosk) has come along where I need to draw a

I have a number of applications which I cannot modify(no source), they are hard coded to draw at 0,0. Normally this is not a problem however a new project(kiosk) has come along where I need to draw a boarder around the outside of these applications. I am looking for a way to change display range from:

X: 0 to 1200
Y: 0 to 900

to something like:

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

I've seen a开发者_StackOverflow couple functions on MSDN like SetViewportExtEx, SetWorldTransform which fit the need however if I understand them correctly they don't do a system wide change. They are for the current process only.

I am programming in C++ but if there are settings in the registry/control panel/etc that would also work.

Has anyone else done anything like this before?

Edit 1: Window position is hard coded to 0,0


This might be overkill, but if it's something you really want to have complete control over, you could always use API hooking to intercept the Window creation by hooking CreateWindow, CreateWindowEx in the target process and altering the X Y coordinates before passing control back to the system.

Popular API hooking libraries include: Microsoft Detours, Madshi's madCodeHook, and the free, open source EasyHook.


Could you clarify what you mean by 'the applications are hard coded to draw at 0,0'? Does this mean that the position of their windows is set to 0,0, or do they have code to paint at 0,0?

Solution #1
One possible solution would be to use SetWindowPosition to simply move each of the applications to whatever position you desire.

All you would need to do is enumerate the list of HWNDS calling SetWindowPosition on each as necessary.

Solution #2
Set the working area of the desktop to be smaller. This should cause your applications to take up the working area, not the entire screen. You would then be free to put up any additional windows you need, manually position them, and draw your border.

In fact you might consider registering your border windows as 'app bars' which would automatically resize the working area.


The route I might take is making a shell application with a window and then setting the parent of the other using "SetParent"

for instance, 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 it hosted notepad in my forms window

So, Simply host the window, resize your host to the clients size + a bit, position the client in your host window where you want, and then draw around the outside.

easy peasy :)

0

精彩评论

暂无评论...
验证码 换一张
取 消