Re: What happened to the Mabry demo software after they closed down?
- From: "Mike Williams" <mikea@xxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 18:36:37 -0000
"MM" <kylix_is@xxxxxxxxxxx> wrote in message news:1kj3r3909j8n947mnlt060vnoghv1djuqk@xxxxxxxxxx
Yes, I had thought about bitblt, having used it years ago
and been blown away by the speed. However, I'm not
talking about a 7-segment display, but a simple LED, like
the one that lights up when you press Num Lock. I have
a freeware LED ocx from Scott Hather, but the 5mm
simulated "lamp" is too large. I want the equivalent of
a 3mm one, again about the size of the Num Lock or
Caps Lock LEDs on most keyboards.
In that case I'm not sure what you meant when you said that the simple act of showing or not showing a picture box was giving you a speed problem? What exactly do you mean by that? It now appears that it was the size that was the problem, not the speed of display? A picture the size of a small LED (either in a picture box or an image control or one that you blit yourself) will display or hide itself almost instantly when your code decides to change its state (visible or hidden or on or off). Naturally, a monitor displays only one frame every 10 to 15 milliseconds or so, and it can therefore be up to 10 or 15 milliseconds before "the stuff you have drawn to the display" actually appears on the monitor. Is that what your problem is? And if so, why is that a problem for you?
Why don't you just draw a picture of a "lit LED" and an "unlit LED" in a graphics program or something (or download one from somewhere if, like me, you have no artistic flair) and then just use that picture to simulate your LED? What problem are you having with that?
By the way, I've just "Googled" for the Scott Hather LED thing you mentioned but the ocx will not work on my Vista system, even after I have registered it using an admin mode DOS box, so I can't see what kind of graphics you are looking at, but I used to be heavily "into" electronics myself (more than twenty five years ago!) and I assume it is just a simple circular LED. In fact there is an image of a pair of such LEDs on the web page containing Scott Hather's download so I grabbed that image as a jpg and its pixel size is such that the "round LED" part of the overall image is indeed 5 mm when displayed at its original pixel size on a computer running at the standard 96 dpi (15 twips per pixel) setting. Do you mean you want to display that image so that the round LED part would be 3 mm (instead of 5 mm) on such a machine? If so then you can just resize it in VB code (see example below). But do remember that when talking about millimeters (or inches or whatever) on a computer display you are talking about "logical" millimeters (or "logical" inches). These logical measurements are not necessarily the same physical size as their "real world" equivalents (if you hold a measuring rule against the display) and moreover they can (and often will be) very different physical sizes on different machines. Without knowing exactly what you mean by "display it as a 3 mm LED" I cannot really help you further. Anyway, try grabbing the same image I did (or using an image you already have) and then using the following code to reduce it from a "5mm LED" image to a "3mm LED" image. The example uses two picture boxes and one command button. Change the hard coded original image path to the path and filename of the appropriate image on your own machine. Paste the code into your Form (containign a command button and two picture boxes) and run the code and click the button. Also, I've used two picture boxes in the example simply so you can easily see the two (original and resized" images side by side, but there is no actual need to use two picture boxes in your real code.
Or have I completely misunderstood your request?
Mike
Option Explicit
Private Declare Function StretchBlt Lib "gdi32" _
(ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, _
ByVal dwRop As Long) As Long
Private Declare Function SetStretchBltMode Lib "gdi32" _
(ByVal hdc As Long, ByVal nStretchMode As Long) As Long
Private Const STRETCH_DELETESCANS = 3
Private Const STRETCH_HALFTONE = 4
Private Sub Command1_Click()
Me.ScaleMode = vbPixels
Picture1.BorderStyle = vbBSNone
Picture1.AutoSize = True
Picture1.Picture = LoadPicture("c:\temp\led1.jpg")
DoEvents
Picture2.BorderStyle = vbBSNone
Picture2.AutoRedraw = True
Picture2.Width = Picture1.Width * 3! / 5!
Picture2.Height = Picture1.Height * 3! / 5!
SetStretchBltMode Picture2.hdc, STRETCH_DELETESCANS
SetStretchBltMode Picture2.hdc, STRETCH_HALFTONE
StretchBlt Picture2.hdc, _
0, 0, Picture2.Width, Picture2.Height, _
Picture1.hdc, _
0, 0, Picture1.Width, Picture1.Height, vbSrcCopy
Picture2.Picture = Picture2.Image
End Sub
.
- Follow-Ups:
- References:
- What happened to the Mabry demo software after they closed down?
- From: MM
- Re: What happened to the Mabry demo software after they closed down?
- From: Dick Grier
- Re: What happened to the Mabry demo software after they closed down?
- From: MM
- Re: What happened to the Mabry demo software after they closed down?
- From: Mike Williams
- Re: What happened to the Mabry demo software after they closed down?
- From: MM
- What happened to the Mabry demo software after they closed down?
- Prev by Date: Re: INSERTing an empty attribute value
- Next by Date: Re: Versions
- Previous by thread: Re: What happened to the Mabry demo software after they closed down?
- Next by thread: Re: What happened to the Mabry demo software after they closed down?
- Index(es):
Relevant Pages
|