I've read and re-read this message several times now and I still can't
figure out what "tool" or code you are looking for. Can you describe your
problem in more detail so we can figure out what you have and what you are
trying to do with it?
Rick - MVP
http://www.mentalis.org/apilist/FloodFill.shtml
Rick
"Bob Mein" <anon...@discussions.microsoft.com> wrote in message
news:8DA916C9-7ACD-4E50...@microsoft.com...
> No problem sorry. I have a template image of how a client wants a program
to look. Part of that image includes two "progress bars." These bars
consist of a series of images that would 'light up' to show progress. Lets
use a physical fitness app as an example. There is one bar that lights up
based upon the pressure you apply to a sensor and the other bar shows total
reps. These bars flucuate in real-time. My question involves those
progress bars. I received image file templates of how they want it too
look. The progress bars involve a series of 50 mini rectanges that light up
as more data streams in.
>
> I've come to the conclusion that I'm going to have to "cut up" the orginal
template image to get these mini rectanges as individual images and as the
data streams in, have them appear in the app to show the progress. It is a
bit time intensive to cut the original template image file up this way.
>
> Before I did it, I wanted to check to see if there was a shortcut around
this. I was curious to find out if Visual Basic had any graphic tools that
could detect borders in an image. If so, I could probably get away with not
having to cut up the original template.
>
> ----- Rick Rothstein wrote: -----
VB has very little in the way of 'canned' tools - it's always WIY
(write-it-yourself!).
I'm not sure that it will help but I have a quick and dirty (and I mean
dirty - no eror checking etc) tool that I wrote to do somethig similar to
what you require. It takes an image and cuts it up into a number of images
(all the same size). It was written as a way of splitting what were
pictureclip images into individual images, all of the same dimensions.
If you do want it, let me know and I'll e-mail it to you.
Martin
"Bob Mein" <anon...@discussions.microsoft.com> wrote in message
news:8DA916C9-7ACD-4E50...@microsoft.com...
> No problem sorry. I have a template image of how a client wants a program
to look. Part of that image includes two "progress bars." These bars
consist of a series of images that would 'light up' to show progress. Lets
use a physical fitness app as an example. There is one bar that lights up
based upon the pressure you apply to a sensor and the other bar shows total
reps. These bars flucuate in real-time. My question involves those
progress bars. I received image file templates of how they want it too
look. The progress bars involve a series of 50 mini rectanges that light up
as more data streams in.
>
> I've come to the conclusion that I'm going to have to "cut up" the orginal
template image to get these mini rectanges as individual images and as the
data streams in, have them appear in the app to show the progress. It is a
bit time intensive to cut the original template image file up this way.
>
> Before I did it, I wanted to check to see if there was a shortcut around
this. I was curious to find out if Visual Basic had any graphic tools that
could detect borders in an image. If so, I could probably get away with not
having to cut up the original template.
>
> ----- Rick Rothstein wrote: -----
>
I'd probably make a control project.
But I'm lazy. When I needed a custom progress bar, what I did was put two images
inside a frame, and simply move one or both around. No individual portions going
light or dark, just one picture of a row of unlit symbols and another picture of
lit up symbols. As progress changed, it adjusted how much the overlapped.
Unless yours has a different symbol in each spot, you can probably do the same or
similar. I never needed it, but I did consider having several versions of the
moving image, with slightly different conditions of the symbol at the edge so that
they could overlap by fractions of a symbol, without the symbols themselves ever
appearing to move.
Bob
--
Rod Stephens has published non-rectangular forms code in a couple of his books.
You might find samples or at least references on his <vb-helper.com> site.
Or you could google for "nonrectangular VB forms" (maybe with and without the dash)
<codehound.com/vb> may have some as well
Bob
--
Start a new project and place three OptionButtons and a CommandButton on the
Form (use the default names that VB gives them as the code depends on this;
and don't worry about where you place them). Paste the following code into
the Form's code window and Run the project. Click the OptionButtons to see
the effect. (You can also drag the Form around via a Left Mouse
Click/Drag -- important for you to do in your own program since you will
probably clip away the title bar.)
Rick - MVP
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function CreatePolygonRgn Lib "gdi32" _
(lpPoint As POINTAPI, _
ByVal nCount As Long, _
ByVal nPolyFillMode As Long) _
As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" _
(ByVal X1 As Long, _
ByVal Y1 As Long, _
ByVal X2 As Long, _
ByVal Y2 As Long) _
As Long
Private Declare Function SetWindowRgn Lib "user32" _
(ByVal hWnd As Long, _
ByVal hRgn As Long, _
ByVal bRedraw As Long) _
As Long
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) _
As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
' Used to support captionless drag
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Dim MyRegion(5) As POINTAPI
Dim DefinedRegion As Long
Dim DiffX As Single
Dim DiffY As Single
Dim MoveIt As Boolean
Private Sub Command1_Click()
DeleteObject DefinedRegion
Unload Me
End Sub
Private Sub Form_Load()
Dim opt As Object
MyRegion(0).X = 50
MyRegion(0).Y = 80
MyRegion(1).X = 150
MyRegion(1).Y = 30
MyRegion(2).X = 450
MyRegion(2).Y = 150
MyRegion(3).X = 250
MyRegion(3).Y = 380
MyRegion(4).X = 0
MyRegion(4).Y = 300
MyRegion(5).X = 100
MyRegion(5).Y = 275
Command1.Move 2445, 3240
Command1.Caption = "Exit"
For Each opt In Controls
If TypeOf opt Is OptionButton Then
opt.Move 2160, 1420 + 540 * (Val(Mid$( _
opt.Name, 7, 1)) - 1), 1800, 315
opt.FontSize = 14
End If
Next
Me.Move 3000, 3000, 8000, 6000
Option1.Caption = "Polygon"
Option2.Caption = "Ellipse1"
Option3.Caption = "Ellipse2"
End Sub
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Call ReleaseCapture
Call SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, _
HTCAPTION, ByVal 0&)
End If
End Sub
Private Sub Label1_Click()
Option1.Value = True
End Sub
Private Sub Label2_Click()
Option2.Value = True
End Sub
Private Sub Label3_Click()
Option3.Value = True
End Sub
Private Sub Option1_Click()
DefinedRegion = CreatePolygonRgn&( _
MyRegion(0), 1 + UBound(MyRegion), 1)
SetWindowRgn Me.hWnd, DefinedRegion, True
DeleteObject DefinedRegion
End Sub
Private Sub Option2_Click()
DefinedRegion = CreateEllipticRgn(20, 75, 400, 300)
SetWindowRgn Me.hWnd, DefinedRegion, True
DeleteObject DefinedRegion
End Sub
Private Sub Option3_Click()
DefinedRegion = CreateEllipticRgn(120, 50, 300, 400)
SetWindowRgn Me.hWnd, DefinedRegion, True
DeleteObject DefinedRegion
End Sub
"Bob Mein" <anon...@discussions.microsoft.com> wrote in message
news:D487724F-388F-48DA...@microsoft.com...
> Thank you for your responses guys. Pretty much what I was expecting,
though I like Bob's shortcut idea of sliding the image and might be able to
use it on one of the two progress bars.
>
> I do have one additional question. I've looked for this online and I've
searched the newsgroup and haven't been able to come up with an answer yet.
Windows Media Player 9.0 has a custom sized form....ie..not a typical square
or rectangle (though it will have it pop up if you move your mouse to top
part of the app.) Is this possible in VB to have your forms have rounded
edges and non-conventional shapes? And does anyone have a link to some
information so I can do further reserach on it? Thanks.
I'd think that would be overkill. By the time you get the images set, and the
logic needed to adjust them, you'd have used way more memory than it would
take just to have one full on, and another full off, and just copy over the parts
that are needed....
Here is a quick example using a class to give it that 'Object' feel. ;-)
(Click on the picturebox to see it increment)
Have fun!
LFS
' [ Form1 - Add 1 Picturebox ]
Option Explicit
Private Bar As New Class1
Private PC As Long
Private Sub Form_Load()
Bar.ReSet Picture1
Bar.Percent = PC
End Sub
Private Sub Picture1_Click()
PC = (PC + 25) Mod 125
Caption = PC
Bar.Percent = PC
End Sub
'[ Class1 ]
Option Explicit
Private DisplayBox As PictureBox
Private Width As Single
Private Height As Single
Private MarkOn As StdPicture
Private MarkOff As StdPicture
Public Sub ReSet(ByRef Display As PictureBox)
Dim wid#, hgt#, stp#
' Init properties
Set DisplayBox = Display
With Display
.AutoRedraw = True
Width = .ScaleWidth
Height = .ScaleHeight
End With
' Draw ON image
stp = Width / 41
hgt = Height / 21
For wid = stp To Width Step (stp * 4)
Display.Line (wid, hgt)-Step(stp * 3, Height - hgt - hgt), vbYellow, BF
Next
' Save image/ reset
Set MarkOn = Display.Image
Set Display.Picture = Nothing
' Draw OFF image
For wid = stp To Width Step (stp * 4)
Display.Line (wid, hgt)-Step(stp * 3, Height - hgt - hgt), vbYellow And &H7F7F7F, BF
Next
' Save image/ reset
Set MarkOff = Display.Image
Set Display.Picture = Nothing
End Sub
Public Property Let Percent(ByVal Value As Single)
Dim wid#
' Copy OFF image
DisplayBox.PaintPicture MarkOff, 0, 0
wid = Value * Width / 100
If wid > 0 Then
' Copy ON image
DisplayBox.PaintPicture MarkOn, 0, 0, wid, Height, 0, 0, wid, Height
End If
End Property
How about one full on, another full off, and a frame in between to do clipping?
The "off" picture can be anything, the background of the ctl, whatever.
The frame goes in front of that, no caption, no border
The "on" picture goes inside the frame.
Align everthing, and then just alter the .Width of the frame.
Bob
--
> How about one full on, another full off, and a frame in between to do clipping?
>
> The "off" picture can be anything, the background of the ctl, whatever.
> The frame goes in front of that, no caption, no border
> The "on" picture goes inside the frame.
> Align everthing, and then just alter the .Width of the frame.
Yeah, that would be better than juggling several images. But now,
add inverted text right in the middle to indicate the value!
<gd&r>
LFS
"Rick Rothstein" <rickNOS...@NOSPAMcomcast.net> wrote in message
news:OLtgNMEE...@TK2MSFTNGP11.phx.gbl...
I wrote it a couple of years ago in response to a similar question like the
one the OP asked. I used a simple example of how to create a Region that I
had found somewhere (from a book, I think) at the time and expanded the
concept into the sample I posted.
Rick - MVP