Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Problem with CButton (shape, size, appearance)

Posted on 1998-12-19
6
Medium Priority
?
552 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

647 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