User Activity

Because in this function it uses memory allocation, I want to set memory parameters static not dynamic
when I press an external interrupt button, I want to switch to static IP, press again want to switch to DHCP, how can I get this? because in CubeMX it just defines once for LWIP_DHCP macro and how can I use this for static IP or vice versa ?