agrillage
asked on
changing background colour
I want to change details from a window class before it is created, such as background colour of the window. It seems I can only get a pointer to the class name (a string). I am currently using this code
CRect rect;
GetClientRect( rect );
pDC->FillSolidRect( rect, RGB( 0, 0xbb, 0 ) );
in the OnDraw function but this is highly inefficient. How can I do better?
Also, a trivial but annoying thing (not worth points but bugging me all the same) I have edited the document icon in my application but windows continues to use the old one on my system (I have not tried distributing the app yet). I have tried importing the .reg file but still no good. I guess this must be a windows thing because the application definitely recognises the new icon.
CRect rect;
GetClientRect( rect );
pDC->FillSolidRect( rect, RGB( 0, 0xbb, 0 ) );
in the OnDraw function but this is highly inefficient. How can I do better?
Also, a trivial but annoying thing (not worth points but bugging me all the same) I have edited the document icon in my application but windows continues to use the old one on my system (I have not tried distributing the app yet). I have tried importing the .reg file but still no good. I guess this must be a windows thing because the application definitely recognises the new icon.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The icon is associated with the document ( the only document ) class for the application. It is the default from the app wizard. All I did was edit it.
I am trying the SetClassLong Function in the meantime.
Thanks
I am trying the SetClassLong Function in the meantime.
Thanks
For the icon problem, I think you have edited the 32x32 version of the icon, but not the 16x16 version, which is used to display the document icon in MFC.
WHen you edit the icon in Visual C++, you have a combobox where you can choose between the 32x32 version and the 16x16 version to edit.
WHen you edit the icon in Visual C++, you have a combobox where you can choose between the 32x32 version and the 16x16 version to edit.
ASKER
Points are for the background colour. I edited both icons and niether comes through correctly. I think it must be a bug but I would be interested to hear any more thoughts you might have.
Which version of Visual C++ do you use ?
Is your MFC application SDI or MDI ?
Try to open your application .EXE with Visual C++
using "Open as : resource" and tell me if the icon
in the .EXE appears as you modified it or as the default.
Is your MFC application SDI or MDI ?
Try to open your application .EXE with Visual C++
using "Open as : resource" and tell me if the icon
in the .EXE appears as you modified it or as the default.
ASKER
Visual C++ 5.0 Enterprise
SDI
The icons appear as I want, correctly modified.
SDI
The icons appear as I want, correctly modified.
After the class is created, you can use SetClassLong to change the properties of a class. The change will only affect new windows, not existing ones.
Since you use MFC, you might want to use AfxRegisterWndClass to get exactly the class you want.