CodeItBetter Programming Another VB Programming Blog

How to handle Size & Position of Console Application with Windows Application in VB6

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'System & API - How to handle Size & Position of Console Application with Windows Application in VB6
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, _
    ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowPos Lib "user32.dll" (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 Sub Form_Load()
    Dim hWndConsole As Long
    Const SWP_NOZORDER As Long = &H4
 
    'This will shell the FTP console application and show it in the picture box
    Picture1.ScaleMode = vbPixels
    Shell "ftp.exe", vbNormalFocus
    'wait a second so the program has time to start
    Call Sleep(1000)
    hWndConsole = FindWindow("ConsoleWindowClass", vbNullString)
    If hWndConsole Then
        Call SetParent(hWndConsole, Picture1.hWnd)
        Call SetWindowPos(hWndConsole, 0, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
            SWP_NOZORDER)
    End If
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.