Changing position of command window (cmd) programmably

Vitjaz

New member
Joined
Apr 6, 2011
Messages
1
Programming Experience
5-10
Hi everyone,

I've been trying fo find a solution on how to set screen position and size of the command prompt window (looks as old DOS). I found lots of references to SetWIndowPos function. The function declaration is pretty straightforward:

Declare Function SetWindowPos Lib "user32" (ByVal hWnd As IntPtr, _
ByVal hWndInsertAfter As IntPtr, _
ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, _
ByVal flags As Integer) As Boolean
End Function

Parameters x, y, cx, and cy define a new position and size of the window. I tried to use the function with no luck. But in the meantime I found a very strange behavior of SetWindowPos. When I used desired left side coordinate in place of hWndInsertAfter and desired width in place of x, then my cmd window horizontal size was set and cmd window itself moved, see example:
SetWindowPos(handle.ToInt32, 0, 600, 0, 0, 0, SWP_SHOWWINDOW)
So, I found that I can change the width and the horizontal position by misplacing the parameters in the function call. Hurrah! But I couldn't change the height and the vertical position of cmd window.
Any help and/or suggestions will be greatly appreciated.
 
Back
Top