// element that performs the action of another element (linkedItem)
struct H3DlgCustomControlItem : public H3DlgItem
{
public:
H3DlgItem* linkedItem;
//INT32 ProcessMsg(H3Msg* msg) override // this doesn't work either: in "struct H3DlgItem { ... virtual INT32 ProcessMsg(H3Msg* msg); } "
//{
// if (linkedItem)
// return linkedItem->ProcessMsg(msg);
// // return THISCALL_2(int, (UINT)&this->linkedItem->vTable[2], this, &msg);
// return 2; // stop processing the current msg
// // return THISCALL_2(int, (UINT)&this->vTable[2], this, &msg); // call original message process
//};
static int __fastcall CustomProcessMsg(H3DlgCustomControlItem* control, int unused, H3Msg* msg)
{
if (control->linkedItem) // can add some more checks if needed
return THISCALL_2(int, (UINT)&control->linkedItem->vTable[2], control->linkedItem, msg);
return 2; // stop processing the current msg
// return THISCALL_2(int, /*insert_original_address*/, control, &msg); // call original message process
}
// constructor
H3DlgCustomControlItem()
{
DwordAt(&this->vTable[0] +0x8) = (int)H3DlgCustomControlItem::CustomProcessMsg;
}
static H3DlgCustomControlItem* Create(INT32 x, INT32 y, INT32 width, INT32 height, INT32 id, H3DlgItem* linkedControl);
};