Home » Category » Microsoft Visual Basic

Microsoft Visual Basic: ZOrder question

112| Sat, 10 Nov 2007 10:32:00 GMT| johnwood| Comments (8)
I have 2 frame controls on a form one directly below the other. The
bottom frame has a listview control on it. I make the listview visible
under certain conditions. When I make the listview visible, I want it to
be the top most control on both the frame it is contained on but also on
top of the frame directly above it (since the frames are relatively
small in height).

Since the frame control is a container and the ZOrder method only seems
to arrange objects only within the layer where the object is displayed,
the listview is under the frame directly above the frame it is contained
on.

How can I make the listview ride on top of both frames?

Thank you for any suggestions,
John Wood

Keywords & Tags: zorder, microsoft, visual basic, vb

URL: http://www.programmerbase.com/visual-basic/560848/
 
«« Prev - Next »» 8 helpful answers below.
"John Wood" <jwood...co.sarasota.fl.us> wrote in message
news:3CBE4523.43C71C34...co.sarasota.fl.us...
> I have 2 frame controls on a form one directly below the other. The
> bottom frame has a listview control on it. I make the listview visible
> under certain conditions. When I make the listview visible, I want it to
> be the top most control on both the frame it is contained on but also on
> top of the frame directly above it (since the frames are relatively
> small in height).
>
> Since the frame control is a container and the ZOrder method only seems
> to arrange objects only within the layer where the object is displayed,
> the listview is under the frame directly above the frame it is contained
> on.
>
> How can I make the listview ride on top of both frames?

Don't put it on either -- make it's container the same as the frames'.

grinder | Sun, 11 Nov 2007 18:20:00 GMT |

> I have 2 frame controls on a form one directly below the other. The
> bottom frame has a listview control on it. I make the listview visible
> under certain conditions. When I make the listview visible, I want it to
> be the top most control on both the frame it is contained on but also on
> top of the frame directly above it (since the frames are relatively
> small in height).
>
> Since the frame control is a container and the ZOrder method only seems
> to arrange objects only within the layer where the object is displayed,
> the listview is under the frame directly above the frame it is contained
> on.
>
> How can I make the listview ride on top of both frames?

If it needs to be contained in the frame, set the zorder of the listview, AND the frame.

--
Dean Earley (dean.earley...icode.co.uk)
Assistant Developer

iCode Systems

deanearley | Sun, 11 Nov 2007 18:22:00 GMT |

If I don't put it on either -- and make it's container the same as the frames, when I try to
set the focus I get the error "Invalid procedure call or argument".

It really does not need to be contained in the frame - actually I would like to move it from
one frame to another - How do I accomplish that?

Thanks,

jw

Dean Earley wrote:

> > I have 2 frame controls on a form one directly below the other. The
> > bottom frame has a listview control on it. I make the listview visible
> > under certain conditions. When I make the listview visible, I want it to
> > be the top most control on both the frame it is contained on but also on
> > top of the frame directly above it (since the frames are relatively
> > small in height).
> >
> > Since the frame control is a container and the ZOrder method only seems
> > to arrange objects only within the layer where the object is displayed,
> > the listview is under the frame directly above the frame it is contained
> > on.
> >
> > How can I make the listview ride on top of both frames?
>
> If it needs to be contained in the frame, set the zorder of the listview, AND the frame.
>
> --
> Dean Earley (dean.earley...icode.co.uk)
> Assistant Developer
>
> iCode Systems

johnwood | Sun, 11 Nov 2007 18:22:00 GMT |

"John Wood" <jwood...co.sarasota.fl.us> wrote in message
news:3CC080C8.98840E93...co.sarasota.fl.us...
> If I don't put it on either -- and make it's container the same as the
frames, when I try to
> set the focus I get the error "Invalid procedure call or argument".

This happens if the item you're trying to SetFocus to (or it's container) is
either hidden or disabled. Other than that, it should not matter what the
ListView's container is.

> It really does not need to be contained in the frame - actually I would
like to move it from
> one frame to another - How do I accomplish that?

That seems unnecessary. Track down why your SetFocus is failing, and I
think you'll be close to a solution.

grinder | Sun, 11 Nov 2007 18:24:00 GMT |

Since I can't figure it out from your suggestions, maybe I should give the
whole story:

