tbfreefall
Member
- Joined
- Oct 17, 2007
- Messages
- 11
- Programming Experience
- Beginner
I am using process.start() to start an application from withing mine. I need to be able to modify is size/position properties.
<DllImport("User32.dll")> _
Public Shared Function SetWindowPos(ByVal hwnd As Intptr, ByVal hWndInsertAfter As Int32,
ByVal x As Int32, ByVal y As Int32, ByVal cx As Int32, ByVal cy As Int32,
ByVal wFlags As Int32) As Int32
That is quite true and I should have known that because I made that switch myself. I was thinking that SetWindowPos would set the position but not the size, which is obviously not the case. At least someone's on the ball. :thumb:SetWindowPos is a bit easier in ths case, as it doesn't use any structures...
VB.NET:<DllImport("User32.dll")> _ Public Shared Function SetWindowPos(ByVal hwnd As Intptr, ByVal hWndInsertAfter As Int32, ByVal x As Int32, ByVal y As Int32, ByVal cx As Int32, ByVal cy As Int32, ByVal wFlags As Int32) As Int32
I assume that you mean a Windows app with a main form. In that case you can the MainWindowHandle of your process and use it to call the SetWindowPlacement API function.
Dim myProcess As Process
Dim myhWnd As [B]Intptr[/B]
Const HWND_NOTOPMOST As [B]Int32[/B] = -2
Const SWP_SHOWWINDOW As [B]Int32[/B] = &H40
myprocess = system.diagnostics.process.Start(lstApplications.SelectedItem.ToString)
myprocess.WaitForInputIdle()
myhWnd = myProcess.MainWindowHandle
SetWindowPos(myhWnd, HWND_NOTOPMOST, Cint(txtAppLeft.Text),
Cint(txtAppTop.Text), Cint(txtAppWidth.Text), Cint(txtAppHeight.Text), SWP_SHOWWINDOW)