Results 1 to 6 of 6

Thread: move a application program window

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Posts
    124

    move a application program window

    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;

    VB Code:
    1. 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
    2.  
    3. Do while loopcount < 6
    4.  
    5. RetVal = CreateProcess(vbNullString, _
    6.       ApplicationName, ByVal 0&, ByVal 0&, _
    7.       1&, NORMAL_PRIORITY_CLASS, ByVal 0&, vbNullString, _
    8.       startInfo6, processInfo6)
    9.  
    10. loopcount = loopcount + 1
    11.  
    12. loop

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    VB Code:
    1. 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
    2.  
    3. Private Const HWND_TOPMOST = -1
    4. Private Const SWP_NOSIZE = &H1
    5.  
    6.  
    7. Private Sub Form_Load()
    8.     SetWindowPos (hwnd of window to move), 0, (new left goes here), (new top goes here), 0, 0, SWP_NOSIZE
    9. End Sub
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Posts
    124
    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)

  4. #4
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    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
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  5. #5
    Megatron
    Guest
    Basically, eumerations just encapsulate constants. For example:
    VB Code:
    1. Enum PlanetSize
    2.     Earth = 16384
    3.     Moon = 2298
    4.     Mars = 2576
    5.     Sun = 5850435
    6. End Enum
    Those are all ugly numbers, and it would be a pain to try to remember them all, right?

    So instead of using:
    VB Code:
    1. Result = 16384 * 2576
    You can simply use
    VB Code:
    1. Dim Size As PlanetSize
    2. 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.
    VB Code:
    1. Function ReturnSize(Size1 As PlanetSize, Size2 As PlanetSize) As Long
    2.     ReturnSize = Size1 * Size2
    3. End Function
    We can easily pass values, that are part of the PlanetSize enumeration, like this:
    VB Code:
    1. Result = ReturnSize(Earth, Sun)

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Posts
    124
    Guys,
    This mean a lot more to me. I learnt.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width