|
|
Comments and Discussions
|
|
 |

|
This article is written before I joined CP in 2002! Kudos to Nish again.
Got my 5. Just what I needed (gradient formula)!
|
|
|
|

|
Well, I wrote it 10 years ago
I don't even remember this code anymore.
|
|
|
|

|
Hello Sir
I just want to discussed one problem that is: I created on Dll in VC++ 6.0 as well as in VC++.Net 2003.When i set the date of system like i set year 2075 then the application giving Error.
Plz can you Help me.
Thanks & Regards
hi!!
|
|
|
|

|
I copied the code and ran the program to make a Diagonal Gradient,
I get these error messages
Please can someone tell me where im going wrong!
Tom
|
|
|
|

|
It would be more helpful if you posted the error messages you are getting.
If a wizard fails to cast an enchantment correctly, is that a mis-spelling?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|

|
hahahaha...
"I have only started on this GDI stuff. But it's truly an amazing field. I wish I had started on this area earlier. Now I'll always be behind times. And then I haven't started with GDI+ yet "
thats funny..
Umer Mansoor
|
|
|
|

|
Hi,
I pasted your code in my application, it works nicely. But a small problem-
I have a start button in my dialog. If user clicks on it, a set of controls including buttons, icons will be visible. The problem is that, the contols flicker for a while before they display. This is really bad looking. Even while hiding these controls, the same problem occurs.
Pls help me in this matter.
Thanking you,
Rajani
|
|
|
|

|
Just what I was looking for....
|
|
|
|

|
Thanx for such a nice code.I have two querrie.
1.When I maximise the dialog box, there is a patch of color, of the size of the dialog box when it was opened.If I fully minimise & then maximise, this problem is not there. What to do?
2.When I used the diagonal shading code, I getting an error that m_bitmap is not declared, like that. Where should it be declared.
I am a beginner. So,help me out. Thanx.
Srini
|
|
|
|

|
How can I do this for OpenGL backgrounds?
I have an OpenGL view and I need to put the same background I have alredy used in GDI views. I need a similar way to draw a colored and filled rectangle in an OpenGL view...
Any help? Any sample code? Thanks.
|
|
|
|

|
hey gonzalez,
you can use the following code to draw a radiant background:
//////////////
glBegin(GL_POLYGON);
glColor3f(1.0f,0.0f,0.0f);//bottom color
glVertex3f (-1.0, -1.0, 0.0);
glVertex3f (1.0, -1.0, 0.0);
glColor3f(0.0f,1.0f,0.0f);//top color
glVertex3f (1.0, 1.0, 0.0);
glVertex3f (-1.0, 1.0, 0.0);
glEnd();
///////////////////
this can be put in a function say drawBackground() and the color values can
be set from user input.
dont forget to use the following onsize:
glOrtho(-1.0f,1.0f,-1.0f,1.0f,1.0f,-1.0f);
hope it may help you.
'life is like a ten speed bike,most of us having gears
we ne never use' ... i want
to try those.
|
|
|
|

|
Thank you, it helps...
h.gonzalez
|
|
|
|

|
Thank you very much.It is very useful for me.
But I meet a problem when I pasted your code into my project.
In the Diagonal gradients part,I wanted to make a resizable application.So I pasted the MakeBitmap function called inside OnInitDialog into my project and called it inside OnSize. But when I run it,there was nothing on the background unless I called Inverlitate.
Why?
----------------------
I am from a non-English country,so if you can mail me,i would be very thankful.
|
|
|
|

|
Hi ....
I tried to use your code to create a gradient dialog background, but I have problems when I put static controls. The background of these static controls cannot merge with the dialog background.
What can I do about it? thanks in advance
|
|
|
|

|
Hi Nish,
I'm Park.
I pasted your code into OnEraseBkgnd(), and it works well.
But, I'm using OpenGL functions and libraries, So I have code following.
When I use them, they override gradient background of yours. So your beautiful background is disappearing.
What can I do for that problem??
Please answer me... vulcan31@hanmail.net
--------------------------------------------
PIXELFORMATDESCRIPTOR object,
SetPixelFormat(m_hDC,pixelformat,&pfd);
m_hRC = wglCreateContext(m_hDC);
wglMakeCurrent(m_hDC,m_hRC);
glClearColor(0.0f, 1.0f, 1.0f, 0.0f);
---------------------------------------------
|
|
|
|

|
Excelent! It gave an excelent idea to use a gradient animation affect with some borders of a control i was doing in c#.
congrats.
|
|
|
|
|

|
A really nice effort . The only problem is that the gradient seems to have a banded appearance, which depending on the colours used can make it appear incorrect. If it can be smoother than great!
|
|
|
|

|
thesentinel wrote:
The only problem is that the gradient seems to have a banded appearance
Only in the screen shots. The actual gradient looks much much better.
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|

