"Hmmm..." <bl******@blah.com> wrote in message
news:t8******************@nwrddc03.gnilink.net...
Is there a way to control which controls appear to be "on top". For
example a MaskEdBox shows up "on top" of a ComboBox when the 2 controls overlap,
but a MaskedBox shows up "underneath" a DataCombo when 2 controls overlap.
How can I force a MaskEdBox to show up "on top" of a DataCombo when whey
overlap? Thanks.
Provided all the controls exist within the same graphical layer, set their
ZOrder (via the ZOrder method). Controls in different layers will always
appear over or under controls in another layer. The controls you're talking
about exist in the same layer, though, so it shouldn't be a problem. Well,
I'm not sure about the DataCombo, but I would imagine it's in the same layer
as the other controls.
There are only 3 layers, and one of those is the container (it's the first,
and bottom, layer). That leaves only 2 layers for controls in the
container. Graphically-drawn controls are at another layer (the second, or
middle, layer). Such controls include the Label, Line, and Shape controls.
All "windowed" controls exist in the 3rd (and top) layer. If a control has
an hWnd property, it's a windowed control and exists in the 3rd layer, so
that's an easy way to determine the layer. A control existing in a higher
layer always covers a control existing in a lower layer. For example, a
textbox (a windowed control existing in the 3rd layer) will always cover a
label (a graphical control existing, as stated, in the 2nd layer).
A control's initial ZOrder is set, within its layer, by the order the
controls are placed on a form (or other container). IOW, if you place a
command button on a form, and then place a textbox on a form and move the
textbox so it overlaps the command button, the textbox will be on top of the
command button. Since these controls exist in the same layer, you can change
this by setting the ZOrder (at design-time, select "Bring to Front" or "Set
to Back" from the Order submenu of VB's Format menu (or just press Ctrl+K or
Ctrl+K, respectively). In code, you use the control's ZOrder method to bring
it to front or set it to back.
That's really all there is to it.
Mike