Toon posts:

[VB6] form in container op ander form

Pagina: 1
Acties:

Verwijderd

Topicstarter
hoi..
hoe kan ik op een main form een andere form in een container laden ?
ik had ergens gelezen dat je op de main form een picturebox moest plaatsen en dan die 2e form in die picturebox moest laden, maar heb niet echt een idee hoe je een form in die picturebox moet laden..
op de tweede form worden in runtime comboboxen aangemaakt en aangezien ik niet weet hoeveel het er precies zijn, wordt deze form dus langer afhankelijk van de hoeveelheid comboboxen. Daarom dat ik die in een container op de eerste form wil laden, zodat ik daar dan in kan scrollen.

andere suggesties zijn welkom uiteraard.

greetz,
Slashem

  • Luppie
  • Registratie: September 2001
  • Laatst online: 01-03 23:21

Luppie

www.msxinfo.net

Je kan het beste voor je MainForm een MDI Form (Multiple Document Interface) gebruiken.

Hierin kan je dan child forms laden.

http://www.google.nl/sear...nl&btnG=Google+zoeken&lr=

[ Voor 27% gewijzigd door Luppie op 19-05-2003 08:55 ]

Heb je iets aan mijn antwoord ? Een thumbs-up wordt zeker op prijs gesteld.


Verwijderd

Topicstarter
mja, maar op m'n main form zijn er ook controls enzo...
volgens hetgeen ik tot nu weet van mdi is het zo dat de parent enkel een menubalk/toolbalk heeft en geen body met andere controls. het is wel de bedoeling dat de parentform ook inhoud heeft en dan in een container ofzo die andere form terecht komt

Het zou zoiets moeten zijn zoals in Internet Explorer -> extra -> internet opties, tabblad geavanceerd. in die instellingen kan je scrollen. Het lijkt alsof dat dat een appart formulier is. Hier zou het dan iets zijn met comboboxen ipv checkboxen..

[ Voor 31% gewijzigd door Verwijderd op 19-05-2003 09:22 ]


  • RayNbow
  • Registratie: Maart 2003
  • Laatst online: 10:15

RayNbow

Kirika <3

Hier is een code example uit API-Guide (www.allapi.net)


Visual Basic:
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Const GW_HWNDNEXT = 2
Dim mWnd As Long
Function InstanceToWnd(ByVal target_pid As Long) As Long
    Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
    'Find the first window
    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
    Do While test_hwnd <> 0
        'Check if the window isn't a child
        If GetParent(test_hwnd) = 0 Then
            'Get the window's thread
            test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
            If test_pid = target_pid Then
                InstanceToWnd = test_hwnd
                Exit Do
            End If
        End If
        'retrieve the next window
        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
End Function
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim Pid As Long
    'Lock the window update
    LockWindowUpdate GetDesktopWindow
    'Execute notepad.Exe
    Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
    If Pid = 0 Then MsgBox "Error starting the app"
    'retrieve the handle of the window
    mWnd = InstanceToWnd(Pid)
    'Set the notepad's parent
    SetParent mWnd, Me.hwnd
    'Put the focus on notepad
    Putfocus mWnd
    'Unlock windowupdate
    LockWindowUpdate False
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'Unload notepad
    DestroyWindow mWnd
    'End this program
    TerminateProcess GetCurrentProcess, 0
End Sub

[ Voor 7% gewijzigd door RayNbow op 19-05-2003 12:23 ]

Ipsa Scientia Potestas Est
NNID: ShinNoNoir


Verwijderd

Topicstarter
Heb het uiteindelijk op een andere manier gedaan.
'k heb op de hoofdform een frame geplaatst met er standaard 1 combobox in.
naast de frame heb ik een scrollbar geplaatst.
als de gebruiker iets in de combobox selecteert komt er onder die combobox een nieuwe combobox. Dit gaat zo verder.
Op een gegeven moment is de lijst van comboboxen groter dan de hoogte van de frame. dan wordt een berekening gedaanvoor de max value van de scrollbar te weten te komen en als je op de scrollbar klikt worden eigenlijk alle comboboxen.Top veranderd zodat je op deze manier naar boven & beneden kan scrollen.
De werkelijke .top waarde heb je ook nodig om een nieuwe combobox te plaatsen en deze wordt dan in de .tag bewaard