Board index » cppbuilder » SetIconSm

SetIconSm


2003-08-09 05:13:49 PM
cppbuilder43
I'm trying to set the little icon (top left on the application window).
(Bor-5.02)
In some applications using TFrameWindow
SetIconSm(GetApplication(), IDI_ICON1);
works, and in some it doesn't.
Any ideas anyone ?
 
 

Re:SetIconSm

I'm using SetIconSm(GetModule(), TResId(IDI_ICON1));
but tried your version and it worked also, so I'm not sure it will help.
Quote

SetIconSm(GetApplication(), IDI_ICON1);

 

Re:SetIconSm

Roger Lindgren wrote:
Quote
I'm using SetIconSm(GetModule(), TResId(IDI_ICON1));
but tried your version and it worked also, so I'm not sure it will help.

>
>SetIconSm(GetApplication(), IDI_ICON1);
>
Thanks for the try Roger, but GetModule() is no better! It's all very
strange!
Georges
 

{smallsort}

Re:SetIconSm

Roger Lindgren wrote:
Quote
well didn't think it would help, but you didn't give much information.
You can try to give a bit more info on how and where you set the icons.
Then maybe someone can help.
Point taken but there's little to add:
Icon is set in the contructor of the TFrameWindow (TWnd::TWndw)
by
SetIconSm(GetApplication(), IDI_ICON1);
As I said, it has worked just so in some previous aplications and I can see
no difference!
Bestwishes and thanks
Georges
 

Re:SetIconSm

The only thing I can think of, is that the proper place to use SetIconSm
should be in SetupWindow() after you called TFrameWindow::SetupWindow();
It can have something to do with creation order, that your SetIconSm
gets overridden.
But I did try in of my bigger apps to move around SetIconSm and SetIcon
(I don't think you need SetIcon just a bad habit, that I use both I
think) and it worked in constructors and applications initmainwindow
after SetMainWindow, and in my SetupWindow of my clientwindow where it
is normally. But I still think that the icon should be set after the
frame is created.
Other than that I can only think of that you don't have the correct
icon, perhaps number of colors and size can matter (But tried a few
different icons now and it worked anyway). You could try to paste in an
icon from an app that do work in text edit mode and try setting that one
instead.
Do you have the icon in the .rc file or do you include an .ico file in
the .rc file, then it could be that Borland C++ 5.02 can't read the icon
format if it has been any additions to that format since 5.02 was
released, but then it should complain about it I guess.
And I'm presuming not working meaning that the standard application icon
is showed.
I do remember having some problems with icons many many years ago, just
don't remember what the problem was. But all new apps I make it works
perfect. And I change the application in runtime also with no problems.
Both with 5.01a and 5.02, and BCB4 with OWL 5.4
Hope it can help, but feels that it should work like you have it already.
 

Re:SetIconSm

Jan Vernimmen wrote:
Quote
What about the following:

//--------------------------

void TMyClass::GetWindowClass( WNDCLASS& WndClass)
{
TWindow::GetWindowClass( WndClass );
WndClass.hIcon = LoadIcon(*GetApplication(),
TResId(IDI_SMALLICON));

} //GetWindowClass

//---------------------

with in the class definition:
.
virtual LPSTR GetClassName ( ){ return "MyWindow"; };
.
.

The function GetWindowClass(...) is called automaticly

Greetings
Jan Vernimmen.
Jan,
Yes, that works, but also Roger's suggestion of moving it to after
TFrameWindow::SetupWindow works also!
So now the problem is solved - thanks to both of you!
Georges