The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Change icon in GETN title bar
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 02/23/2020 :  08:46:26 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

couturier

France
291 Posts

Posted - 02/24/2020 :  02:40:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot Yuki
Go to Top of Page

Castiel

343 Posts

Posted - 02/24/2020 :  7:26:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
**********************************************************
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000