|
Hey Nish
Great article. Here is something to get your juices flowing . . . . A few *cough* years ago, I wrote a Visual Basic application that solved a simple brain teaser (it was a Governor's School assignment when I was in high school). I got bored with doing just the basic assignment . . . so I added some flare (database access, gradient colored form, and a few other bells and whistles). I have since ported this to C++. Anyway, my idea for you is to extend this article to add a timer and change the gradient scheme based on some random number generator, etc. I still have my code for this somewhere . . . but it might be fun for you to fool around with
Zac
"If I create everything new, why would I want to delete anything?"
|
|
|
|

|
but distinctions are clear (apologies to Peter Gabriel)
These gradients look great by themselves. I added the code to program I'm writing for a customer and the result was attrocious (sp?). Static controls showed their ugly backgrounds (and I meticulously set my statics to the same height everywhere), group boxes lost their nice 3D definition, and the affect was quite jarring when the spaces between listboxes and buttons got filled with color. The "smoothness" of the GUI was lost.
A long time ago, someone told me that space is a really important consideration when designing GUI's. Filling the space with a gradient takes away from the spatiousness of the interface.
Phooey. Gradients looks so beautiful by themselves.
PS - I really like your articles, Nish. Always thought provoking.
Marc
|
|
|
|
|

|
Do we really need more gradients in utilities/applications?
br /> - Goran.
|
|
|
|

|
just wait... in 3 years, "solid" will be the cool UI design feature. people will look back on all those gradients and chuckle.
-c
Cheap oil. It's worth it!
|
|
|
|
|
|

|
Cannot agree. Gradients were kind of fun back in late eighties when you had palettes with only 64 colors made out of 4 bits per component (I'm talking about Amigas, of course), not to mention that we all were some 15 years younger back then. Today, gradients only show bad taste and constant, sad deficiency of new ideas. Sorry...
- Goran.
|
|
|
|
|

|
Hey, I haven't used any gradients in any of my applications yet.
So please don't slam gradients until I have also gotten onto the bandwagon and also have used them.
I am sticking to 3d controls. In ten years time they will be cool again.
|
|
|
|
|

|
Does it exist a more boring color than a flat one? Gradient is the most pleasant background painting ever exist, if you can develop something better, go on budy!
|
|
|
|

|
GDI+ does all this and more for free - you should check it out.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|

|
Without the SDK, you're programming for 1996. Would you like me to send it to you on CD ?
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|

|
Christian Graus wrote:
Without the SDK, you're programming for 1996. Would you like me to send it to you on CD ?
No CG. I have made the required moves here and if all goes well I'll get a copy of VS .NET within two weeks.
In the background I am also trying to coax my company to get an MSDN subscription, now that my attempts to get them to buy VS .NET has totally failed!!!
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|

|
Yes I really love LinearGradientBrush & TextureBrush. They are cool.
|
|
|
|
|

|
Nish, why you still not got a pirate CD with VS.NET? In my country (Russia) I purchased a copy of VS.NET for $2! Mail me about it, this question is interested for me...
Sorry for wrong english.
|
|
|
|

|
Alexander Kourov wrote:
In my country (Russia) I purchased a copy of VS.NET for $2!
You russians are so lucky!
Alexander Kourov wrote:
Sorry for wrong english.
No probs at all
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|

|
Yeah, imagine you are coming to a large serious shop with a lot of bars with pirate CDs. Hundreds beauty CDs with attractive covers for $2 only. And it's absolutely legally and the shop is in a center of a city with two millions of people. There are so much different software, and discs made really highly qualitative. Pirates provide their discs with suitable shells with comments and cracks and additional info ( here's a sample screenshot - not the best pirate shell) - it's almost industry...
Sorry for deviation from topic's theme...
|
|
|
|
|

|
Nishant S wrote:
You russians are so lucky!
Why - because they steal software ? He does not OWN VS.NET.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|

|
Christian Graus wrote:
Why - because they steal software ? He does not OWN VS.NET.
I know CG, I know! Oh well, I won't win this argument, so I won't even argue! But I hope you'll understand that the day I earn money nice and proper I'll go fully legal. Right it's not even worth trying! MS won't lose anything in a way since even otherwise I wouldn't be able to afford any of this stuff!
I dunno about Russia though. I kinda fancied that Russians were a rich people!
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|

|
Nishant S wrote:
MS won't lose anything in a way since even otherwise I wouldn't be able to afford any of this stuff!
Yeah, I know. M$ doesn't lose anything because you would not buy it anyhow, plus they are rich and can afford for people to pirate their software, etc, etc, etc.
Nishant S wrote:
I kinda fancied that Russians were a rich people!
You WHAT ? Have you heard of the Cold War ? Communism ? Stalin ? The Russian economy is in tatters, they are headed back towards being a 3rd world country. The only reason they rose above that is that Stalin sold all their food and let his people starve to pay for industrialisation.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|

|
I think GDI+ is too heavy.
they can render jpg/gif/bmp. but, you can implement jpg/gif/bmp renderer using IPicture interfaces. it needs anything further.
and, GradientFill API can do the same. why have to use those heavy stuffs?
i don't understand.
|
|
|
|

|
To be honest, I've never used IPicture, I needed to write a full paint program and GDI+ was perfect. If IPicture is lighter and does the little you want, then I say go for it
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|

|
Usefull on NT4 and Win95.
For Win98 and Win2k, Microsoft added the GradientFill API.
From MSDN :
The GradientFill function fills rectangle and triangle structures.
BOOL GradientFill(
HDC hdc, PTRIVERTEX pVertex, ULONG dwNumVertex, PVOID pMesh, ULONG dwNumMesh, ULONG dwMode );
|
|
|
|
|

|
Yes - do it as two gradient triangles with the adjacent edges the same colour.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Beginner article that shows how you can create horizontal, vertical and diagonal backgrounds. Also tells you what to watch out for, to avoid flickering when doing complicated drawing.
| Type | Article |
| Licence | CPOL |
| First Posted | 9 Jun 2002 |
| Views | 201,623 |
| Bookmarked | 83 times |
|
|