9.80:Strange behaviour CXTButton::SetIcon |
Post Reply |
Author | |
Uwe Keim
Newbie Joined: 01 November 2004 Location: Germany Status: Offline Points: 29 |
Post Options
Thanks(0)
Posted: 17 October 2005 at 8:08am |
In version 9.80, the implementation of CXTButton::SetIcon has changed. It is internally routed to BOOL CXTPImageManagerIconHandle::CreateIconFromResource(LPCTSTR lpszResourceName, CSize szIcon) which internally has the following code: ... Now I call the CXTButton::SetIcon from within my code and the result is that the main application icon is loaded instead of the icon that is present and even found by the lines above. Let me explain:
Question: could you please comment on this? I do believe this is an error, because in the version prior to 9.7 everything works correctly. Thanks |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello, Thank you, we agree that the problem exists, To fix you can 1. Change resource of IDR_MAINFRAME (Main Icon) from 1 to 128 or patch sources 1. Add third parameter to CreateIconFromResource bGroupResource = TRUE and change line 04: if (hRsrc != NULL && bGroupResource) change line 15: if (CreateIconFromResource(MAKEINTRESOURCE(lpGrpIconDir->idE ntries.nID), szIcon, FALSE))
Thank you, |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Uwe Keim
Newbie Joined: 01 November 2004 Location: Germany Status: Offline Points: 29 |
Post Options
Thanks(0)
|
Thank you, I will try the second approach. BTW: My IDR_MAINFRAME is not 1 but 150. Probably returning the IDR_MAINFRAME (i.e. the lowest icon) when requesting with ID 1 is a Windows default behaviour. |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Ok, Please give me know if it helps.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Uwe Keim
Newbie Joined: 01 November 2004 Location: Germany Status: Offline Points: 29 |
Post Options
Thanks(0)
|
Just tried, still did not work. The reason is that it still passes the "1" from lpGrpIconDir->idEntries[i].nID to the first recursion of the function (instead of my real resource ID). I do not fully understand what the function does, so I'll try it now and see how I can fix it. Maybe you can tell me another option, too, if I find no solution by myself. Thanks |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Another option is to call BOOL CXTButton::SetIcon(CSize size, HICON hIcon, HICON hIconHot/*= NULL*/, BOOL bRedraw/*= TRUE*/) instead of BOOL CXTButton::SetIcon(CSize size, UINT nID, UINT nHotID/*= 0*/, BOOL bRedraw/*= TRUE*/)
so you can load Icon useing AfxGetApp()->LoadIcon(idr) and call first method.
but, fix must work :( Can you attach icon that have problem?
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Uwe Keim
Newbie Joined: 01 November 2004 Location: Germany Status: Offline Points: 29 |
Post Options
Thanks(0)
|
Uwe Keim
Newbie Joined: 01 November 2004 Location: Germany Status: Offline Points: 29 |
Post Options
Thanks(0)
|
I think I found another issue: I now do call SetIcon() as you suggested. Now the icon IS loaded correctly, but since the Icon file contains a 32x32 and a 16x16, I do pass CSize(16,16), but internally you overwrite it again. Namely here: 01: m_pIcon = new CXTPImageManagerIcon(0, size.cx, size.cy);02: m_pIcon->SetIcon(hIcon); Line 01 correctly passes my CSize(16,16), but when entering line 02 the function called there looks like the following: 01: BOOL CXTPImageManagerIcon::SetIcon(CXTPImageManagerIconHandle hIcon) The lines 08 and 09 overwrite it again with CSize (32,32). I think this is an error. Am I right here? Thanks |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
The problem now that LoadIcon loads 32*32 icon instead of 16*16 so CXTPImageManagerIcon::SetIcon works as expected. To load corrrect Icon you can remove 32*32 layout from ico file, or use LoadImage instead: HICON hIcon = (HICON)LoadImage(..,..,IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Uwe Keim
Newbie Joined: 01 November 2004 Location: Germany Status: Offline Points: 29 |
Post Options
Thanks(0)
|
Arrgh! . Now I removed the 32x32 leaving only the 16x16 bitmap in the icon file. The result? Now the 16x16 icon is resized to be 32x32 resulting in a rasterized image, drawn at the wrong position (because too wide and too high). Hmmmmmmm... |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |