/**************/ /* mdialog.h */ /**************/ #ifndef MDIALOG_H #define MDIALOG_H #include "incwin.h" #ifndef CALLBACK_E #define CALLBACK_E CALLBACK //_export /* Nyt .DEF tiedosto ei tarvitse EXPORT*/ #endif #ifdef __WIN32__ # define mPLATFORM "(Win32S)" #else # define mPLATFORM "(Win 3.1)" #endif #ifdef GetDialogCreateLParam #undef GetDialogCreateLParam(hWnd) #endif #ifdef __cplusplus extern "C" { #endif typedef struct { int Info; /* = 1 jos pitää muuttaa dialogin tietoja */ HGLOBAL hgl; /* Dialogin muistialueen kahva */ void FAR *Tmpl; /* Lukittu kahva */ int Del; /* Täytyykö muistialue tuhota */ } tDlgInfo; typedef struct { WNDCLASS wc; CREATESTRUCT cs; tDlgInfo *Dlg; } tCreWndSt; typedef void (*tWNDCLASSHandler)(tCreWndSt *); //typedef BOOL CALLBACK_E (*PDIALOGPROC)(HWND,UINT,WPARAM,LPARAM); typedef BOOL (CALLBACK_E *PDIALOGPROC)(HWND,UINT,WPARAM,LPARAM); typedef struct { int id; char *version; } tVersionInfo; void UnlockDialogInfo(tDlgInfo *Dlg); void DeleteDialogInfo(tDlgInfo *Dlg); LPARAM GetDialogCreateLParam(HWND hWnd); void DialogSethInstance(HINSTANCE hInstance); HINSTANCE DialogGethInstance(HWND hWnd); HWND DoModelessDialogParamWC( HWND, const char *, PDIALOGPROC,LPARAM,tWNDCLASSHandler); HWND DoMultiModelessDialogParamWC(HWND, const char *, PDIALOGPROC,LPARAM,tWNDCLASSHandler); HWND DoModalDialogParamWC( HWND, const char *, PDIALOGPROC,LPARAM,tWNDCLASSHandler); void FreeAllModeless(void); int DestroyDialog(HWND, int); int KillDialog(HWND,int); int IsModelessMessage(MSG *); void *DialogLock(HWND); void *DialogAlloc(HWND,unsigned); BOOL DialogUnlock(HWND); BOOL DialogFree(HWND hWnd); BOOL CALLBACK_E MDialogAbout(HWND hDlg,UINT message, WPARAM wParam,LPARAM lParam); int mRegisterWndClass(HINSTANCE hInstance, const char *classname, const char *iconname, WNDPROC MainWndProc, tWNDCLASSHandler wcHandler); #define DoModelessDialogParam(hWnd,name,proc,param) DoModelessDialogParamWC(hWnd,name,proc,param,NULL) #define DoMultiModelessDialogParam(hWnd,name,proc,param) DoMultiModelessDialogParamWC(hWnd,name,proc,param,NULL) #define DoModelessDialog(hWnd,name,proc) DoModelessDialogParam(hWnd,name,proc,0) #define DoMultiModelessDialog(hWnd,name,proc) DoMultiModelessDialogParam(hWnd,name,proc,0) #define DoModalDialogParam(hWnd,name,proc,param) DoModalDialogParamWC(hWnd,name,proc,param,NULL) #define DoModalDialog(hWnd,name,proc) DoModalDialogParam(hWnd,name,proc,0) #define DoClassDialog(hInstance,classname,iconname,hWnd,name,wproc,dproc) \ DoClassDialogParam(hInstance,classname,iconname,hWnd,name,wproc,dproc,0) #define DoClassDialogParam(hInstance,classname,iconname,hWnd,name,wproc,dproc,lParam) \ DoClassDialogParamCMD(hInstance,classname,iconname,hWnd,name, \ wproc, dproc, SW_SHOW,NULL) int mDeleteAccelerator(HWND hWnd); int mAddAcceleratorType(HWND hWnd,const char *name,int loose); int mIsAcceleratorMessage(MSG *msg); int mMessageLoop(void); HWND DoClassDialogParamCMD(HINSTANCE hInstance, const char *classname, const char *iconname, HWND hWnd, const char *dialogname, WNDPROC MainWndProc, DLGPROC MainDlgProc, LPARAM lParam, int nCmdShow, tWNDCLASSHandler wcHandler); #define mAddAccelerator(hWnd,name) mAddAcceleratorType(hWnd,name,1) int mChangeAcceleratorType(HWND hWnd,int loose); /***************************************************************************/ #define mClassDlgMAINWC(dclass,icon,accel,dial,wfun,dfun,wch) \ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, \ LPSTR lpCmdLine, int nCmdShow) \ { \ HWND hWnd = DoClassDialogParamCMD(hInstance,dclass,icon,NULL,dial,wfun,dfun, \ 0,nCmdShow,wch); \ (void)hPrevInstance;(void)lpCmdLine; \ if ( !hWnd ) return 1; \ mAddAccelerator(hWnd,accel); \ return mMessageLoop(); \ } \ /***************************************************************************/ #define mClassDlgMAIN(dclass,icon,accel,dial,wfun,dfun) \ mClassDlgMAINWC(dclass,icon,accel,dial,wfun,dfun,NULL) /***************************************************************************/ #define mDlgMAIN(accel,dial,fun) \ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, \ LPSTR lpCmdLine, int nCmdShow) \ { \ HWND hWnd; \ DialogSethInstance(hInstance); \ hWnd = DoMultiModelessDialog(NULL,dial,fun); \ (void)hPrevInstance;(void)lpCmdLine;(void)nCmdShow; \ if ( !hWnd ) return 1; \ mAddAccelerator(hWnd,accel); \ return mMessageLoop(); \ } \ /***************************************************************************/ #define mClassDlgMAINWCVBX(dclass,icon,accel,dial,wfun,dfun,wch) \ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, \ LPSTR lpCmdLine, int nCmdShow) \ { \ HWND hWnd; int ret; \ VBXInit( hInstance, "Thunder" ); \ hWnd = DoClassDialogParamCMD(hInstance,dclass,icon,NULL,dial,wfun,dfun, \ 0,nCmdShow,wch); \ (void)hPrevInstance;(void)lpCmdLine; \ if ( !hWnd ) return 1; \ mAddAccelerator(hWnd,accel); \ ret = mMessageLoop(); \ VBXTerm(); \ return ret; \ } \ int mGetChildRect(HWND hWnd,int id,RECT *rc); HWND DoClassDialogParamCMDSet(HINSTANCE hInstance, const char *classname, const char *iconname, HWND hWnd, const char *dialogname, WNDPROC MainWndProc, DLGPROC MainDlgProc, LPARAM lParam, int nCmdShow, tWNDCLASSHandler wcHandler); #ifdef __cplusplus } #endif #endif /* MDIALOG_H */