Author |
Topic  |
|
couturier
France
291 Posts |
Posted - 02/23/2020 : 08:46:26 AM
|
Origin Ver. and Service Release (Select Help-->About Origin): 2020 Operating System:2020
I've changed the icon in a GETN title bar and it looks nice 
HWND hh = GetWindow(OGW_DB_ACTIVE_DLG);
Window wnd(hh);
HICON hic = LoadImage( NULL, strico, IMAGE_ICON, 16, 16, LR_LOADFROMFILE );
wnd.SetIcon(hic, false);
In LoadImage help, it is said: When you are finished using a bitmap, cursor, or icon you loaded without specifying the LR_SHARED flag, you can release its associated memory by calling one of the functions in the following table.
The system automatically deletes these resources when the process that created them terminates; however, calling the appropriate function saves memory and decreases the size of the process's working set.
Should I take care on destroying that icon ? If so, how can I do that ? Similar to GETNE_ON_INIT, is there an event just before GETN is closed, where I could retrieve icon handle and call DestroyIcon( HICON hIcon ) ?
|
|
yuki_wu
896 Posts |
Posted - 02/23/2020 : 10:25:02 PM
|
Hi couturier,
We could use this function directly:
HICON set_window_icon_from_file(HWND hWnd, LPCSTR szIconPath); Regards, Yuki OriginLab
|
Edited by - yuki_wu on 02/23/2020 10:25:17 PM |
 |
|
couturier
France
291 Posts |
Posted - 02/24/2020 : 02:40:45 AM
|
Thanks a lot Yuki |
 |
|
Castiel
343 Posts |
Posted - 02/24/2020 : 7:26:49 PM
|
quote: Originally posted by couturier
Origin Ver. and Service Release (Select Help-->About Origin): 2020 Operating System:2020
I've changed the icon in a GETN title bar and it looks nice 
HWND hh = GetWindow(OGW_DB_ACTIVE_DLG);
Window wnd(hh);
HICON hic = LoadImage( NULL, strico, IMAGE_ICON, 16, 16, LR_LOADFROMFILE );
wnd.SetIcon(hic, false);
In LoadImage help, it is said: When you are finished using a bitmap, cursor, or icon you loaded without specifying the LR_SHARED flag, you can release its associated memory by calling one of the functions in the following table.
The system automatically deletes these resources when the process that created them terminates; however, calling the appropriate function saves memory and decreases the size of the process's working set.
Should I take care on destroying that icon ? If so, how can I do that ? Similar to GETNE_ON_INIT, is there an event just before GETN is closed, where I could retrieve icon handle and call DestroyIcon( HICON hIcon ) ?
To destroy/release/close some object, automatically, a common way is using a class object.
In the following example, DestroyIcon() is called automatically when foo() ends.
class A
{
public:
A(LPCSTR lp) { m_h = LoadImage(...); }
~A() { DestroyIcon(m_h); }
HICON get() { return m_h; }
private:
HICON m_h;
};
void foo()
{
A a(...);
HICON h = a.get();
// blablabla
return;
}
&&&&&&&&&
&&&
&&
& _____ ___________
II__|[] | | I I |
| |_|_ I I _|
< OO----OOO OO---OO
**********************************************************
|
 |
|
|
Topic  |
|
|
|