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. .NET (Core and Framework)
  4. Popup Form Class Problems

Popup Form Class Problems

Scheduled Pinned Locked Moved .NET (Core and Framework)
database
2 Posts 2 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
    
    S 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
      
      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      I guess the problem is because you're calling methods/setting properties on the control from another thread. You should use BeginInvoke or Invoke methods on the UI (the Form object in your case) to marshal the call to the UI thread. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      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