ocx question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mickey

    #1

    ocx question

    Hi,

    I'm playing around with activeX-control creation.
    It's the first time for me but it going well. And turns out to be not
    all that difficult. I have created on a (activex) form, a
    command-array within a frame

    When I set a property (I have created a 'style' property) to 0
    It generates 5 buttons from left to right.
    And the frame resizes accordingly

    When I set the property to 1
    It generates 5 buttons from top to bottom.

    My question is:
    How can I resize the OCX I draw on a project
    within the ocx-code.

    All the above is a attempt to create a key-pad, wich I use alot in my
    line of programming(tou chscreen)

    style 0 should be a num-pad
    style 1 should be a simple qwerty keyboard.


    The code for creating a key-board is not that difficult and long.

    My next questions is, is it usefull to create this activex-control?


    thank you




    Groetjenz,

    Mickey
    --
    #### gewoan skrieve su ast ut seist ####
  • Steve Gerrard

    #2
    Re: ocx question


    "mickey" <mickeyATgruize lgruis.nl> wrote in message
    news:k2ng81lahr 56p55k0urk4ofne 2scntvngj@4ax.c om...[color=blue]
    >
    > I'm playing around with activeX-control creation.
    >
    > My question is:
    > How can I resize the OCX I draw on a project
    > within the ocx-code.
    >
    >
    > My next questions is, is it usefull to create this activex-control?
    >
    >[/color]

    1. You can resize the control within its own code, but you might want to check
    for the scalemode of the container it is in. See the Ambient.ScaleUn its
    property. Normally the size and placement of a control is managed by the
    container, not the control itself.
    This will work in the usual Twips situation:

    Private Sub UserControl_Cli ck()
    UserControl.Wid th = 1000
    UserControl.Hei ght = 1000
    End Sub

    2. User controls are very useful. I would not bother with actually building it
    as an OCX; this gets into annoying problems with registration, binary
    compatibility, and other such noise. Just add the user control source code
    file(s) to any project where you need it.


    Comment

    • mickey

      #3
      Re: ocx question

      On Mon, 16 May 2005 07:52:40 -0700, "Steve Gerrard"
      <mynamehere@com cast.net> you typed some letters in random order:

      Thank you Steve for your insight.
      [color=blue][color=green]
      >> My question is:
      >> How can I resize the OCX I draw on a project
      >> within the ocx-code.
      >>
      >>
      >> My next questions is, is it usefull to create this activex-control?
      >>
      >>[/color]
      >
      >1. You can resize the control within its own code, but you might want to check
      >for the scalemode of the container it is in. See the Ambient.ScaleUn its
      >property. Normally the size and placement of a control is managed by the
      >container, not the control itself.
      >This will work in the usual Twips situation:
      >
      >Private Sub UserControl_Cli ck()
      > UserControl.Wid th = 1000
      > UserControl.Hei ght = 1000
      >End Sub
      >[/color]

      I'm not sure what the ' Ambient.ScaleUn its property' is. But perhaps
      I'm not very clear on what I need.

      Lets say you draw a listbox on a form. When you change the fontsize
      for the listbox, the list box 'snaps' in a certain height depending on
      the fontsize.

      This is 'sort of' what i'm looking for. When my 'stile' is set to 0
      I would like the object to snaps in a certain width
      [color=blue]
      >2. User controls are very useful. I would not bother with actually building it
      >as an OCX; this gets into annoying problems with registration, binary
      >compatibilit y, and other such noise. Just add the user control source code
      >file(s) to any project where you need it.[/color]

      oke. Knowing this probably saves me time figuring it out

      thank you
      Groetjenz,

      Mickey
      --
      #### gewoan skrieve su ast ut seist ####

      Comment

      • mickey

        #4
        Re: ocx question

        On Mon, 16 May 2005 17:43:02 +0200, mickey <mickeyATgruize lgruis.nl>
        you typed some letters in random order:

        [color=blue][color=green]
        >>
        >>Private Sub UserControl_Cli ck()
        >> UserControl.Wid th = 1000
        >> UserControl.Hei ght = 1000
        >>End Sub
        >>[/color]
        >
        >I'm not sure what the ' Ambient.ScaleUn its property' is. But perhaps[/color]

        I found it...
        UserControl.Wid th = frm_key.width +200


        Thank you


        Groetjenz,

        Mickey
        --
        #### gewoan skrieve su ast ut seist ####

        Comment

        • Steve Gerrard

          #5
          Re: ocx question


          "mickey" <mickeyATgruize lgruis.nl> wrote in message
          news:jhrh81hoc9 6pbuu6iuj1utgb7 gaah1k8vf@4ax.c om...[color=blue]
          > On Mon, 16 May 2005 17:43:02 +0200, mickey <mickeyATgruize lgruis.nl>
          > you typed some letters in random order:
          >
          >[color=green][color=darkred]
          >>>
          >>>Private Sub UserControl_Cli ck()
          >>> UserControl.Wid th = 1000
          >>> UserControl.Hei ght = 1000
          >>>End Sub
          >>>[/color]
          >>
          >>I'm not sure what the ' Ambient.ScaleUn its property' is. But perhaps[/color]
          >
          > I found it...
          > UserControl.Wid th = frm_key.width +200
          >
          >[/color]

          That will work, as long as you use it only on the form frm_key in this project,
          and change the name in the code when you use it in another project.

          Ambient.ScaleUn its is a property of the Ambient object, which tells your user
          control a few things about where it has been placed. It could be inside a
          picturebox, for instance. ScaleUnits is a text string that lets you know if the
          container is using vbTwips or vbPixels, etc., so you could in principle write
          some code that would work in any form or container in any project.

          However, one of the nice things about just using the source code where needed is
          that you can tweak it for each situation, which is often easier.

          Another possibility you might look at is making your control Alignable (its a
          property), and then in your code, setting its Align property to say
          vbAlignBottom. This would make it stretch automatically when the form was
          resized.


          Comment

          Working...