static short create_directory( int main_x, int main_y, char *parent) /* Dialog for "create new directory". Asks user for * the name of the new directory and creates it. * * In: main_x = Requested window position * main_y = =""= * parent = Parent directory * * Return: 0 = OK, new directory created. * REJECT = Operation canceled. * * (C)2007-11-21 J. Kjellander * ******************************************************!*/ { char newpath[V3PTHLEN],dirname[JNLGTH],title[V3STRLEN], pmt[V3STRLEN]; int altlen,alth,main_dx,main_dy,ly,alt_x,alt_y; DBint iwin_id,okey_id,reject_id,pmt_id,edit_id,but_id; WPIWIN *iwinpt; WPBUTT *butptr; /* ***Texts from the ini-file. */ if ( !WPgrst("varkon.input.new.title",title) ) strcpy(title,"New directory"); if ( !WPgrst("varkon.input.new.prompt",pmt) ) strcpy(pmt,"Current path"); /* ***Ok and Reject, which text is longest ? */ altlen = 0; if ( WPstrl(okey) > altlen ) altlen = WPstrl(okey); if ( WPstrl(reject) > altlen ) altlen = WPstrl(reject); altlen *= 1.4; /* ***Window geometry. */ ly = 1.0*WPstrh(); alth = 1.8*WPstrh(); main_dx = altlen + ly + altlen + ly + altlen; main_dy = ly + alth + ly + alth + ly + alth + alth + ly + alth; if ( WPstrl(pmt) > main_dx ) main_dx = WPstrl(pmt); if ( WPstrl(parent) > main_dx ) main_dx = WPstrl(parent); main_dx += 2*ly; /* ***Create the window as a WPIWIN. */ WPwciw(main_x,main_y,main_dx,main_dy,title,&iwin_id); iwinpt = (WPIWIN *)wpwtab[iwin_id].ptr; /* ***Prompts. */ alt_x = ly; alt_y = ly; WPcrlb((wpw_id)iwin_id,alt_x,alt_y,WPstrl(pmt),alth,pmt,&pmt_id); alt_y += alth; WPcrlb((wpw_id)iwin_id,alt_x,alt_y,WPstrl(parent),alth,parent,&pmt_id); /* ***Input edit. */ alt_y += alth + ly; WPmced((wpw_id)iwin_id,alt_x,alt_y,main_dx-2*ly,alth,(short)1, "",JNLGTH,&edit_id); /* ***A 3D line. */ alt_x = main_dx/8; alt_y += 2*alth; WPcreate_3Dline(iwin_id,alt_x,alt_y,7*main_dx/8,alt_y); /* ***Ok and Reject. */ alt_x = ly; alt_y += ly; WPcrpb((wpw_id)iwin_id,alt_x,alt_y,altlen,alth,1, okey,okey,"",WP_BGND2,WP_FGND,&okey_id); butptr = (WPBUTT *)iwinpt->wintab[okey_id].ptr; strcpy(butptr->tt_str,okeytt); alt_x = ly + altlen + ly; WPcrpb((wpw_id)iwin_id,alt_x,alt_y,altlen,alth,1, reject,reject,"",WP_BGND2,WP_FGND,&reject_id); butptr = (WPBUTT *)iwinpt->wintab[reject_id].ptr; strcpy(butptr->tt_str,rejecttt); /* ***Show the dialogue. */ WPwshw(iwin_id); XRaiseWindow(xdisp,iwinpt->id.x_id); /* ***Wait for action. */ loop: WPwwtw(iwin_id,SLEVEL_V3_INP,&but_id); /* ***Ok button or CR key. */ if ( but_id == okey_id || but_id == edit_id ) { WPgted(iwin_id,edit_id,dirname); if ( dirname[0] == '\0' ) { WPbell(); goto loop; } else { strcpy(newpath,parent); strcat(newpath,dirname); if ( IGmkdr(newpath) == 0 ) { WPwdel(iwin_id); return(0); } else { strcpy(dirname,""); WPuped(iwin_id,edit_id,dirname); WPbell(); goto loop; } } } /* ***Reject. */ else if ( but_id == reject_id ) { WPwdel(iwin_id); return(REJECT); } /* ***Unknown event. */ else goto loop; }
int igcenv() /* Kollar att nödvändiga ENV-parametrar registrerats * och om så inte är fallet föreslås auto-registrering * med VARKON_ROOT = katalogen ovanför den där varkon * startats ifrån, dvs. den där VARKON95.EXE ligger. * * FV: 0. * * (C)microform ab 1998-01-03 Johan Kjellander * * 1998-01-16 C:\TMP, J.Kjellander * 2004-10-13 Check environment of this process * 2004-10-13 Sets variables also in current process * 2004-10-13 Added SendMessageTimeout() * ******************************************************!*/ { char path[V3PTHLEN+1],buf[2*V3PTHLEN]; int n; long status; HKEY envkey; DWORD disposition,dwReturnValue; /* HKEY key; DWORD size; */ static char envbuf[V3PTHLEN+1],buf2[2*V3PTHLEN]; char *tmp; /* ***Kolla om VARKON_ROOT finns i registret. */ /* Removed by SL, as this is done inderectly by getenv status = RegOpenKeyEx(HKEY_CURRENT_USER,"Environment", (DWORD)0,KEY_QUERY_VALUE,&key); if ( status == ERROR_SUCCESS ) { size= V3PTHLEN; status = RegQueryValueEx(key,"VARKON_ROOT",NULL,NULL,envbuf,&size); RegCloseKey(key); if ( status == ERROR_SUCCESS ) return(0); } */ /* ***Check for VARKON_ROOT in environment. */ tmp = getenv( "VARKON_ROOT" ); /* ***VARKON_ROOT är ej registrerat. if ( status != ERROR_SUCCESS ) */ if ( tmp == NULL ) { if ( MessageBox(NULL, "No registry settings found, register default ?", "VARKON Configuration error", MB_ICONQUESTION | MB_YESNO) == IDYES ) { /* ***Hämta path till den exe-fil som nu körs. ***Tex. C:\VARKON\BIN\VARKON95.EXE */ GetModuleFileName(NULL,path,V3PTHLEN); /* ***Ta bort 2 sista nivåerna i vägbeskrivningen, ***dvs. troligen "\BIN\VARKON95.EXE". */ n = strlen(path); while ( --n > 0 && path[n] != '\\') path[n] = '\0'; if ( path[n] == '\\' ) while ( --n > 0 && path[n] != '\\') path[n] = '\0'; if ( path[n] == '\\' ) path[n] = '\0'; strcpy(buf,"Do you want to register "); strcat(buf,path); strcat(buf," as VARKON:s root directory ?"); if ( MessageBox(NULL, buf, "VARKON Configuration", MB_ICONQUESTION | MB_YESNO) == IDYES ) { /* ***Registrera. */ status = RegCreateKeyEx(HKEY_CURRENT_USER, "Environment", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &envkey, &disposition); strcpy(buf,path); RegSetValueEx(envkey,"VARKON_ROOT",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_ROOT="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\PID"); RegSetValueEx(envkey,"VARKON_PID",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_PID="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\MAN"); RegSetValueEx(envkey,"VARKON_DOC",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_DOC="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\ERM"); RegSetValueEx(envkey,"VARKON_ERM",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_ERM="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\CNF\\FNT"); RegSetValueEx(envkey,"VARKON_FNT",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_FNT="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\CNF\\INI\\ENGLISH"); RegSetValueEx(envkey,"VARKON_INI",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_INI="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\LIB"); RegSetValueEx(envkey,"VARKON_LIB",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_LIB="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\MDF\\ENGLISH"); RegSetValueEx(envkey,"VARKON_MDF",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_MDF="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\CNF\\PLT"); RegSetValueEx(envkey,"VARKON_PLT",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_PLT="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\APP"); RegSetValueEx(envkey,"VARKON_PRD",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_PRD="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\CNF\\SND"); RegSetValueEx(envkey,"VARKON_SND",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_SND="); strcat(buf2,buf); _putenv(buf2); strcpy(buf,path); strcat(buf,"\\CNF\\TOL"); RegSetValueEx(envkey,"VARKON_TOL",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_TOL="); strcat(buf2,buf); _putenv(buf2); /* ***TMP lägger vi på den lokala hårddisken C:\TEMP ***Om inte filkatalogen finns skapar vi den dessutom. */ strcpy(buf,"C:\\TEMP"); RegSetValueEx(envkey,"VARKON_TMP",0,REG_SZ,buf,strlen(buf)+1); strcpy(buf2,"VARKON_TMP="); strcat(buf2,buf); _putenv(buf2); if ( !IGfacc(buf,'X') ) IGmkdr(buf); /* ***Stäng registret. */ RegCloseKey(envkey); /* ***Notify system that the environment variables has been updated in registry. *** */ SendMessageTimeout(HWND_BROADCAST,WM_SETTINGCHANGE,0, (LPARAM)"Environment",SMTO_ABORTIFHUNG,5000,&dwReturnValue); return(0); } } } /* ***S**t. */ return(0); }