0

$Hello_all,

I'm adding functionality to a VB6 application (yes, I know, an amazing task :P) and I need to drop an ActiveX control (it looks like a button but does more things) into a comctlib (Microsoft Common Controls) Toolbar.

Is this possible at all? I don't mind using the Winapi, interop or whatever is needed as I really need this feature. If this is not possible with the Comctlib control is there another toolbar control for VB6 where I can drop other ActiveX controls?

Thanks in advance for helping me with this outdated technology.

Charles
  • 50,943
  • 13
  • 104
  • 142
Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
  • 1
    I'm not sure what you're asking for. The MS Common Controls 6.0 toolbar is a container control, so you can put anything you want on it – you'd just have to manage its position manually as it wouldn't be one of the built-in components. – Antagony Jul 11 '12 at 11:07
  • @Antagony: this is simply not true. The toolbar is a container of buttons. It only has a buttons collection where you add Button objects. – Ignacio Soler Garcia Jul 11 '12 at 15:19
  • It **is** a container regardless of the intrinsic `Buttons` collection. One of the `Style` properties for a button is `PlaceHolder` – which creates a blank area in the desired position – you can then simply place *any* other control you want on top of that blank area. If its position is dynamic due to buttons being optionally shown/hidden, you will have to move any controls you place there programmatically, but that's relatively straightforward. – Antagony Jul 11 '12 at 15:34
  • Looking at this again it would appear *some* controls are not given a high enough precedence to appear on top of the placeholder's buttons. However, this is easily remedied by placing them inside a borderless picturebox. – Antagony Jul 11 '12 at 17:03
  • @Antagony: if you set your second comment as an answer I will accept it. Thanks. – Ignacio Soler Garcia Jul 12 '12 at 15:39

1 Answers1

1

In addition to its intrinsic Buttons collection, the toolbar acts as a general container. So, to position any (non-lightweight*) control/s you want between existing buttons, insert a new button and set its Style property to PlaceHolder – that creates a blank area in the desired position – and place your control/s there.

Of course you will have to manually reposition any such control/s if you dynamically show/hide/add/remove buttons at runtime.

* To display lightweight controls, you could place them inside any other container control – e.g. a borderless PictureBox – first.

Antagony
  • 1,750
  • 12
  • 17