?
Solved

Problem with CButton (shape, size, appearance)

Posted on 1998-12-19
6
Medium Priority
?
543 Views
Last Modified: 2013-11-20
Hi,

I'm using a derived class for the CButton object which allows me to change the shape of the push button.  Although I can get the shape to change (an ellipse for example), the grey corners still show on the button. This isn't a problem when in a dialog, because the background is also grey and it blends, but my app uses a green background.

  When creating a CButton derived object inside my application (not CForm view or CRecordView or in a dialog ), the derived class calculates the lighting, etc. and draws the button as the regular CButton class would, except that it draws the button face as any shape desired.  The problem here is that the actual space taken up by the button is still rectangular, which means that ugly grey corners still show on the button (when using ellipse for example).

  I don't want to cover it with rectangular bitmaps, because that will defeat the whole purpose and I would have to match the bitmap corners with my app's background colors, etc...  That would be a pain.  

  When I actually create the CButton derived button, I'm forced to pass a RECT or CRect object, so it appears that this is my road-block, but I don't know how to tackle this problem.  If I could change the actual size that the button itself occupies, I think everything would be fine, but for now, I'm stuck.

 I've tried this with & w/out BS_OWNERDRAW.
 I think dealRect is the real problem here.

m_dealButton.Create("Deal", BS_OWNERDRAW | VISIBLE,
                     dealRect, this, 7);

   Call to derived CButton class with predefined shape.
   Not particularly important, but shown so that it's
   known that it's called after button is created.

m_dealButton.SetVtx(VTX_STRETCHEDCIRCLE);

Does anybody know of a way to get around this problem?  Please let me know if any further explaination, source, link to derived class source on web, picture of problem button, etc.... is needed.

Totally frustrated,

Jon Phillips
0
Comment
Question by:iseverynametaken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1326418
Create a region.  After the button is created,  use SetWindowRgn.  This will cause the button to clip to the region.

Use SetWindowRgn with a NULL region to restore the rectangular shape before setting another region (e.g. changing shape from circle to diamond)

Also be aware that most region creaton functions work in screen coords
0
 

Author Comment

by:iseverynametaken
ID: 1326419
Sorry to keep you waiting,

Thank you for showing me how to go about it.  
It makes sense, but could you be a little more
precise?  I haven't quite got it working yet.
Here's what I've got so far...

[snip]

/* How to go about using screen coordinates? */
CDC* pDC = GetDC();
CRgn bRegion;

m_dealButton.Create("Deal", BS_OWNERDRAW | WS_VISIBLE,
                     dealRect, this, 7);

bRegion.CreateEllipticRgn( dealRect.TopLeft().x,
                           dealRect.TopLeft().y,
                           dealRect.BottomRight().x,
                           dealRect.BottomRight().y );

m_dealButton.SetWindowRgn(bRegion, true);
m_dealButton.SetVtx(VTX_STRETCHEDCIRCLE);
ReleaseDC(pDC);


Again, sorry for the tardiness...

Jon Phillips

0
 

Author Comment

by:iseverynametaken
ID: 1326420
Further explaination desired... (no second contact from expert)
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 8

Expert Comment

by:Answers2000
ID: 1326421
Sorry I didn't see your follow up till now.

I don't have time to debug your program at the moment.  Maybe another expert can add a comment/answer, otherwise I'll be back soon.
0
 
LVL 1

Accepted Solution

by:
dd_b earned 800 total points
ID: 1326422
Form the problem statement it seems that u r trying for irregular shape button. for this instead of using OWNER DRAWN property try extend style.

WS_EX_TRANSPERANT : this style will create transparent window & shows only portion drawn under PAINT ( OnDraw )

for this u have to create your button using CreateEx (...)


Try this

All the Best

dd_b
0
 

Author Comment

by:iseverynametaken
ID: 1326423
Thanks for your post dd_b,

This question was hard to answer, only because I was
using a CButton derived class.  No one has asked to
even take a peek at the source, but this is why I
offered a large number of pts.  I did solve my prob.
already.  I had to modify the source that I used.  I
just added a parameter to the Create function to specify
a background color to blend with the main window's bg
color and made a few other minor adjustments (fully
documenting the changes of course...).  I do thank you
for your time though.  The original expert gave up, I
guess, so the points are yours.
   
    Thanks again for your time,

    Jon Phillips
    jonboy108@hotmail.com


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question