473,421 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

A "Gradient" for Form Sections

I suppose something like this may have been posted before. I am unaware of
it.
It's intended to duplicate the gradient filter that MS provides in their
manifestation of CSS.
Yes, I know it creates a gazillion labels.
ESPECIALLY I KNOW it could Screw Up Your Form, so PLEASE, make a few
hundred safety copies before you try this at all.
Yes, I know an image might be easier on a one time basis, but it's not
likely to be as easily changed (I think).

Regardless this is mostly "whimsical" code.

You could see the before and after at

http://ffdba.com/BeforeandAfter.htm

Here's the code (if you're not good with code, just move on to the next
post, please, and don't mess up your db.) Your news client may add extra
line feeds which you will have to edit out:

Private Sub GradientSection(ByVal FormName As String, ByVal Section As
Long)
Dim f As Form
Dim c As Control
Dim s As String
Dim w As Long
Dim z As Long
' save a copy for the form as text
' with date and time so as not to overwrtie the original later
s = Environ("temp") & "\" & FormName & Format(Now(), "yyymmddhhnnss") &
".txt"
Application.SaveAsText acForm, FormName, s
If Len(Dir$(s)) = 0 Then
MsgBox "Safety not Saved", vbCritical
Exit Sub
End If
DoCmd.OpenForm FormName, acDesign
Set f = Forms(FormName)
w = f.Width / 256
With f
For z = 0 To .Section(Section).Controls.Count - 1
Set c = .Section(Section).Controls(z)
c.InSelection = False
Next z
For z = 0 To 255
Set c = Application.CreateControl( _
.Name, acLabel, Section, , , _
z * w, 0, w, .Section(Section).Height)
With c
' you can mess with this line to get the effect you want
.BackColor = CLng(RGB(0, z / 2, z))
.BackStyle = 1
.BorderStyle = 0
.InSelection = True
DoCmd.RunCommand acCmdSendToBack
.InSelection = False
End With
Next z
End With
DoCmd.Close acForm, f.Name, acSaveYes
End Sub

Public Sub test()
GradientSection "MDAC and ESO", acDetail
End Sub

--
Lyle
(for e-mail refer to http://ffdba.com/)
Nov 13 '05 #1
7 4707
yes..there is one at lebans site also...

http://www.lebans.com/gradientfill.htm
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #2
"Albert D. Kallal" <Pl*******************@msn.com> wrote in
news:f33zc.748939$oR5.683343@pd7tw3no:
yes..there is one at lebans site also...

http://www.lebans.com/gradientfill.htm


That's so incredibly fabulous. Thank you Albert!

I had been mucking around with gradiant bitmaps just this afternoon
and was having a terrible time because the screen resolutions for
deployment changed since I created them, so I was going to need to
redo all of them. But now, this takes care of the whole problem.

I have only one question for Stephen the Genius, though:

Why do you surround the bitmap with a black border? In one instance,
this turns out to not look good on my form (though not bad enough for
me to go back to a bitmap!).

Also, why do you have the colors run from bottom to top or from
right to left, instead of the more intuitive top to bottom and left
to right? My graphics program (Paintshop Pro) certainly does things
in the opposite order. That is, to me "starting" more intuitively
means top or left, while "ending" means bottom or right side.

It's no big deal at all, I was just wondering why you implemented it
that way.

On another note, how does the triangular work? It appears to always
use black as the third color.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #3
Hi David,
answers inline.
:-)

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.90...
"Albert D. Kallal" <Pl*******************@msn.com> wrote in
news:f33zc.748939$oR5.683343@pd7tw3no:
yes..there is one at lebans site also...

http://www.lebans.com/gradientfill.htm
That's so incredibly fabulous. Thank you Albert!

I had been mucking around with gradiant bitmaps just this afternoon
and was having a terrible time because the screen resolutions for
deployment changed since I created them, so I was going to need to
redo all of them. But now, this takes care of the whole problem.

I have only one question for Stephen the Genius, though:

Why do you surround the bitmap with a black border? In one instance,
this turns out to not look good on my form (though not bad enough for
me to go back to a bitmap!).


I do see a one pixel border here but only on the bottom and right edges.
A quick peek at the code reveals the answer but it's not documented so I
cannot remember why I was subtracting one from the calculated horizontal
and vertical dimensions. Commented out the code to fix the border issue.

