00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <windows.h>
00027 #include <commctrl.h>
00028 #include <stdlib.h>
00029 #include <stdarg.h>
00030 #include <math.h>
00031
00032 #include "struct.h"
00033 #include "dstruct.h"
00034 #include "dxfcon.h"
00035
00036 int (*X__pri)(const char *,...);
00037 int X__local_print(const char *,...);
00038
00039 HWND hWndParent;
00040 HINSTANCE hInstance;
00041 HWND dlg=NULL,hwndProgress=NULL;
00042
00043 #if __WATCOMC__
00044 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00045 #elif __BCC__
00046 int APIENTRY DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00047 #else
00048 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00049 #endif
00050 switch (dwReason) {
00051 case DLL_PROCESS_ATTACH:
00052 hInstance=hDLL;
00053 break;
00054 case DLL_PROCESS_DETACH:
00055 break;
00056 }
00057 return TRUE;
00058 }
00059
00060 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00061 switch( msg ) {
00062 case WM_INITDIALOG:
00063 hwndProgress=GetDlgItem(hwnd,DLG_PROGRESS);
00064 SendMessage(hwndProgress,PBM_SETRANGE,0,MAKELPARAM(0,99));
00065 SendMessage(hwndProgress,PBM_SETSTEP,(WPARAM)1,0);
00066 SendMessage(hwndProgress,PBM_SETPOS,(WPARAM)0,0);
00067 CentreDlgOnS(hwnd);
00068 break;
00069 default: break;
00070 }
00071 return( FALSE );
00072 }
00073
00074 BOOL CALLBACK DlgProcSettings(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00075 char str[32];
00076 static struct bp {
00077 short h_type,l_freeze,b_freeze,no_weld,d2,d3,cs;
00078 double wt;
00079 } *dp;
00080 switch( msg ) {
00081 case WM_INITDIALOG:
00082 dp=(struct bp *)lparam;
00083 if(dp->h_type == 0)SendDlgItemMessage(hwnd,DLG_SET_HX,BM_SETCHECK,TRUE,0);
00084 if(dp->h_type == 1)SendDlgItemMessage(hwnd,DLG_SET_HL,BM_SETCHECK,TRUE,0);
00085 if(dp->h_type == 2)SendDlgItemMessage(hwnd,DLG_SET_HB,BM_SETCHECK,TRUE,0);
00086 if(dp->l_freeze == 1)SendDlgItemMessage(hwnd,DLG_SET_FL,BM_SETCHECK,TRUE,0);
00087 if(dp->no_weld == 0)SendDlgItemMessage(hwnd,DLG_SET_NW,BM_SETCHECK,TRUE,0);
00088 if(dp->d2 == 1)SendDlgItemMessage(hwnd,DLG_SET_D2,BM_SETCHECK,TRUE,0);
00089 sprintf(str,"%.4lf",dp->wt);
00090 SetDlgItemText(hwnd,DLG_SET_WT,(LPCTSTR)str);
00091 sprintf(str,"%ld",dp->cs);
00092 SetDlgItemText(hwnd,DLG_SET_CS,(LPCTSTR)str);
00093 CentreDlgOnS(hwnd);
00094 return (TRUE);
00095 case WM_COMMAND:
00096 switch(LOWORD(wparam)){
00097 case IDCANCEL:
00098 EndDialog(hwnd,FALSE);
00099 return(TRUE);
00100 case IDOK:
00101 if(SendDlgItemMessage(hwnd,DLG_SET_HX,BM_GETCHECK,0,0))
00102 dp->h_type=0;
00103 else if(SendDlgItemMessage(hwnd,DLG_SET_HL,BM_GETCHECK,0,0))
00104 dp->h_type=1;
00105 else if(SendDlgItemMessage(hwnd,DLG_SET_HB,BM_GETCHECK,0,0))
00106 dp->h_type=2;
00107 if(SendDlgItemMessage(hwnd,DLG_SET_FL,BM_GETCHECK,0,0))
00108 dp->l_freeze=1;
00109 else dp->l_freeze=0;
00110 if(SendDlgItemMessage(hwnd,DLG_SET_NW,BM_GETCHECK,0,0))
00111 dp->no_weld=0;
00112 else dp->no_weld=1;
00113 if(SendDlgItemMessage(hwnd,DLG_SET_D2,BM_GETCHECK,0,0))
00114 dp->d2=1;
00115 else dp->d2=0;
00116 if(GetDlgItemText(hwnd,DLG_SET_WT,str,10) == 0){
00117 EndDialog(hwnd,FALSE); return TRUE;
00118 }
00119 dp->wt=atof(str);
00120 if(GetDlgItemText(hwnd,DLG_SET_CS,str,10) == 0){
00121 EndDialog(hwnd,FALSE); return TRUE;
00122 }
00123 dp->cs=atoi(str);
00124 if(dp->cs < 3)dp->cs=3;
00125 EndDialog(hwnd,TRUE);
00126 return(TRUE);
00127 default: break;
00128 }
00129 default: break;
00130 }
00131 return( FALSE );
00132 }
00133
00134 BOOL CALLBACK DlgProcScale(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00135 char str[32];
00136 static double *scale;
00137 switch( msg ) {
00138 case WM_INITDIALOG:
00139 scale = (double *)lparam;
00140 sprintf(str,"%.3le",*scale);
00141 SetDlgItemText(hwnd,DLG_SCALE_SCALE,(LPCTSTR)str);
00142 CentreDlgOnS(hwnd);
00143 return (TRUE);
00144 case WM_COMMAND:
00145 switch(LOWORD(wparam)){
00146 case IDCANCEL:
00147 EndDialog(hwnd,FALSE);
00148 return(TRUE);
00149 case IDOK:
00150 if(GetDlgItemText(hwnd,DLG_SCALE_SCALE,str,31) == 0){
00151 EndDialog(hwnd,FALSE); return TRUE;
00152 }
00153 sscanf(str,"%lf",scale);
00154 if(*scale < 1.e-10)*scale=1.e-10;
00155 EndDialog(hwnd,TRUE);
00156 return(TRUE);
00157 default: break;
00158 }
00159 default: break;
00160 }
00161 return( FALSE );
00162 }
00163
00164
00165 long _Convert(
00166 HWND parent,
00167 char *iname,
00168 char *oname,
00169 X__STRUCTURE *lpevi
00170 ){
00171 long i,r;
00172 double wt = 0.0001;
00173 short h_type=0,l_freeze=0,b_freeze=0,no_weld=0,d2=0,
00174 d3=1,cs=15;
00175 struct bp {
00176 short h_type,l_freeze,b_freeze,no_weld,d2,d3,cs;
00177 double wt;
00178 } d;
00179 lpEVI=lpevi;
00180 hWndParent=parent;
00181 X__pri=X__local_print;
00182 d.h_type=h_type;
00183 d.l_freeze=l_freeze;
00184 d.b_freeze=b_freeze;
00185 d.no_weld=no_weld;
00186 d.d2=d2;
00187 d.d3=d3;
00188 d.cs=cs;
00189 d.wt=wt;
00190 if(!DialogBoxParam(hInstance,MAKEINTRESOURCE(DLG_SET),hWndParent,
00191 (DLGPROC)DlgProcSettings,(LPARAM)&d))return 0;
00192 dlg=CreateDialog(hInstance,MAKEINTRESOURCE(DLG),parent,(DLGPROC)DlgProc);
00193 r=(long)DoDxfConvert(iname,oname,
00194 d.wt,d.h_type,d.l_freeze,d.b_freeze,d.no_weld,
00195 d.d2,d.d3,d.cs);
00196 if(dlg != NULL)DestroyWindow(dlg); dlg=NULL;
00197 return r;
00198 }
00199
00200 int X__local_print(const char *format,...){
00201 char line[80];
00202 va_list arg_ptr;
00203 va_start(arg_ptr,format);
00204 vsprintf(line,format,arg_ptr);
00205 va_end(arg_ptr);
00206
00207 return 1;
00208 }