Skip to content

Fix and improve CreateIconFromResource(Ex) and LookupIconIdFromDirectory(Ex) documentation - #2242

Open
Dimitriy Ryazantcev (DJm00n) wants to merge 2 commits into
MicrosoftDocs:docsfrom
DJm00n:fix/createiconfromresource-input-format
Open

Fix and improve CreateIconFromResource(Ex) and LookupIconIdFromDirectory(Ex) documentation#2242
Dimitriy Ryazantcev (DJm00n) wants to merge 2 commits into
MicrosoftDocs:docsfrom
DJm00n:fix/createiconfromresource-input-format

Conversation

@DJm00n

Copy link
Copy Markdown
Contributor

CreateIconFromResourceEx:

  • presbits: clarify the parameter accepts a single RT_ICON/RT_CURSOR image, not a
    resource group directory; redirect buffer format details to Remarks
  • fIcon: remove misplaced LOCALHEADER sentence (covered in the DIB format bullet in Remarks)
  • cxDesired/cyDesired: clarify that zero without LR_DEFAULTSIZE uses the size stored in
    presbits without scaling, rather than vaguely "the actual resource size"
  • Flags: remove LR_SHARED — it does not produce sharing or caching for this function
    and makes the handle impossible to destroy; remove from keyword metadata as well
  • Remarks: replace boilerplate sentence with a proper description of the three accepted
    buffer formats (DIB, PNG, ANI/RIFF-ACON); add ANI sizing and fIcon-ignored notes

CreateIconFromResource:

  • presbits: redirect buffer format details to CreateIconFromResourceEx Remarks
  • fIcon: remove misplaced LOCALHEADER sentence
  • Remarks: remove boilerplate sentence; expand the wrapper description to explain the
    LR_DEFAULTSIZE consequence (always default system size) and how to get a specific size
  • Add Examples link

LookupIconIdFromDirectoryEx:

  • cxDesired/cyDesired: document that the SM_* metric is only used when LR_DEFAULTSIZE is
    set; without it, zero returns the first directory entry without size scoring
  • Flags table: add the missing LR_DEFAULTSIZE entry; fix LR_MONOCHROME description
    ("Searches for" rather than "Creates")
  • Add LR_DEFAULTSIZE to keyword metadata

LookupIconIdFromDirectory:

  • Description: clarify that this wrapper passes Flags=0 (not LR_DEFAULTSIZE), so it
    always returns the first directory entry without size scoring

Related: https://devblogs.microsoft.com/oldnewthing/?p=108925

@prmerger-automator

Copy link
Copy Markdown

Dimitriy Ryazantcev (@DJm00n) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. Jim Walker (@jwmsft)

@prmerger-automator

Copy link
Copy Markdown

Dimitriy Ryazantcev (@DJm00n) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. Jim Walker (@jwmsft)

…ory(Ex) documentation

CreateIconFromResourceEx:
- presbits: clarify the parameter accepts a single RT_ICON/RT_CURSOR image, not a
  resource group directory; redirect buffer format details to Remarks
- fIcon: remove misplaced LOCALHEADER sentence (covered in the DIB format bullet in Remarks)
- cxDesired/cyDesired: clarify that zero without LR_DEFAULTSIZE uses the size stored in
  presbits without scaling, rather than vaguely "the actual resource size"
- Flags: remove LR_SHARED — it does not produce sharing or caching for this function
  and makes the handle impossible to destroy; remove from keyword metadata as well
- Remarks: replace boilerplate sentence with a proper description of the three accepted
  buffer formats (DIB, PNG, ANI/RIFF-ACON); add ANI sizing and fIcon-ignored notes

CreateIconFromResource:
- presbits: redirect buffer format details to CreateIconFromResourceEx Remarks
- fIcon: remove misplaced LOCALHEADER sentence
- Remarks: remove boilerplate sentence; expand the wrapper description to explain the
  LR_DEFAULTSIZE consequence (always default system size) and how to get a specific size
- Add Examples link

LookupIconIdFromDirectoryEx:
- Description: replace the size/color-depth summary with the actual scoring algorithm —
  each candidate is scored by its departure from the target width, height, and color
  depth, with the width and height terms doubled when the candidate is undersized and
  the color-depth term always doubled; lowest score wins, ties broken by color depth
  then directory order
- cxDesired/cyDesired: shortened to defer the zero-value behavior to the Flags entry;
  corrected the false claim that zero size without LR_DEFAULTSIZE returns the first
  directory entry — the scoring loop always runs, and at zero size the width/height
  terms drop out for every candidate, so selection falls to color depth alone, only
  degenerating to the first entry when all entries share the same color depth
- Flags table: consolidate the SM-metric substitution detail into the LR_DEFAULTSIZE
  row as its single home; add the missing LR_DEFAULTSIZE entry; fix LR_MONOCHROME
  description ("Searches for" rather than "Creates")
- Add LR_DEFAULTSIZE to keyword metadata

LookupIconIdFromDirectory:
- Description: clarify that this wrapper passes Flags=0 (not LR_DEFAULTSIZE), so size
  does not take part in selection and the result is chosen by color depth as described
  for LookupIconIdFromDirectoryEx, rather than unconditionally "the first entry"
@DJm00n
Dimitriy Ryazantcev (DJm00n) force-pushed the fix/createiconfromresource-input-format branch from 9c88e2b to 354ab67 Compare July 31, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant