[RESOLVED] I want task manager waveform graphic on my Form
All,
How can I achieve this? I have serached the forums and been digging around for quite some time on this issue.
Has anyone been able to do this? A little green box like the one you see in the systray would be acceptable, but the green waveform is preferred (like the supplied pic)
Ideally, I would also like to store the values in a file as time goes on.
Thanks!
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Re: I want task manager waveform graphic on my Form
This will give you a start. I found this piece of code on a web page that isn't there any longer (at least the link I saved no longer works). I thought it was kind of cool, so I popped it in my Code Library in case I ever needed anything like it. Right now it just draws an ever scrolling wave type graph, but I'm sure you can tweak it so that it is graphing based on an actual something. Anyway, play around with this. It uses a Picturebox and a Timer control.
VB Code:
Option Explicit
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Const PS_SOLID = 0
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" _
(ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
ByVal hObject As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, _
ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, _
ByVal y As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long, ByVal lpPoint As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Const pWidth = 250 ' Width of picture box in pixels.
Private Const pHeight = 150 ' Height of picture box in pixels.
Private Const pGrid = 25 ' Distance between grid lines.
Private Const tInterval = 100 ' Interval between timer samplings
' in milliseconds.
Private Const pHeightHalf = pHeight \ 2
Private counter As Long ' Number of data points logged so far. Used to
' sync grid.
Private oldY As Long ' Contains the previous y coordinate.
Private hDCh As Long, hPenB As Long, hPenC As Long
Re: I want task manager waveform graphic on my Form
Yes that is a great start! I believe I might be able to dig up some APIs for accessing the system resource usage..?... Once I do, I should be able to plug those results directly into this graph. Cool!
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Re: I want task manager waveform graphic on my Form
I will - my plan is to create a stand-alone OCX that is self-aware of it's source - in this case the Task Manager, but I have other uses for it as well.
The only banana-peel I can see is they set the scale-mode of the sample form to 3... Not sure how that will affect my normal Forms which always use the default scale-mode...
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)