// -------------------- // EditProp // -------------------- // This routine is called when the user clicks the button of a Button or EditButton property. // BOOL WINAPI DLLExport EditProp(LPMV mV, LPEDATA edPtr, UINT nPropID) { #ifndef RUN_ONLY EditAnimationParams eap; eap.m_dwSize = sizeof(EditAnimationParams); eap.m_pWindowTitle = NULL; eap.m_pImageTitles = NULL; eap.m_nImages = edPtr->numFrames; eap.m_pImages = &edPtr->imageFrames[0]; eap.m_dwOptions = PICTEDOPT_CANBETRANSPARENT | PICTEDOPT_NOALPHACHANNEL; eap.m_nMaxImages = 1024; eap.m_nStartIndex = 0; eap.m_dwFixedWidth = 300; eap.m_dwFixedHeight = 100; if ( mV->mvEditAnimation(edPtr, &eap, NULL) ){ LPEDATA pNewPtr = (LPEDATA)mvReAllocEditData(mV, edPtr, sizeof(EDITDATA) + eap.m_nImages * sizeof(WORD) ); if( pNewPtr != NULL ) edPtr = pNewPtr; else return FALSE; edPtr->numFrames = eap.m_nImages; for( int i = 0; i < eap.m_nImages; i++ ) edPtr->imageFrames[i] = eap.m_pImages[i]; mV->mvCallFunction(edPtr, EF_INVALIDATEOBJECT, 0, 0, 0); return TRUE; } #endif // !defined(RUN_ONLY) return FALSE; }
// -------------------- // SelectPopup // -------------------- // One of the option from the menu has been selected, and not a default menu option // automatically handled by CC&C: this routine is then called. // BOOL WINAPI EditObject (mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr) { EditAnimationParams eap; eap.m_dwSize = sizeof(EditAnimationParams); eap.m_pWindowTitle = NULL; eap.m_pImageTitles = NULL; eap.m_nImages = edPtr->numFrames; eap.m_pImages = &edPtr->imageFrames[0]; eap.m_dwOptions = PICTEDOPT_HOTSPOT; eap.m_nMaxImages = 1024; eap.m_nStartIndex = 0; eap.m_dwFixedWidth = 300; eap.m_dwFixedHeight = 100; if ( mV->mvEditAnimation(edPtr, &eap, NULL) ) { LPEDATA pNewPtr = (LPEDATA)mvReAllocEditData(mV, edPtr, sizeof(EDITDATA) + eap.m_nImages * sizeof(WORD) ); if( pNewPtr != NULL ) edPtr = pNewPtr; else return FALSE; edPtr->numFrames = eap.m_nImages; for( int i = 0; i < eap.m_nImages; i++ ) edPtr->imageFrames[i] = eap.m_pImages[i]; mV->mvCallFunction(edPtr, EF_INVALIDATEOBJECT, 0, 0, 0); return TRUE; } return FALSE; }
/* Serialize * This is where you need to "write" data * to SerializedED like a file. Make sure * you can read the data back in the * constructor below! */ bool Serialize(mv *mV, SerializedED *&SED) const { //First, figure out how much space is needed unsigned size = 0; //size += (MyString.length()+1) * sizeof(stdtstring::value_type); //size += sizeof(MyInt); //size += sizeof(MyArray_t::size_type); //size += MyArray.size() * sizeof(MyArray_t::value_type); //Then, ask MMF2 to provide this space for us in the SerializedED { SerializedED *t = (SerializedED *)mvReAllocEditData(mV, SED, sizeof(SerializedED)+size); if(t) //if it worked { SED = t; //Since SED is a pointer passed by reference, //it will update outside this function so that //the calling code keeps a valid pointer to //the SerializedED. } else return false; //could not allocate space } //Now, the crazy-looking part: serialize the data char *p = (char *)(&SED->data); //put the pointer at the beginning of the space MMF2 gave us //Perform the copy: Advance the pointer: //_tcscpy(p, MyString.c_str()); p += (MyString.length()+1) * sizeof(stdtstring::value_type); //memcpy(p, &MyInt, sizeof(MyInt)); p += sizeof(MyInt); //MyArray_t::size_type MyArray_size = MyArray.size(); //memcpy(p, &MyArray_size, sizeof(MyArray_size)); p += sizeof(MyArray_size); //for(MyArray_t::size_type i = 0; i < MyArray_size; ++i) //{ //memcpy(p, &MyArray[i], sizeof(MyArray_t::value_type)); p += sizeof(MyArray_t::value_type); //} //If you get tired of retyping the size stuff from above, you can always store //the sizes in variables or make macros for them. //Done! return true; //return false in the event of an error }