Showing results 1 to 7 of 7

Thread: get heigh msforms combo box as aktiveX

  1. #1

    Default get heigh msforms combo box as aktiveX

    Hi
    I have a problem to get the height in an AktiveX Combobox. I need the height to set the Font.Size of the Combobox because some boxes are on more pictures with a different size. I tried following Code on the Init function
    Code:
    Set combobox1 = obElem.AktiveX
    With combobox1
        .Font.Size = obelem.height
        .Font = "Arial Black"
        End With
    But Vba halts and says "... doesn't support this method..."
    Can anybody tell me how this could be working? Or is there another way to set it?

    Thanks
    Matthias

  2. #2
    robertf Gast

    Default Re: get heigh msforms combo box as aktiveX

    The "Height" property of elements is not available at runtime beacause of screen resolution independet runtime...

    You can use "Top" and "Bottom" Property to calculate the height...

    Public Sub InitCombo(xElem As Element)
      Set xCombo = xElem.AktiveX
      If xCombo Is Nothing Then Exit Sub
      
      xCombo.Font.Size = (xElem.Bottom - xElem.Top) * 0.75 '75% of height
      
      xCombo.AddItem "Test1"
      xCombo.AddItem "Test2"
      xCombo.AddItem "Test3"
    End Sub

  3. #3
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: get heigh msforms combo box as aktiveX

    You are right... the "height" property is not supported for elements....

    check out this:
    obElem.Bottom - obElem.Top
    -> this would be something around 30 pixel.... setting a font size with 30 for the combobox entry?!?

    -> one thing which I want to mention:
    be very careful using such controls (i.e. MSCombobox) within an ActiveX Control in order to display it within the zenOn Runtime:
    -> if you do leave the picture where the ActiveX Control is placed destroy the element!
    -> otherwise unforeseen consequences can occur

    -> declare the pictures where the ActiveX Control is placed with WithEvents and with event
    myPic_Close() destroy the created object
    Set combobox1 = Nothing

    Also destroy the objects when closing the runtime:

    Private Sub Project_Inactive()
         If Not combobox1 Is Nothing Then
            Set combobox1 = Nothing
        End If
    End Sub


    Regards,
    Herbert

    btw: to check which object properties are available just put this object (in your case obelem) into the watch-window....

    btw2: check out also the CD_Combobox (instead of the MsForms.Combobox) ... this combox also do have the style 1 (Simple Combo) which is a combination out of a combobox and listbox...

  4. #4

    Default AW: get heigh msforms combo box as aktiveX

    Thank you very much for your answers, works fine.
    But now i got another Problem, the CD_Combobox fits much better then the MSFORMS one, but if i try it to dim withevents, it says userdefined object not defined. The Zenon RT libary is included. And in the Editor i can choose the CD_combobox. Is there another file that have to be included?
    Thanks so far
    Matthias

  5. #5
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: get heigh msforms combo box as aktiveX

    The reference which has to be added for the CD_Combobox is called "Copa-Data Controls" (CD_ComCtrl.ocx)

    Regards,
    Herbert

  6. #6

    Default AW: get heigh msforms combo box as aktiveX

    Ok, this part works now. But again i gain another problem
    It seems, that there is no ondropdownbutton event in the CD_Combobox. I used this in the MSFORMS to load the Dropdownelements out of a sql database, so they are always uptodate. Is there an other possibility to get the fill the data in the box, every time an user klick it?
    Thanks
    Matthias

  7. #7
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: get heigh msforms combo box as aktiveX

    as far as i know the "ondropdownbutton" event is not a standard event from a combobox (not for the "standard" MS-Combo nor for the one of CD)...

    to see which events (and also methods, properties,... ) are supported for a control simply open the object browser (Objektkatalog) and check the events for the CD_ComboBox (library is called CD_COMCTRLLib) ...

    Events available for the CD_ComboBox:
    Event Click()
    Event Change()

    Regards,
    Herbert

    hint: the CD_Combobox does have a "sort" function ... the MS_Combobox not

Posting Rules

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