EXAMPLE.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 /* File EXAMPLE.C DLL template to create an external modeler */
00025 
00026 /* This trivial example can serve as a template for building external */
00027 /* modelers. It shows the Entry point called by the                   */
00028 /* Modeler and the include files that define the accessible           */
00029 /* data structures of the modeler and defines "Function callbacks" to */
00030 /* functions in the modeler. Other examples will show the use of the  */
00031 /* structures                                                         */
00032 
00033 /* include any other C library header files needed here               */
00034 #include <windows.h>
00035 
00036 /* include the definitions of the Data structures                     */
00037 #include "struct.h"
00038 
00039 /* include defines for function names and global variables            */
00040 #include "dstruct.h"
00041 
00042 /* include external modeler defines eg. Dialog Box ID's               */
00043 #include "example.h"
00044 
00045 /* Definition needed for compilation on MIPS machines                 */
00046 #if __X__MIPS__
00047 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00048 #endif
00049 
00050 static BOOL CALLBACK ExampleDlgProc(HWND hwnd, UINT msg,
00051                                  WPARAM wparam, LPARAM lparam);
00052 
00053 static HWND      hParent;
00054 static HINSTANCE hThisInstance;
00055 
00056 
00057 /* Main Entry point, called as Process attaches and detached          */
00058 /* remove debug MessageBox statement as required                      */
00059 #if __WATCOMC__
00060 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00061 #else
00062 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00063 #endif
00064   switch (dwReason) {
00065     case DLL_PROCESS_ATTACH: {
00066       hThisInstance=hDLL;
00067 #if __X__MIPS__
00068       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00069 #endif
00070       MessageBox ( GetFocus(),
00071                   (LPCTSTR) "Process attaching",
00072                   (LPCTSTR) " ",
00073                   MB_OK | MB_SYSTEMMODAL);
00074       break;
00075     }
00076     case DLL_PROCESS_DETACH:
00077 #if __X__MIPS__
00078       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00079 #endif
00080       MessageBox ( GetFocus(),
00081                   (LPCTSTR) "Process detaching",
00082                   (LPCTSTR) "",
00083                   MB_OK | MB_SYSTEMMODAL );
00084       break;
00085   }
00086   return TRUE;
00087 }
00088 
00089 #if __SC__
00090 #pragma startaddress(DllMain)
00091 #endif
00092 
00093 /* Function Called From the modeler                                  */
00094 
00095 BOOL _Xmodeler
00096  /* parameters                                                        */
00097  ( HWND parent_window,     /* parent window of caller                 */
00098    HWND info_window,       /* send WM_SETTEXT  see StatusBar class    */
00099    X__STRUCTURE *lpevi    /* pointer to database structure           */
00100  ){
00101 
00102 
00103  /* assign a static global variable that is used in DEFINE's for      */
00104  /* calls to functions and access to global variables                 */
00105  /* this name must NOT be changed lpEVI is typed in DSTRUCT.H         */
00106 
00107  lpEVI=lpevi;
00108 
00109  /* This is where the Modeler action takes place                      */
00110  /* can be almost anything required                                   */
00111  if(DialogBox(hThisInstance,MAKEINTRESOURCE(DLG_EXAMPLE),GetFocus(),
00112            (DLGPROC)ExampleDlgProc) != OK)return FALSE;
00113  /* end of action                                                     */
00114 
00115  /* return TRUE if functions are successful FALSE otherwise           */
00116  return TRUE;
00117 }
00118 
00119 
00120 /* this is a very trivial Dialog Box that just basically just has     */
00121 /* a cancel button. It is NOT a required part of an external modeler  */
00122 
00123 static BOOL CALLBACK ExampleDlgProc(HWND hwnd, UINT msg,
00124                                     WPARAM wparam, LPARAM lparam){
00125  int i;
00126  BOOL err;
00127  switch( msg ) {
00128    case WM_INITDIALOG:
00129      return (TRUE);
00130    case WM_COMMAND:
00131       switch(LOWORD(wparam)){
00132         case DLG_EXAMPLE_CANCEL:
00133           EndDialog(hwnd,FAIL);
00134           return(TRUE);
00135         case DLG_EXAMPLE_OK:
00136           EndDialog(hwnd,OK);
00137           return(TRUE);
00138         default:
00139           break;
00140       }
00141       break;
00142     default: break;
00143  }
00144  return(FALSE);
00145 }
00146 

Generated on Sun Apr 27 14:20:10 2014 for OpenFX by  doxygen 1.5.6