Win32: Remove Windows 9x specific code, part 2.

git-svn-id: trunk@50770 -
This commit is contained in:
bart 2015-12-13 16:41:31 +00:00
parent 157c7c738e
commit 31d0fe9579

View File

@ -125,8 +125,6 @@ const
tmPopupSubmenuNormal
);
const
OldMenuWin95 = False; // Indicator for Windows 95 menus, or above(MENUITEMINFO size, MIIM_TYPE)
type
TCaptionFlags = (cfBold, cfUnderline);
@ -167,10 +165,7 @@ var
begin
Result := MakeLResult(0, MNC_IGNORE);
MenuItemIndex := -1;
if OldMenuWin95 then
ItemInfo.cbSize := W95_MENUITEMINFO_SIZE
else
ItemInfo.cbSize := sizeof(TMenuItemInfo);
ItemInfo.cbSize := sizeof(TMenuItemInfo);
ItemInfo.fMask := MIIM_DATA;
if not GetMenuItemInfoW(AMenuHandle, 0, true, @ItemInfo) then Exit;
@ -1205,23 +1200,13 @@ var
MenuInfo: MENUITEMINFO; // TMenuItemInfoA and TMenuItemInfoW have same size and same structure type
begin
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
if OldMenuWin95 then
begin
MenuInfo.cbSize := W95_MENUITEMINFO_SIZE;
MenuInfo.fMask := MIIM_TYPE; // caption not retrieved (dwTypeData = nil)
end
else
begin
MenuInfo.cbSize := sizeof(TMenuItemInfo);
MenuInfo.fMask := MIIM_FTYPE; // don't retrieve caption (MIIM_STRING not included)
end;
MenuInfo.cbSize := sizeof(TMenuItemInfo);
MenuInfo.fMask := MIIM_FTYPE; // don't retrieve caption (MIIM_STRING not included)
GetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
if Value then
MenuInfo.fType := MenuInfo.fType or Flag
else
MenuInfo.fType := MenuInfo.fType and (not Flag);
if OldMenuWin95 then // MIIM_TYPE = MIIM_FTYPE + MIIM_STRING for Windows 95
MenuInfo.dwTypeData := PChar(UTF8ToAnsi(CompleteMenuItemCaption(AMenuItem, #9))); // Windows 95 only Ansi
Result := SetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
TriggerFormUpdate(AMenuItem);
end;
@ -1238,10 +1223,7 @@ var
MenuInfo: MENUITEMINFO; // TMenuItemInfoA and TMenuItemInfoW have same size and same structure type
begin
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
if OldMenuWin95 then
MenuInfo.cbSize := W95_MENUITEMINFO_SIZE
else
MenuInfo.cbSize := sizeof(TMenuItemInfo);
MenuInfo.cbSize := sizeof(TMenuItemInfo);
MenuInfo.fMask := MIIM_TYPE; //MIIM_FTYPE not work here please use only MIIM_TYPE, caption not retrieved (dwTypeData = nil)
GetMenuItemInfoW(Menu, 0, True, @MenuInfo);
if Value then
@ -1265,16 +1247,8 @@ begin
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
with MenuInfo do
begin
if OldMenuWin95 then
begin
cbSize := W95_MENUITEMINFO_SIZE;
fMask := MIIM_TYPE or MIIM_STATE; // current caption not retrieved (dwTypeData = nil)
end
else
begin
cbSize := sizeof(TMenuItemInfo);
fMask := MIIM_FTYPE or MIIM_STATE; // don't retrieve current caption
end;
cbSize := sizeof(TMenuItemInfo);
fMask := MIIM_FTYPE or MIIM_STATE; // don't retrieve current caption
end;
GetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
with MenuInfo do
@ -1282,10 +1256,7 @@ begin
// change enabled too since we can change from '-' to normal caption and vice versa
if ACaption <> cLineCaption then
begin
if OldMenuWin95 then
fType := fType or MFT_STRING
else
fType := fType or MIIM_STRING;
fType := fType or MIIM_STRING;
fType := fType and not (MFT_SEPARATOR or MFT_OWNERDRAW);
fState := EnabledToStateFlag[AMenuItem.Enabled];
if AMenuItem.Checked then
@ -1295,15 +1266,11 @@ begin
dwTypeData := PChar(WideBuffer); // PWideChar forced to PChar
cch := length(WideBuffer);
if not OldMenuWin95 then
fMask := fMask or MIIM_STRING; // caption updated too
fMask := fMask or MIIM_STRING; // caption updated too
end
else
begin
if OldMenuWin95 then
fType := fType and not (MFT_STRING)
else
fType := fType and not (MIIM_STRING);
fType := fType and not (MIIM_STRING);
fType := (fType or MFT_SEPARATOR) and not (MFT_OWNERDRAW);
fState := MFS_DISABLED;
end;
@ -1313,10 +1280,7 @@ begin
// MIIM_BITMAP is needed to request new measure item call
with MenuInfo do
begin
if OldMenuWin95 then
fMask := MFT_BITMAP
else
fMask := MIIM_BITMAP;
fMask := MIIM_BITMAP;
dwTypeData := nil;
end;
SetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
@ -1324,17 +1288,8 @@ begin
// set owner drawn
with MenuInfo do
begin
if OldMenuWin95 then
begin
fMask := MIIM_TYPE;
fType := (fType or MFT_OWNERDRAW) and not (MFT_STRING or MFT_SEPARATOR);
MenuInfo.dwTypeData := PChar(CompleteMenuItemStringCaption(AMenuItem, ACaption, #9)); // Windows 95 only Ansi
end
else
begin
fMask := MIIM_FTYPE; // don't set caption
fType := (fType or MFT_OWNERDRAW) and not (MIIM_STRING or MFT_SEPARATOR);
end;
fMask := MIIM_FTYPE; // don't set caption
fType := (fType or MFT_OWNERDRAW) and not (MIIM_STRING or MFT_SEPARATOR);
end;
SetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
TriggerFormUpdate(AMenuItem);
@ -1351,10 +1306,7 @@ var
begin
ParentMenuHandle := AMenuItem.Parent.Handle;
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
if OldMenuWin95 then
MenuInfo.cbSize := W95_MENUITEMINFO_SIZE
else
MenuInfo.cbSize := sizeof(TMenuItemInfo);
MenuInfo.cbSize := sizeof(TMenuItemInfo);
// Following part fixes the case when an item is added in runtime
// but the parent item has not defined the submenu flag (hSubmenu=0)
@ -1385,10 +1337,7 @@ begin
fstate := MFS_GRAYED;
if AMenuItem.Checked then
fState := fState or MFS_CHECKED;
if OldMenuWin95 then
fMask := MIIM_ID or MIIM_DATA or MIIM_STATE or MIIM_TYPE
else
fMask := MIIM_ID or MIIM_DATA or MIIM_STATE or MIIM_FTYPE or MIIM_STRING;
fMask := MIIM_ID or MIIM_DATA or MIIM_STATE or MIIM_FTYPE or MIIM_STRING;
wID := AMenuItem.Command; {value may only be 16 bit wide!}
dwItemData := PtrInt(AMenuItem);
if (AMenuItem.Count > 0) then
@ -1449,10 +1398,7 @@ begin
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
with MenuInfo do
begin
if OldMenuWin95 then
cbSize := W95_MENUITEMINFO_SIZE
else
cbSize := sizeof(TMenuItemInfo);
cbSize := sizeof(TMenuItemInfo);
fMask := MIIM_SUBMENU;
end;
GetMenuItemInfoW(ParentOfParentHandle, AMenuItem.Parent.Command, False, @MenuInfo);