PDA

Click to See Complete Forum and Search --> : move a application program window


ltlearn
Feb 9th, 2002, 11:41 AM
I am using the API "CreateProcess" to launch the other application program. My program is using this method to launch the same program a few times, but the windows are stacked onto each other and the user may not see there are a few windows opened. I would like to move the window away or make it tile horizontally, how do I do it ?

here is my code;


Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Long, lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Do while loopcount < 6

RetVal = CreateProcess(vbNullString, _
ApplicationName, ByVal 0&, ByVal 0&, _
1&, NORMAL_PRIORITY_CLASS, ByVal 0&, vbNullString, _
startInfo6, processInfo6)

loopcount = loopcount + 1

loop

mlewis
Feb 9th, 2002, 01:55 PM
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1


Private Sub Form_Load()
SetWindowPos (hwnd of window to move), 0, (new left goes here), (new top goes here), 0, 0, SWP_NOSIZE
End Sub

ltlearn
Feb 17th, 2002, 09:49 AM
By the way, I came across with the Enumeration, could you please breifly explain what is the Enum means and what does this do ? Thanks (Tried search for MSDN, but could not get a clear picture)

mlewis
Feb 26th, 2002, 12:03 PM
Well, here's how Enums work.

You basically say:

{Public | Private} Enum name
ConstantName [ = value ]
End Enum

So for example:

Private Enum ConnectionTypes
ConnectionSynchronous = 374
ConnectionAsynchronous = 365
End Enum

Now you can say:

Dim CT AS ConnectionTypes

So when you type CT= you will get a little popup box that lets you choose ConnectionSynchronous or ConnectionAsynchronous.



Now ENUMS can be used other ways as well.
To make A = 1, B = 2, and so on:

Public Enum Alphabet
A
B
C
D
End Enum


Or you can make A = 34, B = 35, etc:

Public Enum Alphabet2
A = 34
B
C
D
E
End Enum

Megatron
Mar 1st, 2002, 03:33 PM
Basically, eumerations just encapsulate constants. For example:

Enum PlanetSize
Earth = 16384
Moon = 2298
Mars = 2576
Sun = 5850435
End Enum

Those are all ugly numbers, and it would be a pain to try to remember them all, right?

So instead of using:
Result = 16384 * 2576
You can simply use

Dim Size As PlanetSize
Result = Size.Earth * Size.Sun

A lot easier to remember, don't you think?

And, since enumerations are encapsulated, you can pass them through subroutines. So let's assume we have a subroutine as follows.

Function ReturnSize(Size1 As PlanetSize, Size2 As PlanetSize) As Long
ReturnSize = Size1 * Size2
End Function

We can easily pass values, that are part of the PlanetSize enumeration, like this:

Result = ReturnSize(Earth, Sun)

ltlearn
Mar 4th, 2002, 07:20 PM
Guys,
This mean a lot more to me. I learnt.