2

is it possible to change the minimum size of an external window and resize it. Suppose the size of the external application window is (400,400) and the minimum size is (200,200), is there any way we can change it to say, (100,100). I have the handle of the external window.

I tried with the MoveWindow function

 internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

but it is not able to do so after the window hits minimum size. Is it not possible to do so? I am open to using either managed c# code such as UI-automation or even windows apis, pinvoke etc. Any suggestions?

leppie
  • 115,091
  • 17
  • 196
  • 297
Why
  • 626
  • 11
  • 29
  • I don't think it is possible to do so past the minimum window size, possibly due to the `MoveWindow` calling `WM_SIZE` which would check this limit. as it is an OS call, most other things would use this too – Sayse Aug 26 '14 at 10:19
  • so no way to resize then? there must be some way :) by the powerful windows programming maybe? – Why Aug 26 '14 at 10:30
  • Not past the minimum size I dont think.. its possible you could always put it in a fluid layout control inside a different window with a smaller window size but it would look a bit stupid, probably not very user friendly, and against what the developers were expecting... can I ask what you are trying to achieve by doing so? – Sayse Aug 26 '14 at 10:31
  • If you are familiar with Microsoft Lync, then Lync has a conversation window. I want to resize that a little beyond the minimum for some application of mine. – Why Aug 26 '14 at 10:33
  • I don't know it I'm afraid but I would question how legal what you are trying to do is.. again, I may be wrong, but I dont think there is a way – Sayse Aug 26 '14 at 10:37
  • its just for a demo application...no legal barriers being breached.. :) – Why Aug 26 '14 at 10:38
  • You have to try it to see if it can be done. These things are difficult and it is better with low level languages like c or c++. Set a hook to the window and intercept `WM_SIZE and WM_NCCALCSIZE` or any other messages. Go to the msdn site and read about these messages. Experiment eg discard messages, change the lparam wparam values etc. You never know – γηράσκω δ' αεί πολλά διδασκόμε Aug 26 '14 at 10:45
  • Step 1: work out how the constraint is imposed. Only you can do that. – David Heffernan Aug 26 '14 at 20:01

1 Answers1

0

It may be possible to subclass a certain control in the target window and intercept the messages before the control itself receives them, giving you the opportunity to discard the WM_SIZE message (MSDN article). This, however, would take a lot of work with pinvoke and the windows api.

EDIT: This is probably a lot easier if you don't mind some manual labor.

user3F31A28
  • 104
  • 2
  • 13