#15023 closed enhancement (fixed)

New wxIcon::CreateFromHICON() method

Reported by: troelsk Owned by: vadz
Priority: normal Milestone:
Component: wxMSW Version: stable-latest
Keywords: wxIcon Cc:
Blocked By: Blocking:
Patch: yes

Description

It is rather unexpected that SetHICON() leaves the wxIcon width and height members at zero.

Attachments (2)

hicon.patch download (1.4 KB) - added by troelsk 20 months ago.
hicon.2.patch download (2.2 KB) - added by troelsk 20 months ago.
CreateFromHICON

Download all attachments as: .zip

Change History (7)

Changed 20 months ago by troelsk

comment:1 Changed 20 months ago by vadz

  • Resolution set to wontfix
  • Status changed from new to closed

I don't think it's a good idea. Calling SetHICON() should really be restricted to wxMSW code itself which knows what it is doing. The user code shouldn't call it and if we want to provide a way to wrap an existing HICON, we should do it properly, i.e. add a new public CreateFromHICON() or static New(HICON) method.

Applying this patch would just make SetHICON() inconsistent with SetHBITMAP() and other similar methods.

comment:2 Changed 20 months ago by troelsk

  • Resolution wontfix deleted
  • Status changed from closed to reopened

CreateFromHICON() sounds good. From the user perspective SetHICON() appears just broken. Patch added.

Changed 20 months ago by troelsk

CreateFromHICON

comment:3 Changed 20 months ago by troelsk

  • Summary changed from wxIcon::SetHICON() enhancement to New wxIcon::CreateFromHICON() method

comment:4 Changed 20 months ago by vadz

  • Owner set to vadz
  • Status changed from reopened to accepted

Thanks, will apply soon after changing the code to avoid calling wxGetHiconSize() twice when loading icons.

comment:5 Changed 20 months ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [73489]) Add wxIcon::CreateFromHICON() to wxMSW.

Provide a public method properly assigning an HICON to wxIcon, instead of
asking people to call SetHICON() and SetSize().

Closes #15023.

Note: See TracTickets for help on using tickets.