3 Replies - 536 Views - Last Post: 01 July 2012 - 12:56 PM Rate Topic: -----

#1 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 23
  • View blog
  • Posts: 330
  • Joined: 11-July 07

Seamless Refresh

Posted 01 July 2012 - 10:02 AM

Hello, D.I.C.

Today I'm having a play around with VB.NET and looking at making a little Task Manager kind of thing; I've completed the little bits like populating the running processes and such, but noticed that on the Task Manager provided by Microsoft, the Memory updates at a regular interval but nothing else refreshes, where when I try and reload the running processes to get the updated memory usage, the whole thing refreshes which doesn't look professional and is ugly.

Also, while I'm on the subject - how can I make a DLL call to "kernel32.dll" to gain more access of the processes, IE controlling the windows and such.


Thanks for any help, always appreciated.

~huzi

Is This A Good Question/Topic? 0
  • +

Replies To: Seamless Refresh

#2 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2538
  • View blog
  • Posts: 4,639
  • Joined: 24-September 10

Re: Seamless Refresh

Posted 01 July 2012 - 10:12 AM

checkout pinvoke.net, it's a catalogue of methods to tie to in Windows... in left bar you'll find the kernel32.dll:

http://www.pinvoke.net/#

I'm not sure what you're talking about when "everything" refreshes. I'm guessing you mean the entire window flickers as it redraws itself? I'm guessing you're drawing graphics on screen as opposed to using existing text controls to just display text.

If that's so, do two things:

1) make sure you have double buffer turned on:
http://msdn.microsof...y/3t7htc9c.aspx

2) make sure you don't do any complicated tasks in the main draw thread, move any complicated non-drawing processes to another thread and redraw from data generated in that other thread.
Was This Post Helpful? 1
  • +
  • -

#3 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 23
  • View blog
  • Posts: 330
  • Joined: 11-July 07

Re: Seamless Refresh

Posted 01 July 2012 - 10:20 AM

View Postlordofduct, on 01 July 2012 - 06:12 PM, said:

checkout pinvoke.net, it's a catalogue of methods to tie to in Windows... in left bar you'll find the kernel32.dll:

http://www.pinvoke.net/#

I'm not sure what you're talking about when "everything" refreshes. I'm guessing you mean the entire window flickers as it redraws itself? I'm guessing you're drawing graphics on screen as opposed to using existing text controls to just display text.

If that's so, do two things:

1) make sure you have double buffer turned on:
http://msdn.microsof...y/3t7htc9c.aspx

2) make sure you don't do any complicated tasks in the main draw thread, move any complicated non-drawing processes to another thread and redraw from data generated in that other thread.


Thanks for the links!

As for the drawing graphics, I'm not -- I'm using a ListViewControl but when it comes to reloading the processes, all the processes are flickering.

Thanks for your reply

~huzi

This post has been edited by huzi8t9: 01 July 2012 - 10:22 AM

Was This Post Helpful? 0
  • +
  • -

#4 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 23
  • View blog
  • Posts: 330
  • Joined: 11-July 07

Re: Seamless Refresh

Posted 01 July 2012 - 12:56 PM

If it makes things any easier, I'll attach my app, then you can really see what's going off and how it's working.

Attached File  Hider.zip (83.38K)
Number of downloads: 22

To populate my ListViewControl, I'm using this sub:

    Private Sub RefreshProcesses()
        lbWindows.Items.Clear()

        For Each wind As Process In Process.GetProcesses
            Dim x As New ListViewItem

            Try
                x.Text = wind.ProcessName
                x.SubItems.Add(wind.MainWindowTitle)
                x.SubItems.Add(wind.PrivateMemorySize64.ToString("X"))
                If (wind.Responding) Then
                    x.SubItems.Add("Responding")
                Else
                    x.SubItems.Add("Not Responding")
                End If

                Dim xTime As Date = wind.StartTime, xStr As String

                If (xTime.Hour < 10) Then
                    xStr = "0" & xTime.Hour
                Else
                    xStr = xTime.Hour
                End If

                xStr &= ":"

                If (xTime.Minute < 10) Then
                    xStr &= "0" & xTime.Minute
                Else
                    xStr &= xTime.Minute
                End If

                xStr &= ":"

                If (xTime.Second < 10) Then
                    xStr &= "0" & xTime.Second
                Else
                    xStr &= xTime.Second
                End If

                If Not (wind.Responding) Then
                    x.BackColor = Color.IndianRed
                End If

                x.SubItems.Add(xStr)

            Catch ex As Exception
                x.BackColor = Color.IndianRed
                x.SubItems.Add(ex.Message)
            End Try

            x.Tag = wind.Id

            lbWindows.Items.Add(x)

            Application.DoEvents()
        Next
    End Sub



Thanks again

~huzi

This post has been edited by huzi8t9: 01 July 2012 - 12:58 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1