The correct way for message handling is:
WM_DRAWITEM:
if Message.WParam = 0 then
with PDrawItemStruct(Message.LParam)^ do
if (CtlType = ODT_MENU) and Assigned(Menu) then
begin
{ here is main menu drawing }
end;
But for this solution forms.pas must be modified.
The workaround itself:
When implementing owner-drawn status panels the following code
can be used in form unit containing custom-drawn status bar:
TForm1=class(TForm)
...
protected
procedure WndProc(var Message: TMessage); override;
...
procedure TForm1.WndProc(var Message: TMessage);
begin
if (Message.Msg = wm_DrawItem) and
(Message.WParam <> 0) and
(Message.LParam <> 0) then
with PDrawItemStruct(Message.LParam)^ do
if (CtlType = ODT_MENU) then
CtlType := 0;
inherited;
end;
Parameter CtlType is not used when Windows notifies with
WM_DRAWITEM for status panels, but under WinNT4.0 this
parameter is equal to ODT_MENU (1) and menu item is drawn
inside of status panel rectangle.
Note from checker:
On my NT 4.0 (SP6) system, WParam was 0, not ODT_MENU. I suppose the version of COMCTL32.DLL probably determines whether this bug appears.
|