Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problems Displaying Forms

Problems Displaying Forms

Scheduled Pinned Locked Moved Visual Basic
database
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chris Quick
    wrote on last edited by
    #1

    I am creating an application that will create a notify window similar to outlook 2003 notify popup. I am making an asyncronous remoting call using system.thread that raises an event to show the form. However, the form shows up as a black box and then immediately disappears when the event is called. If I call the function through a menu item or button, it works fine. Here's the popup code:

    Private Sub ATU\_RetrieveDone(ByVal e As AsyncUpdater.AsyncUpdaterEventArgs) Handles ATU.RetrieveDone
        Me.UpdateTimer.Enabled = False
        If e.Forums Is Nothing Then
            UpdateTopicListView(e.Results) ' Updates a list view and 
                                           ' displays the popup.
        Else
            UpdateForumListView(e.Forums)
        End If
        Me.UpdateTimer.Enabled = True
    End Sub
    
    Private Sub UpdateTopicListView(ByVal Topics As ResultsCollection)
        For index As Integer = 0 To Topics.Count - 1
            ...
        Next
        Dim Message As String
        Message = "{0} new topic updates have been retrieved from {1}"
        Me.ShowPopup(String.Format(Message, Topics.Count, ClientSettings.WebURL))
    End Sub
    
    
    Private Sub ShowPopup(ByVal Message As String, Optional ByVal TimeOut As Integer = 0)
        Dim displaytime As Integer
        If TimeOut < 1000 Then
            displaytime = ClientSettings.PopupTime \* 1000
        Else
            displaytime = TimeOut
        End If
        Dim PW As New PopupWindow
        PW.SetProperties(NewMessagePopup.Blend, Message, displaytime)
        PW.ShowPopup()
    End Sub
    

    And here's routine that creates the popup using a seperate windows form.

    Public Sub ShowPopup()
        Dim tbl As TaskBarLocation
        Dim workingArea As Rectangle
        Dim pt As Point
    
        pt = New Point
        pt.X = 0 : pt.Y = 0
    
        workingArea = SystemInformation.WorkingArea
        tbl = GetTaskBarLocation() ' Gets an enumerator 
                                   ' indicating the windows task bar 
                                   ' location.
    
        Select Case tbl
            Case TaskBarLocation.Bottom
                pt.X = workingArea.Right - Me.Width
                pt.Y = workingArea.Bottom - Me.Height
            Case TaskBarLocation.Left
                pt.X = workingArea.Left
                pt.Y = workingArea.Bottom - Me.Height
            Case TaskBarLocation.Right
                pt.X = workingArea.Right - Me.Width
    
    C 1 Reply Last reply
    0
    • C Chris Quick

      I am creating an application that will create a notify window similar to outlook 2003 notify popup. I am making an asyncronous remoting call using system.thread that raises an event to show the form. However, the form shows up as a black box and then immediately disappears when the event is called. If I call the function through a menu item or button, it works fine. Here's the popup code:

      Private Sub ATU\_RetrieveDone(ByVal e As AsyncUpdater.AsyncUpdaterEventArgs) Handles ATU.RetrieveDone
          Me.UpdateTimer.Enabled = False
          If e.Forums Is Nothing Then
              UpdateTopicListView(e.Results) ' Updates a list view and 
                                             ' displays the popup.
          Else
              UpdateForumListView(e.Forums)
          End If
          Me.UpdateTimer.Enabled = True
      End Sub
      
      Private Sub UpdateTopicListView(ByVal Topics As ResultsCollection)
          For index As Integer = 0 To Topics.Count - 1
              ...
          Next
          Dim Message As String
          Message = "{0} new topic updates have been retrieved from {1}"
          Me.ShowPopup(String.Format(Message, Topics.Count, ClientSettings.WebURL))
      End Sub
      
      
      Private Sub ShowPopup(ByVal Message As String, Optional ByVal TimeOut As Integer = 0)
          Dim displaytime As Integer
          If TimeOut < 1000 Then
              displaytime = ClientSettings.PopupTime \* 1000
          Else
              displaytime = TimeOut
          End If
          Dim PW As New PopupWindow
          PW.SetProperties(NewMessagePopup.Blend, Message, displaytime)
          PW.ShowPopup()
      End Sub
      

      And here's routine that creates the popup using a seperate windows form.

      Public Sub ShowPopup()
          Dim tbl As TaskBarLocation
          Dim workingArea As Rectangle
          Dim pt As Point
      
          pt = New Point
          pt.X = 0 : pt.Y = 0
      
          workingArea = SystemInformation.WorkingArea
          tbl = GetTaskBarLocation() ' Gets an enumerator 
                                     ' indicating the windows task bar 
                                     ' location.
      
          Select Case tbl
              Case TaskBarLocation.Bottom
                  pt.X = workingArea.Right - Me.Width
                  pt.Y = workingArea.Bottom - Me.Height
              Case TaskBarLocation.Left
                  pt.X = workingArea.Left
                  pt.Y = workingArea.Bottom - Me.Height
              Case TaskBarLocation.Right
                  pt.X = workingArea.Right - Me.Width
      
      C Offline
      C Offline
      Chris Quick
      wrote on last edited by
      #2

      I've done some more research and it appears the problem is caused using timers. I've used both System.Timers.Timer and System.Windows.Forms.Timer and both give the same result, a black box that appears and then disappears. If I call the ShowPopup subroutine by clicking a button, it displays correctly. If the timer causes the form to be displayed, I get the black box. Here's the logic steps used: 1) Timer.Tick event occurs 2) Tick Handler creates a new AsyncUpdater and invokes the GetUpdate method 3) GetUpdate creates a new thread and begins the remoting call 4) Once GetUpdate has completed the remoting call, the event RetrieveDone is raised. 5) The main form handles the event causing a list view to update it's list of items. 6) The ShowPopup method is called to display the popup. Any help or ideas would be greatly appreciated. I can't understand why the manual invoking (pressing a button) works but the event handler doesn't. Thanks!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups