Toon posts:

[VB6 container optionbuttons]Verkeerde container gebruikt

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb een xml-bestand waarmee ik runtime controls op mijn form plaats.
Deze controls komen in verschillende pictureboxen, die fungeren als tabbladen.
Ik heb dus meerdere pictureboxen met controls op elkaar. Afhankelijk van een cmdButton laat ik een picturebox zien.
Dit proces gaat prima.
Ik heb hier al eens eerder een post over gedaan op:
controls runtime toevoegen in verschillende pictureboxen

Nu heb ik in 1 pictureboxen, twee frames met optionbuttons staan.

Als ik nu een optie wijzig in frame1 dan wordt de optie in frame2 verwijderd. Dit wijst erop dat de optionbuttons in frame1 EN frame2 als 1 geheel worden gezien.
Dat komt waarschijnlijk omdat ik de parent wijzig van de optionbuttons naar de picturebox omdat ik ze anders niet kan 'hide' en 'show'

De code om de optionbuttons te plaatsen is als volgt:
code:
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Public Function addRadiobuttons(frm As Form, lIndexStart As Long, _
  lTopStart As Long, lLeftStart As Long, lButtonSeries As Long, groupbox As Frame, _
  sValue As String, sCaptions As String, sTag As String, _
  lGapBetweenControls As Long, lPicnr As Long) As Long
On Error GoTo addRadiobuttons_Error
Dim arrayOpties() As String, sCaption As String
Dim lIndex As Long, lTop  As Long, lLeft As Long
Dim lHeight As Long, i As Long, lLength As Long
Dim TheSize As STRINGSIZE
Dim radioButton As OptionButton

  'Haal eerst alle opties uit de string:
  arrayOpties = Split(sCaptions, ",")
  'init:
  lIndex = lIndexStart + 1
  lTop = lTopStart
  lLeft = lLeftStart
  
  For i = 0 To UBound(arrayOpties)
    lIndex = lIndex + i
    sCaption = Trim(arrayOpties(i))
    Call GetTextExtentPoint32(frm.hdc, sCaption, Len(sCaption), TheSize)
    lLength = TheSize.cx * Screen.TwipsPerPixelX + 380 'De grootte van het rondje moet ernog bij
    ' TheSize.cx en TheSize.cy bevatten nu de grootte van de string.
    
    'Omdat elke serie gemaakt moet worden van een nieuw orgineel, moet
    'dat hier gesplitst worden. 't Is niet netjes maar het werkt wel:
    Select Case lButtonSeries
    Case 1:
      Load frm.radioPic1(lIndex)
      Set radioButton = frm.radioPic1(lIndex)
..
..
    Case 5:
      Load frm.radioPic5(lIndex)
      Set radioButton = frm.radioPic5(lIndex)
    End Select
    'Als teveel knoppen dan volgende regel:
    If lLeft + lLength > groupbox.Width Then
      lTop = lTop + radioButton.Height + lGapBetweenControls
      'Weer bij het begin starten:
      lLeft = lLeftStart
      'groupbox ook vergroten:
      groupbox.Height = groupbox.Height + radioButton.Height + _
        lGapBetweenControls
    End If
    With radioButton
      .Move lLeft, lTop, lLength
      .Caption = sCaption
      .ToolTipText = .Name & ": " & sTag
      .Tag = sTag
      .Value = False
      .Width = lLength
      If LCase(sValue) = LCase(sCaption) Then .Value = True
      .Visible = True
      'Geplaatst. Volgende ernaast:
      lLeft = lLeft + lLength + lGapBetweenControls
      lHeight = .Height
      Call SetParent(.hWnd, frm.picTab(lPicnr).hWnd)
    End With
  Next i
  
  addRadiobuttons = lHeight

On Error GoTo 0
  Exit Function

addRadiobuttons_Error:
  SchrijfError "Error " & Err.Number & " (" & Err.Description & _
    ") in procedure addRadiobuttons of Module modControls"
End Function


Door de volgende regel:
code:
1
Call SetParent(.hWnd, frm.picTab(lPicnr).hWnd)
gaat het 'fout'.
Hier geef ik aan dat de parent de picturebox is, dus is het ook wel logisch dat alle optionbuttons in de picturebox als 1 geheel reageren.
Nu dacht ik door het op te lossen door
code:
1
Call SetParent(.hWnd, groupbox.hWnd)
te proberen maar dan 'vallen' de optionbuttons achter de pictureboxen en zie ik ze dus niet terug op het form.

Wie o wie kan me hiermee helpen?

  • onkl
  • Registratie: Oktober 2002
  • Laatst online: 23:03
Op het eerste gezicht:
probeer de parent van je groupbox in te stellen.
Dus pictab bezit groupbox bezit options.

Verwijderd

Topicstarter
@onkl:
Dat doe ik al.
Ik stel de parent van de groupbox in op de picturebox.

Als ik dan vervolgens de parent van de optionbuttons in stel op de groupbox zijn de buttons niet meer zichtbaar.
Ik nam aan dat ze dan achter de pictureboxen kwamen te liggen maar dat ga ik nu wel even zeker uitzoeken.

Uitgezocht:
Als ik
code:
1
Call SetParent(.hWnd, groupbox.hWnd)
gebruik ipv
code:
1
Call SetParent(.hWnd, frm.picTab(lPicnr).hWnd)
dan is de radiobutton niet zichtbaar.
Als ik dan
code:
1
frm.picTab(lPicnr).visible = false
uitvoer om te zien of de radiobutton 'achter' mijn picturebox ligt, zie ik de radiobutton niet terug.

Iemand een idee??

[ Voor 39% gewijzigd door Verwijderd op 05-11-2004 15:27 . Reden: typos ]