Print Page | Close Window

Problem getting themed buttons to look correct

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=4914
Printed Date: 11 November 2025 at 7:34am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Problem getting themed buttons to look correct
Posted By: Enclaved Shadow
Subject: Problem getting themed buttons to look correct
Date 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?



Replies:
Posted By: Oleg
Date 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


Posted By: Enclaved Shadow
Date 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);



Posted By: Barto
Date Posted: 30 August 2006 at 5:13am
m_wScanImport.SetXButtonStyle(BS_XT_WINXP_COMPAT);
worked for me.


Posted By: Oleg
Date 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


Posted By: Enclaved Shadow
Date 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?


Posted By: Enclaved Shadow
Date 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);



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net