Also, why do you have the colors run from bottom to top or from
right to left, instead of the more intuitive top to bottom and left
to right? My graphics program (Paintshop Pro) certainly does things
in the opposite order. That is, to me "starting" more intuitively
means top or left, while "ending" means bottom or right side.

It's no big deal at all, I was just wondering why you implemented it
that way.
You're absolutely right. There's a copy and paste bug for the Horizontal
or Vertical directions. I used the first entry in TRIVERTEX array for
the endpoint of the rectangle instead of the second. Posted fixed versio
n tonight.

On another note, how does the triangular work? It appears to always
use black as the third color. As I mentioned in my source code, I could not find a working sample in
VB so I had to experiment until I found a working solution. Math is a
weakness of mine. To really understand how the call works see:
http://msdn.microsoft.com/library/de.../en-us/gdi/bit
maps_8oa4.asp

David thank you for pointing out these errors. I wrote this function in
one night at the request of a NG participant and did not spend much time
testing it. I have posted the new version tonight, version .8.
http://www.lebans.com/gradientfill.htm
:-)

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


Nov 13 '05 #4
Stephen,

Your version 8 description reads ---
"Gradient fills now more logicall start from right to left and top to bottom."

Shouldn't that be .... left to right .....?

Steve
PC Datasheet

"Stephen Lebans" <Fo****************************************@linval id.com> wrote
in message news:AX*********************@ursa-nb00s0.nbnet.nb.ca...
Hi David,
answers inline.
:-)

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.90...
"Albert D. Kallal" <Pl*******************@msn.com> wrote in
news:f33zc.748939$oR5.683343@pd7tw3no:
yes..there is one at lebans site also...

http://www.lebans.com/gradientfill.htm


That's so incredibly fabulous. Thank you Albert!

I had been mucking around with gradiant bitmaps just this afternoon
and was having a terrible time because the screen resolutions for
deployment changed since I created them, so I was going to need to
redo all of them. But now, this takes care of the whole problem.

I have only one question for Stephen the Genius, though:

Why do you surround the bitmap with a black border? In one instance,
this turns out to not look good on my form (though not bad enough for
me to go back to a bitmap!).


I do see a one pixel border here but only on the bottom and right edges.
A quick peek at the code reveals the answer but it's not documented so I
cannot remember why I was subtracting one from the calculated horizontal
and vertical dimensions. Commented out the code to fix the border issue.

Also, why do you have the colors run from bottom to top or from
right to left, instead of the more intuitive top to bottom and left
to right? My graphics program (Paintshop Pro) certainly does things
in the opposite order. That is, to me "starting" more intuitively
means top or left, while "ending" means bottom or right side.

It's no big deal at all, I was just wondering why you implemented it
that way.


You're absolutely right. There's a copy and paste bug for the Horizontal
or Vertical directions. I used the first entry in TRIVERTEX array for
the endpoint of the rectangle instead of the second. Posted fixed versio
n tonight.

On another note, how does the triangular work? It appears to always
use black as the third color.

As I mentioned in my source code, I could not find a working sample in
VB so I had to experiment until I found a working solution. Math is a
weakness of mine. To really understand how the call works see:
http://msdn.microsoft.com/library/de.../en-us/gdi/bit
maps_8oa4.asp

David thank you for pointing out these errors. I wrote this function in
one night at the request of a NG participant and did not spend much time
testing it. I have posted the new version tonight, version .8.
http://www.lebans.com/gradientfill.htm
:-)

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Nov 13 '05 #5
Christ, two beers and I can't do anything right!<grin>
Fixed and posted.
:-)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"PC Datasheet" <no****@nospam.spam> wrote in message
news:l4****************@newsread2.news.atl.earthli nk.net...
Stephen,

Your version 8 description reads ---
"Gradient fills now more logicall start from right to left and top to bottom."
Shouldn't that be .... left to right .....?

Steve
PC Datasheet

"Stephen Lebans" <Fo****************************************@linval id.com> wrote in message news:AX*********************@ursa-nb00s0.nbnet.nb.ca...
Hi David,
answers inline.
:-)

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.90...
"Albert D. Kallal" <Pl*******************@msn.com> wrote in
news:f33zc.748939$oR5.683343@pd7tw3no:

> yes..there is one at lebans site also...
>
> http://www.lebans.com/gradientfill.htm

That's so incredibly fabulous. Thank you Albert!