I have a form with four frames. Each frame consists of several controls (in
control arrays) in at least 4 rows. Each row on any one of the frames
contains the controls that will fill a specific recordset. This setup
facilitates loading the data into the recordsets for inserts into a db.

Now several of the controls in each row are combo boxes (as a matter of fact
there are 8 different recordsets that are fetched for the 8 different combo
types. To make this matter worse, each of the 8 different combos are
repeated on each frame 4 times (rows of contriols on the frames). So when
the form fires I am loading the combos with data fetched from the db.
Problem is that the get procedures are repeated for each combo and this
equates to 32 reads from the db.

To illustrate this, one combo is cboEmployee and this combo is repeated on
this one form 16 times. To say the least, the form load time is unacceptable
using this brute force method.

So Primary Question1. What is a better method to use.

Please Note: I should add that I have implemented this work around:
I added 8 listviews to the form to the form itself and not the frame
containers.- one for each dataset and 32 SubClass (SoftCircuits) controls in
8 SubClass control arrays - one for each combo control. When the cbo click
event fires, the Private Sub Subclass1_WndProc is executed - opening the
appropriate list view and on the lvw click event the item selected is thrown
into the referenced combo.

My major problem is I cannot seem to move the lvws to the different frames
so they ride on top of all frames (some frames are not very high) and the
practicle height for the lvw is greater than the frame height. I have tried
the ZOrder method bu the .setfocus for the lvws fail.

I guess my basic question, is there a better way to accomplish my task and
secondly, I can I get the lvws to move to the top of the different frames.

I know that this is probably to extensive...and thanl\ks for your thoughtful
suggestions.

John Wood

John Wood wrote:

> I have 2 frame controls on a form one directly below the other. The
> bottom frame has a listview control on it. I make the listview visible
> under certain conditions. When I make the listview visible, I want it to
> be the top most control on both the frame it is contained on but also on
> top of the frame directly above it (since the frames are relatively
> small in height).
>
> Since the frame control is a container and the ZOrder method only seems
> to arrange objects only within the layer where the object is displayed,
> the listview is under the frame directly above the frame it is contained
> on.
>
> How can I make the listview ride on top of both frames?
>
> Thank you for any suggestions,
> John Wood

johnwood | Sun, 11 Nov 2007 18:25:00 GMT |

> I have tried the ZOrder method bu the .setfocus for the lvws fail.

This statement make me suspect you're getting tripped up by something small.
SetFocus will work if the target is visible and enabled. This must also be
true for its container, and that container's container, etc... If you're
reallying wanting that control to get focus, those other conditions must be
true anyhow.

Instead of writing this approach off as a failure, take a look into why it
has failed.

> I guess my basic question, is there a better way to accomplish my task?

Probably, it sounds fairly tangled, but I'm speaking from ignorance. It
sounds like the code has been scaled poorly. Meaning, that an approach that
works for 5 controls may not work well for 50 controls if you simply cut and
paste 10 copies of the original code.

> secondly, [how] can I get the lvws to move to the top of the different
frames.

Just to make sure of your meaning. When you say "to the top of", is this
equivalent to "in front of"?

> I know that this is probably to extensive...and thanl\ks for your
thoughtful
> suggestions.

I think the details are obscuring your view of a solution. Try working with
a new project that just has a couple of controls. Write a prototype of what
you want your code to do before stabbing at your main project.

grinder | Sun, 11 Nov 2007 18:26:00 GMT |

Grinder:

Thanks for your in depth analysis of my problem. Used your approch by scaling
down the problem and figured out how to .setfocus.

The list view apoproch and subclassing is working fine - meaning the load time
is acceptable. I just cannot move a listview from one frame container to another
frame container. I just cannot figure out the proper syntax. I know how to set
the top and left properties but that is relatively to the container - isn't it?

This illustrates:

Private Sub SubclassAdminActionTypes_WndProc(Index As Integer, Msg As Long,
wParam As Long, lParam As Long, Result As Long)

'On Error GoTo Proc_Err
'cboMosqCode associated with habitat audit grid
Select Case Index
Case 0:
Select Case Msg

Case WM_CTLCOLORLISTBOX
'close up the combo
SendMessage cboAAType(Index).hwnd, CBN_CLOSEUP, False, False
With lvwAdminActionTypes
'.Top = 1575
'.Left = 4650
.Visible = True
.SetFocus
End With

Case Else
'Allow default message processing
lResult = SubclassAdminActionTypes(Index).CallWndProc(Msg,
wParam, lParam)
End Select

The .top and .left properties position it on its present container but how to
move to the front of another container and the position it?

john

Grinder wrote:

> > I have tried the ZOrder method bu the .setfocus for the lvws fail.
>
> This statement make me suspect you're getting tripped up by something small.
> SetFocus will work if the target is visible and enabled. This must also be
> true for its container, and that container's container, etc... If you're
> reallying wanting that control to get focus, those other conditions must be
> true anyhow.
>
> Instead of writing this approach off as a failure, take a look into why it
> has failed.
>
> > I guess my basic question, is there a better way to accomplish my task?
>
> Probably, it sounds fairly tangled, but I'm speaking from ignorance. It
> sounds like the code has been scaled poorly. Meaning, that an approach that
> works for 5 controls may not work well for 50 controls if you simply cut and
> paste 10 copies of the original code.
>
> > secondly, [how] can I get the lvws to move to the top of the different
> frames.
>
> Just to make sure of your meaning. When you say "to the top of", is this
> equivalent to "in front of"?
>
> > I know that this is probably to extensive...and thanl\ks for your
> thoughtful
> > suggestions.
>
> I think the details are obscuring your view of a solution. Try working with
> a new project that just has a couple of controls. Write a prototype of what
> you want your code to do before stabbing at your main project.

johnwood | Sun, 11 Nov 2007 18:27:00 GMT |

thats an easy one...

Set Listview1.container = Frame1

D.

"John Wood" <jwood...co.sarasota.fl.us> wrote in message news:3CC0D031.815713DE...co.sarasota.fl.us...
Grinder:
Thanks for your in depth analysis of my problem. Used your approch by scaling down the problem and figured out how to .setfocus.

The list view apoproch and subclassing is working fine - meaning the load time is acceptable. I just cannot move a listview from one frame container to another frame container. I just cannot figure out the proper syntax. I know how to set the top and left properties but that is relatively to the container - isn't it?

This illustrates:

Private Sub SubclassAdminActionTypes_WndProc(Index As Integer, Msg As Long, wParam As Long, lParam As Long, Result As Long)

'On Error GoTo Proc_Err
'cboMosqCode associated with habitat audit grid
Select Case Index
Case 0:
Select Case Msg

Case WM_CTLCOLORLISTBOX
'close up the combo
SendMessage cboAAType(Index).hwnd, CBN_CLOSEUP, False, False
With lvwAdminActionTypes
'.Top = 1575
'.Left = 4650
.Visible = True
.SetFocus
End With

Case Else
'Allow default message processing
lResult = SubclassAdminActionTypes(Index).CallWndProc(Msg, wParam, lParam)
End Select

The .top and .left properties position it on its present container but how to move to the front of another container and the position it?

john


Grinder wrote:

> I have tried the ZOrder method bu the .setfocus for the lvws fail.
This statement make me suspect you're getting tripped up by something small.
SetFocus will work if the target is visible and enabled. This must also be
true for its container, and that container's container, etc... If you're
reallying wanting that control to get focus, those other conditions must be
true anyhow.

Instead of writing this approach off as a failure, take a look into why it
has failed.

> I guess my basic question, is there a better way to accomplish my task?

Probably, it sounds fairly tangled, but I'm speaking from ignorance. It
sounds like the code has been scaled poorly. Meaning, that an approach that
works for 5 controls may not work well for 50 controls if you simply cut and
paste 10 copies of the original code.

> secondly, [how] can I get the lvws to move to the top of the different
frames.

Just to make sure of your meaning. When you say "to the top of", is this
equivalent to "in front of"?

> I know that this is probably to extensive...and thanl\ks for your
thoughtful
> suggestions.

I think the details are obscuring your view of a solution. Try working with
a new project that just has a couple of controls. Write a prototype of what
you want your code to do before stabbing at your main project.

dnagel | Sun, 11 Nov 2007 18:28:00 GMT |

Microsoft Visual Basic Hot Answers

Microsoft Visual Basic New questions

Microsoft Visual Basic Related Categories