Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Problem getting themed buttons to look correct
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem getting themed buttons to look correct

 Post Reply Post Reply
Author
Message
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Topic: Problem getting themed buttons to look correct
    Posted: 29 August 2006 at 10:45am
I have a dialog with a bunch of buttons on it.  Two of the buttons have member variables.  I cannot seem to get these two buttons to look the same as the other buttons that do not have member variables.
 
Here is a small snapshot of the buttons in question:
 
The button that is highlighted in orage and button with the bitmap (rightmost second row) are the two buttons with CXTButton member vars.
 
I have the following code in the dialog's OnInit() method:

XTThemeManager()->SetTheme(xtThemeOffice2003);

m_obtnCalendar.SetXButtonStyle(BS_XT_SEMIFLAT | BS_XT_WINXP_COMPAT);

m_obtnQuote.SetXButtonStyle(BS_XT_SEMIFLAT | BS_XT_WINXP_COMPAT);

 
Not too sure what's going on here.  I've tried several combinations of setting the individual button's theme, using different themes and I can't get them to look correct.  Any clues to what I am doing wrong?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2006 at 10:59am
Hi,
 
If you want them look like standard just use standard CButton class instead CXTButton...
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2006 at 3:05pm
I made them regular CButton's and that solved part of the problem.  The other problem is that I want to use a bitmap on one of the buttons.  In order to do that I need to set the OwnerDraw property.
 
Owner Draw TRUE:
 
Owner Draw FALSE:
 
What I'm looking for is the combination of the two ... where the button still has the XP theme and the bitmap on top of it.  I have tried using CButton and CBitmapButton member vars and get the same result with both.  With the CBitmapButton I am just using the following one liner in the OnInit():

m_obtnCalendar.LoadBitmaps(IDB_CALENDAR_BITMAP);

Back to Top
Barto View Drop Down
Groupie
Groupie


Joined: 27 February 2005
Location: Germany
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote Barto Quote  Post ReplyReply Direct Link To This Post Posted: 30 August 2006 at 5:13am
m_wScanImport.SetXButtonStyle(BS_XT_WINXP_COMPAT);
worked for me.
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 30 August 2006 at 8:42am
Hi,
 
Yes m_wScanImport.SetXButtonStyle(BS_XT_WINXP_COMPAT) have to work...
Also if you want standard CButton with bitmap check CButton::SetBitmap method.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2006 at 11:12am
I got a little side tracked last week but am back to this again ... so I  swaped the CButton back in, changed the owner draw property to FALSE,  and changed the init code to the following:

HBITMAP hb = ::LoadBitmap(GetModuleHandle(_T("name.dll")), MAKEINTRESOURCE(IDB_CALENDAR_BITMAP));

m_obtnCalendar.SetBitmap(hb);

Now the output looks like:
The button is there and the bitmap is being displayed but themes are once again not working with that button.  Is there something I'm missing?
Back to Top
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2006 at 11:57am
Finally fixed the problem myself.  I had to change the CButton back to a CXButton and added the following member variables:
 
HMODULE m_module;
HBITMAP m_hbitmap;
CBitmap* m_opBitmap;
CImageList m_oImageList;
then modified changed some code in the OnInit method to look like the following:
 
XTThemeManager()->SetTheme(xtThemeOffice2003);
m_module = GetModuleHandle(_T("dllName.dll"));
m_hbitmap = ::LoadBitmap(m_module, MAKEINTRESOURCE(IDB_BITMAP));
m_oImageList.Create(16, 15, ILC_COLOR16, 1, 1);
m_opBitmap = CBitmap::FromHandle(m_hbitmap);
m_oImageList.Add(m_opBitmap, RGB(0, 255, 0));
m_obtnCalendar.SetIcon(CSize(16, 15), m_oImageList.ExtractIcon(0));
m_obtnCalendar.SetXButtonStyle(BS_XT_WINXP_COMPAT);
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.061 seconds.