Solved

Form Top-Most proberty Problem

Posted on 2004-09-29
11
502 Views
Last Modified: 2009-05-08
i have a MDI-Form with property top-most=true
the problem when i open a child form and the focus entered to an object inside the child form specially datagrid object , the MDI_Form can't be always on top .
so what can i do ?
0
Comment
Question by:janartgroup
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12180622
What are you trying to accomplish?  What problems are you having with the parent TopMost = True?

Bob
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12181184
An MDI Child is contained completely within an MDI Parent.  Therefore you can't have the MDI Parent "above" the MDI Child with the TopMost property.  Setting the TopMost property on your MDI Parent will make it float above other applications.

~IM
0
 
LVL 8

Assisted Solution

by:wguerram
wguerram earned 50 total points
ID: 12181906
Are you setting the child form property MdiParent?

like

dim f as new form1
f.MdiParent = me

f.show

MDI Form is a container of forms and can't be on top of its own childs unless you don't set the mdiparent. you can do that only if you and SDI environment where every form is opened standalone. just like notepad.
0
 
LVL 4

Assisted Solution

by:eozz_2000
eozz_2000 earned 100 total points
ID: 12186835
Well... if you want to lost the top most when you open your child form and recover after closing the child:

you can set the topMost property of your first form to false before calling the child form, show the child form with ChildForm.ShowDialog(Me) and immediatly after this line set the topMos property of your parent form to True.

Or, in the code of you child form you can do this:

    Public Overloads Sub show(ByRef parentForm As Form)
        parentForm.TopMost = False
        Me.ShowDialog(parentForm)
        parentForm.TopMost = True
    End Sub

and in the parent form call frmChild.Show(Me)

Is practically the same thing, the second code give you the chance to access all the properties of the parent form... if you want.
0
 

Author Comment

by:janartgroup
ID: 12188357
Thanks For All Experts Care To Help Me in this problem

But till now i can't solve it .... so i will describe excatly what happned with me ..

well i develop in ERP Application so i have a lot of MDI Childs , so i can't use SDI Forms

i need my application to be Aloways on top of other windows opened in the operating system,not be alowys top on my MDI Child ..

ex: i have MDI Form , and Form A as switch board , and Form B ...

so i write the following code to open the Form B From Form A(switch board )
========================
dim vForm As New FormB
vForm.MdiParent = Me.ParentForm
vForm.Show
========================
This Code open the form B as MDI child to MDI Form

Till now no problem

The Problem Happned when I Clicked a button or foucsing any object inside the the Form B The MDI Parent LOST THE TOP-MOST PROPERTY ...

Just i need to avoid this problem , to let my application always on top

Thanks a lot
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 100 total points
ID: 12189735
Hi janartgroup,

I can't reproduce the problem.  I created a new project and added two forms: Form1 is the MDI Parent and Form2/Form3 are the two MDI Children.

On Form1, I set the IsMDIContainer and TopMost properties to True and had the following code to open Form2:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f2 As New Form2
        f2.MdiParent = Me
        f2.Show()
    End Sub

On Form2, I had the following code to open Form3:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f3 As New Form3
        f3.MdiParent = Me.MdiParent
        f3.Show()
    End Sub

On Form3, I added a couple buttons and textboxes so something could have the focus on it.  The TopMost property was never lost on my MDI Parent form.

~IM
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12190446
Can you post the code you are using to show FormA, the switch board
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12191169
Create a Module where with a function that receives the principal form ByRef, and then, when you click a child,  modify the TopMost property of the form that you have in your module, in the Closing event of your child, return the TopMost property to True.
0
 

Author Comment

by:janartgroup
ID: 12199874
Finally i Got where is the problem

just i make a new project with MDI Parent and MDI Child

the child form has an datagrid , when i open the child form the Top Most of MDI Parent Lost...

so i confirmed it when i set the datagrid visible to false and appned a button to re-set the datagrid visible to true , when i clicked this button the top-most of MDI Parent lost

so i think the problem in datagrid , and it mostly used in my application forms

thanks

Jean
0
 

Author Comment

by:janartgroup
ID: 12205893
Hello All Experts,

Congratulation ,,,,
I Come back This time with the solution....

This problem is caused by a bug with the DataGrid control.  When the handle of the DataGrid is created, it also creats its ToolTip which underneath calls SetWindowPos (Win API) and it breaks the zorder of the windows.  The workaround is to set form's TopMost property after the handle of the DataGrid is created.  
To create the handle of the DataGrid, you can explicitly request it and then ignore it.  Example,
the following code snippet will fix the problem:

Public Sub New()
        MyBase.New()
        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

        Dim trash As IntPtr
        trash = DataGrid1.Handle
        Me.TopMost = True
End Sub

So now , i will split the Point for who care to solve my problem
Thanks
Yours Jean
0
 

Author Comment

by:janartgroup
ID: 12206461
addional info

the best place to put this code ,in  the event Datarid.Paint
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now