Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/WinAPI    [ Add a report in this area ]  
Report #:  101000   Status: Open
Winapi.CommCtrl wrappers to comctl32 functions incorrectly implemented
Project:  Delphi Build #:  16.0.4316.44803
Version:    16.2 Submitted By:   David Heffernan
Report Type:  Minor failure / Design problem Date Reported:  11/14/2011 5:10:43 AM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   288795
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Winapi.CommCtrl wrappers to comctl32 functions incorrectly implemented
Steps to Reproduce:
The following functions in Winapi.CommCtrl use GetProcAddress to load the entry point from comctl32:

ImageList_ReadEx
ImageList_WriteEx
HIMAGELIST_QueryInterface
SetWindowSubclass
GetWindowSubclass
RemoveWindowSubclass
DefSubclassProc
LoadIconMetric
LoadIconWithScaleDown
DrawShadowText
DrawScrollArrow

The implementation calls GetProcAddress passing ComCtl32DLL as the module handle. ComCtl32DLL equals 0 unless it happens that InitComCtl has alread been called. This may well not be the case.

The very simple resolution is to add a call to InitComCtl to the implementation each of the above functions. An example of what I mean can be found with TaskDialogIndirect and TaskDialog which do this correctly.

As an aside ComCtl32DLL is incorrectly declared to be THandle.  That's simply wrong.  A THandle is something that can be passed to CloseHandle.  A module handle cannot.  ComCtl32DLL should be declared to be HMODULE.
Workarounds
Call GetProcAddress yourself to obtain these function pointers.
Attachment
None
Comments

None

Server Response from: ETNACODE01