Results 1 to 10 of 10

Thread: A Bug? ShowDialog and Opacity and TaskBar

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    A Bug? ShowDialog and Opacity and TaskBar

    I Think I have found a bug. Here is the situation:

    In form1 add a button and add this code:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.      Dim frm As New Form2(Me)
    3.      frm.ShowDialog()
    4.      Me.Show()
    5. End Sub
    In Form2 add this code:
    VB Code:
    1. Public Class Form2
    2.     Inherits System.Windows.Forms.Form
    3.     Dim pform As Form
    4. #Region " Windows Form Designer generated code "
    5.  
    6.     Public Sub New(ByVal frm As Form)
    7.         MyBase.New()
    8.         pform = frm
    9.         'This call is required by the Windows Form Designer.
    10.         InitializeComponent()
    11.  
    12.         'Add any initialization after the InitializeComponent() call
    13.  
    14.    End Sub
    15. '
    16. '
    17. '
    18. Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    19.         Me.Opacity = 0.99 ' Any value less than 1
    20.         Me.Opacity = 1 ' Even if you dont change it to 1 it still happens
    21.      '   MessageBox.Show(Me.ShowInTaskbar)
    22.         pform.Hide()
    23.      '   MessageBox.Show(Me.ShowInTaskbar)
    24. End Sub

    You will note that when Form2 is shown its taksbar icon is hidden, despite ShowInTaskbar property of Form2 remains True. This situation happens if only
    1-you change the Opacity
    2- hide the parent form
    3-form be shown modally.

    This is tested only in VB.NET and Framework 1.1

    If its a bug, how can I report it to MS? any MVP around?

    Attached is the project if you want to test.
    Attached Files Attached Files
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    No idea?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Put this line pform = frm after InitializeComponent() and see if it works.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Originally posted by DevGrp
    Put this line pform = frm after InitializeComponent() and see if it works.
    No it does not work!
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    In fact i just noticed if you change the opacity in the load event of the startup form you wont get its icon in taks bar.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  6. #6
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    erm when using opacity , 1 represents 100% to make say a 10% ( almost invisible ) you need to do 0.1 , eg:
    in Form1 ( no need to modify the New sub in form2 either )
    VB Code:
    1. [COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Button1_Click([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] Button1.Click
    2.         [COLOR=BLUE]Dim[/COLOR] frm [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]New[/COLOR] Form2()
    3.         AddOwnedForm(frm) [COLOR=GREEN]'/// add it as an owned form
    4. [/COLOR]        frm.Show()
    5.     [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
    in Form2 :
    VB Code:
    1. [COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Form2_Load([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] [COLOR=BLUE]MyBase[/COLOR].Load
    2.         [COLOR=BLUE]Dim[/COLOR] frmMain [COLOR=BLUE]As[/COLOR] Form1 = Owner
    3.         [COLOR=BLUE]Me[/COLOR].Opacity = 0.1 '///0.1 = 10%
    4.         frmMain.Hide()
    5.     [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub
    6.  
    7. [/COLOR]    [COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Form2_Closing([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Object[/COLOR], [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.ComponentModel.CancelEventArgs) [COLOR=BLUE]Handles[/COLOR] [COLOR=BLUE]MyBase[/COLOR].Closing
    8.         Owner.Show()
    9.         [COLOR=BLUE]Me[/COLOR].Close()
    10.     [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
    the Owner bit replaces the modified new sub eg:
    Public Sub New(ByVal frm As Form)
    MyBase.New()
    pform = frm
    ^^^^ becomes...
    Dim frmMain As Form1 = Owner
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Thanks, I will test your code, but as i stated before, you dont need to have two forms to note the bug(?). Just in a single form load event (Startup form) put the following code:
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Me.Opacity = 0.1
    3.         Me.Opacity=1 ' This does not make any difference in showing icon in taskbar
    4. End Sub
    And you see that the form is not shown in taskbar.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  8. #8
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    strange , i just tried the following in a single form and it still showed up in the taskbar as it should do...
    VB Code:
    1. [COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Form1_Load([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] [COLOR=BLUE]MyBase[/COLOR].Load      
    2.     [COLOR=BLUE]Me[/COLOR].Opacity = 0.5
    3. [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Yes, strange, as i am testing here and facing various results, sometimes its shown and sometimes not!!!!!
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    dynamic_sysop:
    Your code still does not show the form2 in taskbar and on closing form2 breaks with StackOverFlowException. If you change frm.Show()
    to frm.ShowDialog the error does not happen but still form2 is not shown in taksbar.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width