hi guys.
with this code you can set Ribbon Object Plugin direction (left to right or right to left)
but this code have a problem.
it only work one time for one ribbon
can everybody help me to resolve it?
with this code you can set Ribbon Object Plugin direction (left to right or right to left)
--################################################## farsi style
function farsi_style(a_control)
local current_dialog = Application.GetCurrentDialog();
if current_dialog == "" then
form_type = Page;
else
form_type = DialogEx;
end
local object_type = form_type.GetObjectType(a_control);
if object_type == OBJECT_COMBOBOX then
DLL.CallFunction("user32.dll", "SetWindowLongA", ComboBox.GetProperties(a_control).WindowHandle..", -20, 291844", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif object_type == OBJECT_GRID then
DLL.CallFunction("User32.dll", "SetWindowLongA", Grid.GetProperties(a_control).WindowHandle..", -20, 4194516", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif object_type == OBJECT_PLUGIN then
farsi_ribbon(a_control);
end
end
-- [farsi style] get class name
function GetClassName(a_handle)
local memory = Memory.Allocate(2048);
local class_name;
if memory then
DLL.CallFunction("user32.dll", "GetClassNameA", a_handle..","..memory..",2048", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
class_name = Memory.GetString(memory, -1, "");
Memory.Free(memory);
end
return class_name;
end
-- [farsi style] farsi ribbon
function farsi_ribbon(a_control)
local combo_handle, ribbon_handle = nil;
Page.CreateObject(OBJECT_COMBOBOX, "ribon_combo", {Visible=false});
combo_handle = ComboBox.GetProperties("ribon_combo").WindowHandle;
if combo_handle then
ribbon_handle = tonumber(find_ribbon_handle(combo_handle));
repeat
SetWindowLong(ribbon_handle, -20, GetWindowLong(ribbon_handle, -20)+4194304)
ribbon_handle = tonumber(DLL.CallFunction("user32.dll", "GetWindow", ribbon_handle..","..5, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL));
until ribbon_handle == 0;
Ribbon.Redraw(a_control);
Page.DeleteObject("ribon_combo");
end
end
-- [farsi style] find ribbon handle
function find_ribbon_handle(a_handle)
local handle = tonumber(DLL.CallFunction("user32.dll", "GetWindow", GetParent(a_handle)..","..5, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL));
local result;
if handle then
repeat
if (GetClassName(handle) == "AfxWnd100s") then
result = handle
break
end
handle = tonumber(DLL.CallFunction("user32.dll", "GetWindow", handle..","..2, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL));
until handle == 0
end
return result;
end
-- [farsi style] get parent
function GetParent(a_handle)
return tonumber(DLL.CallFunction("user32.dll", "GetParent", a_handle, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL));
end
-- [farsi style] get window long
function GetWindowLong(a_handle, a_index)
return tonumber(DLL.CallFunction("user32.dll", "GetWindowLongA", a_handle..", "..a_index, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL))
end
-- [farsi style] set window long
function SetWindowLong(a_handle, a_index, a_new_long)
return tonumber(DLL.CallFunction("user32.dll", "SetWindowLongA", a_handle..","..a_index..","..a_new_long, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL))
end
-- put this code to on show event
farsi_style("ribbon_name");
it only work one time for one ribbon
can everybody help me to resolve it?