I wonder why you create the OBJECT the way you are doing it. Just simply go this way:
- write a function which creates and returns an OBJECT: OBJECT* createOBJECT ()
- an OBJECT has an own PANEL element. So, createOBJECT would need to dynamically create a PANEL by pan_create
- use parameters in createOBJECT to create and fill the PANEL
From now on you can simply create OBJECTs like OBJECT* testObject = createOBJEC(); and everything gets done automatically.