Автор: Zloy_Gelud
Дата сообщения: 24.05.2013 14:59
PAVELNEXT
[more=Код]
Код: MENUITEMINFO = MemoryEx.DefineStruct{UINT('Size');UINT('Mask');UINT('Type');UINT('State');
UINT('ID');INT('SubMenu');INT('BmpChecked'); INT('BmpUnchecked');
UINT('ItemData');INT('TypeData');INT('CCH');INT('BmpItem');
};
Menu_GetItemInfo = function (hMenu, nItem)
local tInfo = MENUITEMINFO:New();
tInfo.Size = MemoryEx.StructSize(MENUITEMINFO);
tInfo.Mask = 0x0000003F;
DLL.CallFunction("User32.dll", "GetMenuItemInfoA", hMenu..","..nItem..",1,"..tInfo:GetPointer(), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
return tInfo;
end
Menu_GetItemStateEx = function (hMenu, nItem)
local tInfo = Menu_GetItemInfo(hMenu, nItem);
local nRet = tInfo.State;
tInfo:Free();
return nRet;
end
Menu_SetItemInfo = function (hMenu, nItem, tInfo)
DLL.CallFunction("User32.dll", "SetMenuItemInfoA", hMenu..","..nItem..",1,"..tInfo:GetPointer(), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
end
Menu_SetItemState = function (hMenu, nItem, nState, bState)
if (bState == nil) then bState = true; else bState = false; end
local nFlag = Menu_GetItemStateEx(hMenu, nItem);
if bState then
nState = Bitwise.Or(nFlag, nState);
else
nState = Bitwise.And(nFlag, Bitwise.Not(nState));
end
local tInfo = MENUITEMINFO:New();
tInfo.Size = 48;
tInfo.Mask = 1;
tInfo.State = nState;
Menu_SetItemInfo(hMenu, nItem, tInfo);
tInfo:Free();
end
Menu_SetItemDisabled = function (hMenu, nItem, bState)
Menu_SetItemState(hMenu, nItem, 3, bState);
end
Menu_DrawMenuBar = function (hWnd)
DLL.CallFunction("User32.dll", "DrawMenuBar", hWnd, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
end
--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--Test
File.Run(_SystemFolder.."\\calc.exe", "", _SystemFolder, SW_SHOWNORMAL, false);
local hWnd
repeat
hWnd = tonumber(DLL.CallFunction("user32.dll", "FindWindowA", "\"SciCalc\",0", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
until (hWnd ~= 0);
local hMenu = tonumber(DLL.CallFunction("User32.dll", "GetMenu", hWnd, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
Menu_SetItemDisabled(hMenu, 0);
Menu_SetItemDisabled(hMenu, 1);
Menu_SetItemDisabled(hMenu, 2);
Menu_DrawMenuBar(hMenu);