I had been mucking around with gradiant bitmaps just this afternoon and was having a terrible time because the screen resolutions for
deployment changed since I created them, so I was going to need to
redo all of them. But now, this takes care of the whole problem.

I have only one question for Stephen the Genius, though:

Why do you surround the bitmap with a black border? In one instance, this turns out to not look good on my form (though not bad enough for me to go back to a bitmap!).


I do see a one pixel border here but only on the bottom and right edges. A quick peek at the code reveals the answer but it's not documented so I cannot remember why I was subtracting one from the calculated horizontal and vertical dimensions. Commented out the code to fix the border issue.

Also, why do you have the colors run from bottom to top or from
right to left, instead of the more intuitive top to bottom and left to right? My graphics program (Paintshop Pro) certainly does things in the opposite order. That is, to me "starting" more intuitively
means top or left, while "ending" means bottom or right side.

It's no big deal at all, I was just wondering why you implemented it that way.


You're absolutely right. There's a copy and paste bug for the Horizontal or Vertical directions. I used the first entry in TRIVERTEX array for the endpoint of the rectangle instead of the second. Posted fixed versio n tonight.

On another note, how does the triangular work? It appears to always use black as the third color.

As I mentioned in my source code, I could not find a working sample in VB so I had to experiment until I found a working solution. Math is a weakness of mine. To really understand how the call works see:
http://msdn.microsoft.com/library/de.../en-us/gdi/bit maps_8oa4.asp

David thank you for pointing out these errors. I wrote this function in one night at the request of a NG participant and did not spend much time testing it. I have posted the new version tonight, version .8.
http://www.lebans.com/gradientfill.htm
:-)

--
David W. Fenton http://www.bway.net/~dfenton dfenton at bway dot net
http://www.bway.net/~dfassoc



Nov 13 '05 #6
"Stephen Lebans"
<Fo****************************************@linval id.com> wrote in
news:AX*********************@ursa-nb00s0.nbnet.nb.ca:
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.90...
"Albert D. Kallal" <Pl*******************@msn.com> wrote in
news:f33zc.748939$oR5.683343@pd7tw3no:
> yes..there is one at lebans site also...
>
> http://www.lebans.com/gradientfill.htm
That's so incredibly fabulous. Thank you Albert!

I had been mucking around with gradiant bitmaps just this
afternoon and was having a terrible time because the screen
resolutions for deployment changed since I created them, so I was
going to need to redo all of them. But now, this takes care of
the whole problem.

I have only one question for Stephen the Genius, though:

Why do you surround the bitmap with a black border? In one
instance, this turns out to not look good on my form (though not
bad enough for me to go back to a bitmap!).


I do see a one pixel border here but only on the bottom and right
edges. A quick peek at the code reveals the answer but it's not
documented so I cannot remember why I was subtracting one from the
calculated horizontal and vertical dimensions. Commented out the
code to fix the border issue.


I looked at the code to see if I could find something in there, but
actually couldn't find it. Can you tell me where it is, so I don't
have to redownload?
Also, why do you have the colors run from bottom to top or from
right to left, instead of the more intuitive top to bottom and
left to right? My graphics program (Paintshop Pro) certainly does
things in the opposite order. That is, to me "starting" more
intuitively means top or left, while "ending" means bottom or
right side.

It's no big deal at all, I was just wondering why you implemented
it that way.


You're absolutely right. There's a copy and paste bug for the
Horizontal or Vertical directions. I used the first entry in
TRIVERTEX array for the endpoint of the rectangle instead of the
second. Posted fixed versio n tonight.


Heh. I assumed that the Windows APIs you were using did it that way,
and your UI to it was just letting that leak through.

Sometimes the simple explanation is the right one, though!
On another note, how does the triangular work? It appears to
always use black as the third color.


As I mentioned in my source code, I could not find a working
sample in VB so I had to experiment until I found a working
solution. Math is a weakness of mine. To really understand how the
call works see:
http://msdn.microsoft.com/library/de...l=/library/en-

us/gd i/bit maps_8oa4.asp

David thank you for pointing out these errors. I wrote this
function in one night at the request of a NG participant and did
not spend much time testing it. I have posted the new version
tonight, version .8. http://www.lebans.com/gradientfill.htm
:-)


Errors? Hardly errors! It's incredibly useful for what I was trying
to accomplish. I wish I'd known about it 6 weeks ago!

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7
Hi David,
both changes are in the modGradient module towards the end of the
module.

The current code with the 2 lines marked with"*" that required
modification:

