int ListInsertItem(HWND Window,int Pos,char *String) { HANDLE ListHandle; ListHandle=WindowList(Window); if (Pos>ListGetTotal(ListHandle)) { // printf("pos is invalid. window=%d, pos=%d\n",Window,Pos); return(INVAILEDPARAM); } if (ListGetTotal(ListHandle)>=MAXLISTCHAR/ListGetItemLength(ListHandle)) { // printf("Too many items.\n"); return(TOOMANYLISTITEMS); } memmove(ListGetItem(ListHandle,Pos+1),ListGetItem(ListHandle,Pos), ListGetItemLength(ListHandle)*(ListGetTotal(ListHandle)-Pos)); ListSetItem(ListHandle,Pos,String); ListIncTotal(ListHandle,1); #ifdef USE_SCROLL if (ListGetTotal(ListHandle)==ListGetHeight(ListHandle)+1) { HWND MidWindow; MidWindow=CreatVScroll(WindowGetWidth(Window)-2-SYSSCROLLWIDTH,1, WindowGetHeight(Window)-2,NULL,Window); // MessageInsert(MidWindow,REDRAWMESSAGE,0L, // MAKELONG(WindowGetWidth(Window),WindowGetHeight(Window)) ); } #endif ReturnOK(); }
void help_MatchFound(xmlNode *node, xmlNode **MatchNode, List *TopicWords, int *MatchTextPos, int *Nmatches, int *ambiguous, char **HelpPosition, char **HelpTexts) { int abbreviation,i; List *PrevMatchPosition; if ((*Nmatches)==MAX_HELP_HITS) { ppl_error(ERR_INTERNAL, -1, -1, "Cannot parse ppl_help.xml. Need to increase MAX_HELP_HITS."); return; } help_TopicPrint(HelpTexts[*Nmatches], HelpPosition, ListLen(TopicWords)); if (*ambiguous == 0) { if (*MatchNode == NULL) { *MatchTextPos = 0; *MatchNode = node; // This is the first match we've found } else { PrevMatchPosition = StrSplit( HelpTexts[*MatchTextPos] ); abbreviation = 1; // If previous match is an autocomplete shortening of current match, let it stand for (i=0; i<=ListLen(TopicWords); i++) if (StrAutocomplete( (char *)ListGetItem(PrevMatchPosition,i) , HelpPosition[i] , 1)==-1) {abbreviation=0; break;} if (abbreviation!=1) { abbreviation = 1; // If current match is an autocomplete shortening of previous match, the current match wins for (i=0; i<=ListLen(TopicWords); i++) if (StrAutocomplete( HelpPosition[i] , (char *)ListGetItem(PrevMatchPosition,i) , 1)==-1) {abbreviation=0; break;} if (abbreviation==1) { *MatchTextPos = *Nmatches; *MatchNode = node; } else { *ambiguous = 1; // We have multiple ambiguous matches } } } } (*Nmatches)++; return; }
int ListDeleteItem(HWND Window,int Pos) { HANDLE ListHandle; ListHandle=WindowList(Window); if (Pos>=ListGetTotal(ListHandle)||Pos<0) return(INVAILEDPARAM); memmove(ListGetItem(ListHandle,Pos),ListGetItem(ListHandle,Pos+1), ListGetItemLength(ListHandle)*(ListGetTotal(ListHandle)-Pos-1)); ListDecTotal(ListHandle,1); #ifdef USE_SCROLL if (ListGetTotal(ListHandle)==ListGetHeight(ListHandle)) if (!WindowIsChildless(Window)) MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l); #endif ReturnOK(); }
stPosicion PAT_Informacion(char *c) { char cVelocidad[10]={0}; static int iElementos=0; stPosicion p = MistPosicion; //obtiene el indice de la velocidad iElementos = ListNumItems(miLista); for (int i=0;i<iElementos;i++) { ListGetItem(miLista, &p, i+1); if (CompareStrings(p.cDescripcion, 0, c, 0, 0)==0) { i=iElementos; } } return p; }
static unsigned long WildCardList(HWND Window,HMSG Message,long Param1,long Param2) { switch (Message) { case WINDOWINIT: { char *wd=NowOpenFile->wildcard; char wid[10]; MessageGo(Window,LISTSETITEMHEIGHT,16,0); MessageGo(Window,LISTSETITEMLENGTH,12,0); MessageGo(Window,SETLINEBUFFER,FP2LONG(wd),0L); while(*wd) { strcpy(wid,wd); MessageGo(Window,LISTAPPENDITEM,FP2LONG(wid),0L); while(*wd) wd++; wd++; // point to next wildcast name: // exp. *.tif;*.bmp;*.pcx } } break; case ITEMSELECT: { HWND MidWin,hlist; // ComboDefaultProcedure(Window,COMBOPULL,0l,0l); //ByHance,96,1.23 ComboDefaultProcedure(Window,Message,Param1,Param2); MidWin = ComboFindListBox(Window); hlist = WindowList(MidWin); strcpy(NowOpenFile->wildcard,ListGetItem(hlist,ListGetCurrent(hlist))); MidWin = WindowGetFather(Window); ///Dialog MessageGo(MidWin,DIRCHANGE,0l,0l); } break; default: return(ComboDefaultProcedure(Window,Message,Param1,Param2)); } return(TRUE); }
void help_explore(xmlNode *node, xmlNode **MatchNode, List *TopicWords, int *MatchTextPos, int *Nmatches, int *ambiguous, char **HelpPosition, char **HelpTexts, int depth) { xmlNode *cur_node = NULL; int match,i; if (depth>ListLen(TopicWords)) return; if (depth==MAX_HELP_DEPTH) { ppl_error(ERR_INTERNAL, -1, -1, "Cannot parse ppl_help.xml. Need to increase MAX_HELP_DEPTH."); return; } for (cur_node = node; cur_node; cur_node = cur_node->next) // Loop over siblings { match=1; if (cur_node->type == XML_ELEMENT_NODE) { sprintf(HelpPosition[depth], "%s", cur_node->name); // Converted signedness of chars for (i=1;i<=depth;i++) if (StrAutocomplete( (char *)ListGetItem(TopicWords,i-1) , HelpPosition[i], 1)==-1) {match=0; break;} if ((match==1) && (depth==ListLen(TopicWords))) help_MatchFound(cur_node,MatchNode,TopicWords,MatchTextPos,Nmatches,ambiguous,HelpPosition,HelpTexts); } if (match==1) help_explore(cur_node->children,MatchNode,TopicWords,MatchTextPos,Nmatches,ambiguous,HelpPosition,HelpTexts,depth+1); } return; }
long ListBoxDefaultProcedure(HWND Window,HMSG Message,long Param1,long Param2) { struct viewporttype TmpViewPort; int i,Length,key; HWND MidWindow; int DisplayItem; int DisplayWidth; char MidString[100]; int Left,Top,Right,Bottom; int SaveColor; switch (Message) { case WINDOWQUIT: ListHandleFree(); break; case KEYSTRING: break; case KEYDOWN: switch (MAKELO(Param1)) { case HOME: Param2=ListGetCurrent(WindowList(Window)); goto lbl_upward; case PGUP: Param2=ListGetHeight(WindowList(Window)); goto lbl_upward; case UP: Param2=1; lbl_upward: Length=Param2; if (ListGetCurrent(WindowList(Window))-Length<0) Length=ListGetCurrent(WindowList(Window)); if (!Length) { //Alarm(); break; } Length=-Length; goto lbl_process_up_down; case END: Param2=ListGetTotal(WindowList(Window))-1 -ListGetCurrent(WindowList(Window)); goto lbl_downward; case PGDN: Param2=ListGetHeight(WindowList(Window)); goto lbl_downward; case DOWN: Param2=1; lbl_downward: Length=Param2; if (ListGetCurrent(WindowList(Window))+Length>= ListGetTotal(WindowList(Window))-1) Length=ListGetTotal(WindowList(Window))-1 -ListGetCurrent(WindowList(Window)); if (!Length) { // Alarm(); break; } lbl_process_up_down: ListIncCurrent(WindowList(Window),Length); MessageInsert(Window,ITEMSELECT, ListGetCurrent(WindowList(Window)),Window); #ifdef USE_SCROLL MidWindow=GetVVScroll(Window); if (MidWindow) { i=WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2; i*=ListGetCurrent(WindowList(Window)); // i/=ListGetTotal(WindowList(Window)); i/=ListGetTotal(WindowList(Window))-1; i=i-WindowGetTop(MidWindow)+SYSSCROLLWIDTH; //*------ if(WindowGetBottom(MidWindow)+i> WindowGetHeight(WindowGetFather(MidWindow))-2-SYSSCROLLWIDTH) i=WindowGetHeight(WindowGetFather(MidWindow))-2 -SYSSCROLLWIDTH-WindowGetBottom(MidWindow); //--------------------------*/ MessageInsert(MidWindow,WINDOWMOVE,0l,i); } #endif if (!ListVScroll(Window)) { DisplayItem=ListGetCurrent(WindowList(Window)) -ListGetTop(WindowList(Window)); // MessageInsert(Window,WMPAINT,MAKELONG(0, MessageInsert(Window,REDRAWMESSAGE,MAKELONG(0, (DisplayItem-Length)*CHARHEIGHT), MAKELONG(0,(DisplayItem-Length+1))*CHARHEIGHT); // MessageInsert(Window,WMPAINT,MAKELONG(0,DisplayItem*CHARHEIGHT), MessageInsert(Window,REDRAWMESSAGE,MAKELONG(0,DisplayItem*CHARHEIGHT), MAKELONG(0,(DisplayItem+1)*CHARHEIGHT)); } break; case TAB: WindowTableOrderNext(Window); break; case SHIFT_TAB: WindowTableOrderPrev(Window); break; case ENTER: #ifdef USE_SCROLL if (!WindowIsChildless(Window)) MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l); #endif MessageInsert(Window,LISTBOXCONFIRM,0L,0L); break; case ESC: #ifdef USE_SCROLL // Added ByHance, 96,4.2 if (!WindowIsChildless(Window)) MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l); #endif MessageInsert(WindowGetFather(Window),Message,Param1,Param2); break; default: key=MAKELO(Param1); key=toupper(key); if(key>='A' && key<='Z') { // quick select FirstLetterItem for(i=0;i<ListGetTotal(WindowList(Window));i++) { int ch; char *str; str=ListGetItem( WindowList(Window),i ), ch=toupper(str[0]); if(ch>=key) break; } if( i>=ListGetTotal(WindowList(Window)) ) i=ListGetTotal(WindowList(Window))-1; //the last Param2=i-ListGetCurrent(WindowList(Window)); goto lbl_downward; } break; } break; case MOUSELEFTDOWN: //key=ListGetCurrent(WindowList(Window)); if (MAKELO(Param1)/CHARHEIGHT!=ListGetCurrent(WindowList(Window)) -ListGetTop(WindowList(Window)) &&MAKELO(Param1)/CHARHEIGHT<ListGetTotal(WindowList(Window)) /*-ListGetHeight(WindowList(Window))*/) { if (ListGetCurrent(WindowList(Window)) >= ListGetTop(WindowList(Window)) && ListGetCurrent(WindowList(Window)) < ListGetTop(WindowList(Window))+ListGetHeight(WindowList(Window))) MessageGo(Window,WMPAINT, MAKELONG(0,(ListGetCurrent(WindowList(Window))- ListGetTop(WindowList(Window)))*CHARHEIGHT), MAKELONG(0,(ListGetCurrent(WindowList(Window))+1- ListGetTop(WindowList(Window)))*CHARHEIGHT)); ListSetCurrent(WindowList(Window),MAKELO(Param1)/CHARHEIGHT +ListGetTop(WindowList(Window))); if (WindowGetProcedure(WindowGetFather(Window))==(Function *)ComboDefaultProcedure) MessageInsert(WindowGetFather(Window),COMBOPULL,Param1,Param2); else { #ifdef USE_SCROLL MidWindow=GetVVScroll(Window); if (MidWindow) { i=WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2; i*=ListGetCurrent(WindowList(Window)); // i/=ListGetTotal(WindowList(Window)); i/=ListGetTotal(WindowList(Window))-1; i=i-WindowGetTop(MidWindow)+SYSSCROLLWIDTH; //*------ if(WindowGetBottom(MidWindow)+i> WindowGetHeight(WindowGetFather(MidWindow))-2-SYSSCROLLWIDTH) i=WindowGetHeight(WindowGetFather(MidWindow))-2 -SYSSCROLLWIDTH-WindowGetBottom(MidWindow); //------*/ MessageGo(MidWindow,WINDOWMOVE,0l,i); } #endif MessageGo(Window,WMPAINT, MAKELONG(0,(ListGetCurrent(WindowList(Window))- ListGetTop(WindowList(Window)))*CHARHEIGHT), MAKELONG(0,(ListGetCurrent(WindowList(Window))+1- ListGetTop(WindowList(Window)))*CHARHEIGHT)); } } //if( key != ListGetCurrent(WindowList(Window)) ) // ByHance, 97,5.11 MessageInsert(Window,ITEMSELECT,ListGetCurrent(WindowList(Window)),Window); break; case VVSCROLLMOVE: /* //i=Param1*ListGetTotal(WindowList(Window)) i=Param1*(ListGetTotal(WindowList(Window))-1) /(WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2) ; if(i<ListGetTop(WindowList(Window)) || i>=ListGetTop(WindowList(Window))+ListGetHeight(WindowList(Window)) ) { i=( ListGetTotal(WindowList(Window)) - 1 ) * Param1; i=0.5+(float)i/(WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2); Length=ListGetTotal(WindowList(Window)) -ListGetHeight(WindowList(Window)); if(i>Length) i=Length; ListSetTop(WindowList(Window),i); MessageInsert(Window,WMPAINT,0l, ListGetHeight(WindowList(Window))*CHARHEIGHT); } */ // modi by zjh for smooth move 96.12.6 { i=( ListGetTotal(WindowList(Window)) - 1 ) * Param1; i=0.5+(float)i/(WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2); Length=ListGetTotal(WindowList(Window))-1; if(i>Length) i=Length; Length=(WindowGetHeight(Window)+0)/16; i=i-Length/2; if (i<0) i=0; if (i+Length>ListGetTotal(WindowList(Window))-1) i=ListGetTotal(WindowList(Window)) - 1-Length+1; if (i<0) i=0; if (i!=ListGetTop(WindowList(Window))) { ListSetTop(WindowList(Window),i); MessageInsert(Window,WMPAINT,0l, ListGetHeight(WindowList(Window))*CHARHEIGHT); } } break; case MOUSELEFTDOUBLE: //MessageInsert(Window,LISTBOXCONFIRM,0L,0L); MessageInsert(Window,KEYDOWN,MAKELONG(0,ENTER),1l); break; case GETFOCUS: // ByHance, 95,11.23 case LOSTFOCUS: WindowDefaultProcedure(Window,Message,Param1,Param2); MidWindow=WindowGetFather(Window); if(MidWindow) // has combo list if( WindowGetHeight(MidWindow)<=SYSBUTTONWIDTH+1) // not pull down break; if(!ListGetTotal(WindowList(Window))) // if no item, break break; MouseHidden(); getviewsettings(&TmpViewPort); SaveColor=getcolor(); WindowGetRealRect(Window,&Left,&Top,&Right,&Bottom); setviewport(Left+1,Top+1,Right-1,Bottom-1,1); DisplayWidth=ListGetItemLength(WindowList(Window))*CHARWIDTH/2; if (DisplayWidth<WindowGetWidth(Window)) DisplayWidth=WindowGetWidth(Window); if (!WindowIsChildless(Window)) DisplayWidth-=SYSSCROLLWIDTH+1+CHARWIDTH/2; //by jerry // DisplayWidth-=SYSSCROLLWIDTH+4; i=ListGetCurrent(WindowList(Window))-ListGetTop(WindowList(Window)); i*=CHARHEIGHT; if(Message==GETFOCUS) { DisplayVirtualRect(3,i+1,2+DisplayWidth-1,i+CHARHEIGHT-1); //if(ListGetTotal(WindowList(Window))==1) if(fGetFocusByKey) // ByHance, 97,5.11 MessageInsert(Window,ITEMSELECT,ListGetCurrent(WindowList(Window)),Window); } else { // LOSTFOCUS DisplayWidth/=CHARWIDTH/2; strncpy(MidString, ListGetItem( WindowList(Window),ListGetCurrent(WindowList(Window)) ), DisplayWidth); Length=strlen(MidString); if (Length<DisplayWidth) memset(MidString+Length,' ',DisplayWidth-Length); MidString[DisplayWidth]=0; ViewportDisplayString(MidString,2,i,LISTBKCOLOR,LISTCOLOR); } setviewport(TmpViewPort.left,TmpViewPort.top,TmpViewPort.right, TmpViewPort.bottom,TmpViewPort.clip); setcolor(SaveColor); MouseShow(); break; case DRAWWINDOW: WindowDefaultProcedure(Window,Message,Param1,Param2); case WMPAINT: getviewsettings(&TmpViewPort); SaveColor=getcolor(); MouseHidden(); WindowGetRealRect(Window,&Left,&Top,&Right,&Bottom); setviewport(Left+1,Top+1,Right-1,Bottom-1,1); setfillstyle(1,EGA_WHITE); if (!WindowIsChildless(Window)) Right-=SYSSCROLLWIDTH+10; // ByHance, 96,3.24 bar(0,0,Right-Left,Bottom-Top); // clear area Param1 = 0; Param2 = Bottom-Top; DisplayWidth=ListGetItemLength(WindowList(Window))*CHARWIDTH/2; if (DisplayWidth<WindowGetWidth(Window)) DisplayWidth=WindowGetWidth(Window); if (!WindowIsChildless(Window)) DisplayWidth-=SYSSCROLLWIDTH+1+CHARWIDTH/2; // by jerry //DisplayWidth-=SYSSCROLLWIDTH+4; DisplayWidth/=CHARWIDTH/2; for (i=MAKELO(Param1);i<MAKELO(Param2);i+=CHARHEIGHT) { if (i/CHARHEIGHT+ListGetTop(WindowList(Window)) >=ListGetTotal(WindowList(Window))) break; strncpy(MidString,ListGetItem(WindowList(Window),i/CHARHEIGHT +ListGetTop(WindowList(Window))),DisplayWidth); Length=strlen(MidString); if (Length<DisplayWidth) memset(MidString+Length,' ',DisplayWidth-Length); MidString[DisplayWidth]=0; if (i/CHARHEIGHT==ListGetCurrent(WindowList(Window)) -ListGetTop(WindowList(Window))) { ViewportDisplayString(MidString,2,i,LISTBKCOLOR,LISTCOLOR); if (Window==ActiveWindow) // ByHance DisplayVirtualRect(3,i+1, 2+DisplayWidth*ASC16WIDTH-1,i+CHARHEIGHT-1); } else ViewportDisplayString(MidString,2,i,LISTCOLOR,LISTBKCOLOR); } setviewport(TmpViewPort.left,TmpViewPort.top,TmpViewPort.right, TmpViewPort.bottom,TmpViewPort.clip); setcolor(SaveColor); MouseShow(); break; case LISTAPPENDITEM: ListInsertItem(Window,ListGetTotal(WindowList(Window)),(char *)LONG2FP(Param1)); break; case LISTINSERTITEM: ListInsertItem(Window,Param2,(char *)LONG2FP(Param1)); break; case LISTINSERTITEMSORTED: { char *p1,*p2; p2 = (char *)LONG2FP(Param1); for (i=0;i<ListGetTotal(WindowList(Window));i++) { p1 = ListGetItem(WindowList(Window),i); if (strcmp(p2,p1)>0) continue; ListInsertItem(Window,i,p2); break; } if (i==ListGetTotal(WindowList(Window))) ListInsertItem(Window,i,p2); } break; case LISTDELETEITEM: if (Param1<ListGetTotal(WindowList(Window))) ListDeleteItem(Window,Param1); break; case LISTDELETELASTITEM: if (ListGetTotal(WindowList(Window))>0) ListDeleteItem(Window,ListGetTotal(WindowList(Window))-1); MessageInsert(Window,WMPAINT,0l, ListGetHeight(WindowList(Window))*CHARHEIGHT); break; case LISTDELETEALL: ListSetTotal(WindowList(Window),0); ListSetTop(WindowList(Window),0); ListSetCurrent(WindowList(Window),0); #ifdef USE_SCROLL if (!WindowIsChildless(Window)) MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l); #endif break; case LISTSETITEMLENGTH: if (Param1>0) ListSetItemLength(WindowList(Window),Param1); break; case LISTSETITEMHEIGHT: if (Param1>0) ListSetHeight(WindowList(Window),(WindowGetHeight(Window)+Param1-2)/Param1); break; case LISTSETTOTALITEM: ListSetTotal(WindowList(Window),Param1); if (!Param1) ListHandleFree(); break; case ITEMSELECT: MessageInsert(WindowGetFather(Window),ITEMSELECT, ListGetCurrent(WindowList(Window)),Window); break; case MOUSEMOVE: //MouseShow(); DialogMouseMove(Window,Message,Param1,Param2); // ByHance, 95,12.6 break; default: return(WindowDefaultProcedure(Window,Message,Param1,Param2)); } return(TRUE); }
int ENT_CalculaDesplazamientoPrueba() { //debe realizar un recorrido por los diferentes planos en busca de las velocidades y su neutral int iElementos=0; stPosicion Analisis[TOTAL_ANALISIS]={0}; int iPlanos[TOTAL_PLANOS]={0}; int iTotalPlanos=0; int iIndiceAnalisis=0; char cAnalisis[500]={0}; char c[30][30]={0}; char cPrimerNeutral[20]={0}; int iTotal=0; iElementos = ListNumItems(miLista); //el primer ciclo es para identificar el total de planos configurados for (int i=0;i<iElementos;i++) { stPosicion p; ListGetItem(miLista, &p, i+1); int iPosicionLibre=-1; int iExiste=0; //primero verifica que no se haya registrado el plano ya for (int j=0;j<TOTAL_PLANOS;j++) { if ((iPlanos[j] == 0) && (iPosicionLibre == -1)) iPosicionLibre=j; if (iPlanos[j] == p.iPlano) { iExiste = 1; break; } } //si el plano no ha sido registrado if (iExiste == 0) { iPlanos[iPosicionLibre] = p.iPlano; iTotalPlanos++; } } //ahora recorre cada uno de los planos localizando sus velocidades disponibles int iIndice=0; for (int j=0;j<iTotalPlanos;j++) { iIndiceAnalisis=0; //inicializa el arreglo de Analisis for (int i=0;i<TOTAL_ANALISIS;i++) Analisis[i].iTipo = -999; for (int i=0;i<iElementos;i++) { stPosicion p; ListGetItem(miLista, &p, i+1); if (iIndiceAnalisis!=3) { if (iPlanos[j] == p.iPlano) { Analisis[iIndiceAnalisis++] = p; } } else break; } //ahora ordena la informacion de Analisis como Velocidad - Neutral - Velocidad //Revisa si el elemento de la posicion 1 es diferente de Neutral if (Analisis[1].iTipo != NEUTRAL) { stPosicion p; //revisa si la primer posicion es neutral if (Analisis[0].iTipo == NEUTRAL) { p=Analisis[0]; Analisis[0] = Analisis[1]; Analisis[1] = p; } else { p=Analisis[2]; Analisis[2] = Analisis[1]; Analisis[1] = p; } } //Aqui tengo en Analisis los elementos del plano j //inicia con la neutral strcat(cAnalisis,Analisis[1].cDescripcion); strcat(cAnalisis,"->"); if (strlen(cPrimerNeutral)==0) { Fmt(cPrimerNeutral,"%s<%s",Analisis[1].cDescripcion); Fmt(cNeutralActual,"%s<%s",Analisis[1].cDescripcion); } for (int i=0;i<iIndiceAnalisis;i++) { strcat(cAnalisis,Analisis[i].cDescripcion); strcat(cAnalisis,"->"); } if (iIndiceAnalisis > 2) { //termina con la neutral strcat(cAnalisis,Analisis[1].cDescripcion); strcat(cAnalisis,"->"); } } strcat(cAnalisis,cPrimerNeutral); Fmt(cDesplazamientoPrueba,"%s<%s",cAnalisis); return 0; }
static unsigned long FileNameList(HWND Window,HMSG Message,long Param1,long Param2) { int hlist; switch (Message) { case DIRCHANGE: MessageGo(Window,WINDOWINIT,0,0); hlist = WindowList(Window); MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT); break; case ITEMSELECT: MessageGo(WindowGetFather(Window),FILECHANGE,Param1,Param2); break; case LISTBOXCONFIRM: hlist=WindowGetUserData(Window); strcpy(NowOpenFile->filename,ListGetItem(hlist,ListGetCurrent(hlist))); MessageGo(WindowGetFather(Window),DIALOGBOXOK,0l,0l); break; case WINDOWINIT: { char *filename=NowOpenFile->filename; char *dirs=NowOpenFile->dirs; char *drive=NowOpenFile->drive; char fn[128]; int r; #ifdef _TURBOC_ struct ffblk opffblk; #else struct find_t opffblk; #endif MessageGo(Window,LISTSETITEMHEIGHT,16,0); MessageGo(Window,LISTSETITEMLENGTH,13,0); /*------ ByHance, 96,3.25 ---- hlist = WindowList(Window); ListSetTotal(hlist,0); ListSetCurrent(hlist,0); ListSetTop(hlist,0); --------------------*/ MessageGo(Window,LISTDELETEALL,0L,0L); // _harderr(handler); if( !dirs[0] ) { #ifdef __TURBOC__ getcurdir((int)(*drive-'A'+1), dirs); #else unsigned total,old; _dos_getdrive(&old); if(old!=*drive-'A'+1) _dos_setdrive( *drive-'A'+1, &total ); getcwd(dirs, 64); memmove(dirs,dirs+3,61); // cancel "C:\" if(!dirs[0]) strcpy(dirs,"\\"); if(old!=*drive-'A'+1) _dos_setdrive( old, &total ); #endif } memset(&opffblk, 0, sizeof(opffblk)); strcpy(fn,drive); //strcat(fn,"\\"); //if( strcmp(dirs,"\\") && strcmp(dirs,"/") ) //{ // strcat(fn,dirs); // strcat(fn,"\\"); //} if(dirs[0]) { char ch; int len; ch=dirs[0]; if(ch!='\\' && ch!='/') strcat(fn,"\\"); strcat(fn,dirs); len=strlen(fn); ch=fn[len-1]; if(ch!='\\' && ch!='/') strcat(fn,"\\"); } strcat(fn,filename); r = findfirst(fn, &opffblk, _A_NORMAL); if (!r) // found at least 1 file strcpy(NowOpenFile->filename, opffblk.ff_name); while (!r) { MessageGo(Window, LISTINSERTITEMSORTED, FP2LONG(opffblk.ff_name), 0L); r = findnext(&opffblk); } //MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT); // ByHance, 95,12.11 MessageInsert(Window,REDRAWMESSAGE,0L, MAKELONG(WindowGetWidth(Window),WindowGetHeight(Window)) ); } break; default: return(ListBoxDefaultProcedure(Window,Message,Param1,Param2)); } return(TRUE); }
static unsigned long DirectoryList(HWND Window,HMSG Message,long Param1,long Param2) { int hlist; switch (Message) { case WINDOWINIT: { //int i,j; char *dirs=NowOpenFile->dirs; char *drive=NowOpenFile->drive; #ifdef _TURBOC_ struct ffblk opffblk; #else struct find_t opffblk; #endif char fn[128]; int r; MessageGo(Window,LISTSETITEMHEIGHT,16,0); MessageGo(Window,LISTSETITEMLENGTH,13,0); /*------ ByHance, 96,3.25 ---- hlist = WindowList(Window); ListSetTotal(hlist,0); ListSetCurrent(hlist,0); ListSetTop(hlist,0); --------------------*/ MessageGo(Window,LISTDELETEALL,0L,0L); // _harderr(handler); if( ! drive[0] ) { // *drive = (char)getdisk()+'A'; *drive = (char)getdisk()+'A'-1; *(drive+1) = ':'; *(drive+2) = 0; } if( !dirs[0] ) { #ifdef __TURBOC__ getcurdir((int)(*drive-'A'+1), dirs); #else unsigned total,old; _dos_getdrive(&old); if(old!=*drive-'A'+1) _dos_setdrive( *drive-'A'+1 , &total ); getcwd(dirs, 64); memmove(dirs,dirs+3,61); // cancel "C:\" if(!dirs[0]) strcpy(dirs,"\\"); if(old!=*drive-'A'+1) _dos_setdrive( old, &total ); #endif } memset(&opffblk, 0, sizeof(opffblk)); strcpy(fn,drive); //if( strcmp(dirs,"\\") && strcmp(dirs,"/") ) //{ // strcat(fn,dirs); // strcat(fn,"\\"); //} if(dirs[0]) { char ch; int len; ch=dirs[0]; if(ch!='\\' && ch!='/') strcat(fn,"\\"); strcat(fn,dirs); len=strlen(fn); ch=fn[len-1]; if(ch!='\\' && ch!='/') strcat(fn,"\\"); } strcat(fn,"*.*"); r = findfirst(fn, &opffblk, FA_DIREC); while (!r) { if((opffblk.ff_attrib & FA_DIREC) && strcmp(opffblk.ff_name,".")) MessageGo(Window, LISTINSERTITEMSORTED, FP2LONG(opffblk.ff_name), 0L); r = findnext(&opffblk); } //MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT); // ByHance, 95,12.11 MessageInsert(Window,REDRAWMESSAGE,0L, MAKELONG(WindowGetWidth(Window),WindowGetHeight(Window)) ); { /*--- display directory's name ----*/ #define max_n (304/ASC16WIDTH) int x,y,w,h; unsigned total,old; int len; int SaveColor; struct viewporttype TmpViewPort; char disk[20],dirs[64],file[14],ext[5]; strupr(fn); _splitpath(fn,disk,dirs,file,ext); _dos_getdrive(&old); if(old!=disk[0]-'A'+1) _dos_setdrive( disk[0]-'A'+1 , &total ); len=strlen(dirs); if(len>1) { char ch=dirs[len-1]; if(ch=='\\' || ch=='/') dirs[len-1]=0; } chdir(dirs); getcwd(dirs, 64); _dos_setdrive( old, &total ); MouseHidden(); SaveColor=getcolor(); getviewsettings(&TmpViewPort); setviewport(0,0,getmaxx(),getmaxy(),1); WindowGetRealRect(Window,&x,&y,&w,&h); y-=26; len=strlen(dirs); if(len>max_n) { int i; i=len-1; while(dirs[i]!='\\' && dirs[i]!='/' && i>max_n-12) i--; strcpy(dirs,"..."); strcat(dirs,&dirs[i]); } // WaitMessageEmpty(); setfillstyle(1,EGA_LIGHTGRAY); bar(x,y,x+304,y+25); /*--- clear old area --*/ DisplayString(dirs,x,y,EGA_BLACK,EGA_LIGHTGRAY); setviewport(TmpViewPort.left,TmpViewPort.top,TmpViewPort.right, TmpViewPort.bottom,TmpViewPort.clip); setcolor(SaveColor); MouseShow(); #undef max_n } } break; case LISTBOXCONFIRM:{ char dir[20]; char path[40]; hlist = WindowList(Window); strcpy(dir,ListGetItem(hlist,ListGetCurrent(hlist))); strcpy(path,NowOpenFile->drive); strcat(path,dir); chdir(path); #ifdef __TURBOC__ getcurdir(path[0]-'A'+1,NowOpenFile->dirs); #else { unsigned total,old; _dos_getdrive(&old); if(old!=path[0]-'A'+1) _dos_setdrive( path[0]-'A'+1 , &total ); getcwd(NowOpenFile->dirs, 64); memmove(NowOpenFile->dirs,NowOpenFile->dirs+3,61); // cancel "C:\" if(old!=path[0]-'A'+1) _dos_setdrive( old, &total ); } #endif MessageGo(Window,WINDOWINIT,0,0); MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT); ListSetTop(hlist,0); ListSetCurrent(hlist,0); MessageGo(WindowGetFather(Window),DIRCHANGE,0L,0L); } break; default: return(ListBoxDefaultProcedure(Window,Message,Param1,Param2)); } return(TRUE); }