Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gradient Background!

Status
Not open for further replies.

Digno

Programmer
Jun 11, 2000
1
0
0
DO
I've started learning Visual C++ and I've been trying to make a window with a gradient background like the ones in setup applications. Here I provide the relevant code of the creation of the window from CFrameWnd, the code compiles fine but upon execution it doesn't draw the gradient, it only shows the default white background. Can anyone tell me what's wrong, or give me a code snipet that would accomplish the same. Thanks!.<br><br>////////////////////////////////////////////////////////////<br>CAnaColWindow::CAnaColWindow()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create(NULL,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;AnaCol v2.0&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WS_MINIMIZEBOX¦WS_SYSMENU,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CRect(0,0,500,500),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MAKEINTRESOURCE(100));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CDC *hDC = GetDC();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RECT rectFill;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RECT rectClient;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float fStep;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HBRUSH hBrush;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int iOnBand;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetClientRect(&rectClient);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fStep = (float)rectClient.bottom / 256.0f;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (iOnBand = 0; iOnBand &lt; 256; iOnBand++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetRect(&rectFill,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;(int)(iOnBand * fStep),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;rectClient.right+1,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(int)((iOnBand+1) * fStep));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hBrush = CreateSolidBrush(RGB(0, 0, (255 -iOnBand)));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FillRect(*hDC, &rectFill, hBrush);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DeleteObject(hBrush);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ReleaseDC(hDC);<br>}
 
Amol,<br><br>I'd send an email to you or something, but you haven't listed it and the profiles (regretably) do not (as far as I know; if I'm mistaken, I apologize, please let me know) implement an email form. The thing is... about letsdebug.com. I'm sure it's a great site.. but you push it awfully hard in most of your posts. I have not seen you post without referring to it. Please.. I'm a bit worried that people might use this as a first resort rather than a last- you urge the person that if your code doesn't work (it may or may not, I don't know), seek help at letsdebug.com. Let another tek-tips user have a crack at it before he/she sends it off to some foreign site where a team of experienced programmers can take time away from whatever they're doing (I'm sure they all have jobs in addition to the work they do on letsdebug.com) to work on a program that may or may not need their help. Say they get back to the person in a week (I have no idea what kind of speed these people work with); usually, a question does not last that long in tek-tips forums without a good solid answer resulting. And the person who started the thread learns something in addition by writing the code himself/herself. So everybody wins... Let's not create a community of &quot;ask somebody else first, figure it out on your own later&quot; programmers.<br><br>And I know that's not what you're trying to do- you have only the best of intentions, and you're only trying to make people aware of the option of sending your code to letsdebug.com. That's great, really it is- that's why it's on your profile. But that's really about as far as you should push it, I think- have a line (and link) in your profile that says, &quot;if you're at your wits' end, try asking the folks at Let's Debug.com; they're great!&quot; You basically already have that, but you could spice it up a little bit. I think that's a better idea than suggesting to people that if your fix doesn't work, go straight to a website.<br><br>PLEASE don't let this look like a flame. I have nothing against you, and obviously all posts are welcome. This obviously isn't my forum, this is just one user to another; again, if I could have contacted you personally, I would have. Again, Let's Debug.com is great... it's just that suggesting it so strongly in every post you make might be a little dangerous.<br><br>Good luck to all, and happy coding. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence."
 
Hi Liam and everyone reading this ,<br><br>I can understand your concern. Please be sure that i don't want to make this community &quot;ask somebody else first, figure it out on your own later&quot; programmers !!! <br><br>It is very instinctive for a netizen and programmer like me to share the good things that I find on the web. Probably that's why I was little agressive about it.<br><br>Anyway, I will take care from this post :)<br><br>And let's not talk about it anymore... as we have lot of other better things to talk about on this forum.<br><br>Enjoy.......<br><br>-Amol<br><A HREF="mailto:ajakatda@cs.odu.edu">ajakatda@cs.odu.edu</A> <p> <br><a href=mailto: > </a><br><a href= site for Debugging !</a><br>Try this site for debugging...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top