tri(1).Alpha = 0
tri(1).Blue = MakeInt(0, BEnd)
tri(1).Green = MakeInt(0, GEnd)
tri(1).Red = MakeInt(0, REnd)
tri(0).X = (rcClient.right - rcClient.Left) - 1 ' Debug was tri(0)
copy mistake June 13 Debug -one pixel border- 1
tri(0).y = (rcClient.Bottom - rcClient.top) - 1 ' Debug was tri(0)
copy mistake June 13 Debug - one pixel border - 1

The corrected code:

tri(1).Alpha = 0
tri(1).Blue = MakeInt(0, BEnd)
tri(1).Green = MakeInt(0, GEnd)
tri(1).Red = MakeInt(0, REnd)
tri(1).X = (rcClient.right - rcClient.Left) ' *
tri(1).y = (rcClient.Bottom - rcClient.top) '*

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.74...
"Stephen Lebans"
<Fo****************************************@linval id.com> wrote in
news:AX*********************@ursa-nb00s0.nbnet.nb.ca:
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.90...
"Albert D. Kallal" <Pl*******************@msn.com> wrote in
news:f33zc.748939$oR5.683343@pd7tw3no:

> yes..there is one at lebans site also...
>
> http://www.lebans.com/gradientfill.htm

That's so incredibly fabulous. Thank you Albert!

I had been mucking around with gradiant bitmaps just this
afternoon and was having a terrible time because the screen
resolutions for deployment changed since I created them, so I was
going to need to redo all of them. But now, this takes care of
the whole problem.

I have only one question for Stephen the Genius, though:

Why do you surround the bitmap with a black border? In one
instance, this turns out to not look good on my form (though not
bad enough for me to go back to a bitmap!).


I do see a one pixel border here but only on the bottom and right
edges. A quick peek at the code reveals the answer but it's not
documented so I cannot remember why I was subtracting one from the
calculated horizontal and vertical dimensions. Commented out the
code to fix the border issue.


I looked at the code to see if I could find something in there, but
actually couldn't find it. Can you tell me where it is, so I don't
have to redownload?
Also, why do you have the colors run from bottom to top or from
right to left, instead of the more intuitive top to bottom and
left to right? My graphics program (Paintshop Pro) certainly does
things in the opposite order. That is, to me "starting" more
intuitively means top or left, while "ending" means bottom or
right side.

It's no big deal at all, I was just wondering why you implemented
it that way.


You're absolutely right. There's a copy and paste bug for the
Horizontal or Vertical directions. I used the first entry in
TRIVERTEX array for the endpoint of the rectangle instead of the
second. Posted fixed versio n tonight.


Heh. I assumed that the Windows APIs you were using did it that way,
and your UI to it was just letting that leak through.

Sometimes the simple explanation is the right one, though!
On another note, how does the triangular work? It appears to
always use black as the third color.


As I mentioned in my source code, I could not find a working
sample in VB so I had to experiment until I found a working
solution. Math is a weakness of mine. To really understand how the
call works see:
http://msdn.microsoft.com/library/de...l=/library/en-

us/gd
i/bit maps_8oa4.asp

David thank you for pointing out these errors. I wrote this
function in one night at the request of a NG participant and did
not spend much time testing it. I have posted the new version
tonight, version .8. http://www.lebans.com/gradientfill.htm
:-)


Errors? Hardly errors! It's incredibly useful for what I was trying
to accomplish. I wish I'd known about it 6 weeks ago!

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sooha Park Lee | last post by:
I would like to compare two "double" numbers. To overcome round-off error, I am using the following strategy: rounding each number and try to convert it into interger by multiplying 10E6. One...
3
by: asognoth | last post by:
Hi... Does anybody have a clue how to solve this problem? the task is to change the following method in that manner that it draws the (calculated) image form left to right instead of from top...
4
by: Greg | last post by:
I've searched everywhere for a solution Microsoft .NET Framework V 2.0.50727 AutoEventWireup="false" image2.aspx resize an image on the fly but Page_Load is triggered twice: Any suggestion?...
5
by: balakrishnan.dinesh | last post by:
hi Frnds, I need Confirm box with "yes" or "no" buttons, Is that possible in JAVASCRIPT , Can anyone tell me the solution for this or anyother way to create confirm box with "yes" or "no" button?...
10
by: Anze | last post by:
Hmmm... anyone? :) Anze Anze wrote:
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.