TScrollBar 中間那顆按鈕 還有左右的箭頭按鈕 會被lock住 |
缺席
|
miyada
一般會員 發表:6 回覆:7 積分:2 註冊:2008-11-02 發送簡訊給我 |
各位先進 大家好
有兩個問題 1.使用了TScrollBar 發現當我對中間那顆按鈕 或是 左右兩顆箭頭按鈕,持續滑鼠左鍵一直按著後 然後移開後 再把滑鼠移到箭頭按鈕上 不用按下左鍵喔 就會自己跑ScrollBar1->Position 2.我想利用ScrollBar1Scroll 或是ScrollBar1Change來slide 圖 但是 發現 當bar滑太快 或是箭頭按鍵 按太快,會發現CPU資源都被秀圖到image吃掉,如果有,玩過firefox的Cooliris就應該會知道我說的slide 圖片是啥回事 我把程式碼po上來,請先進幫我看一下,為啥我按太快 或是滑太快,CPU會被吃掉 我是先把圖存於odd even兩個資料夾,在slide時分別去load這兩個資料夾的image進來show在image元件上 image有上下兩排 每排11個元件 Image1~Image11 Image12~Image22 這兩個問題困擾我很久了 請先進們幫我看一下 謝謝 [code cpp] void __fastcall TForm2::ScrollBar1Change(TObject *Sender) { int oddDifference = 0, evenDifference = 0,oddDirFileAmount,evenDirFileAmount; AnsiString oddDir="D:\\BCB Code\\Jpg\\odd\\"; AnsiString evenDir="D:\\BCB Code\\Jpg\\even"; TSearchRec SearchOddRec,SearchEvenRec; int iAttr=faAnyFile,oddIFound,evenIFound,oddCount,evenCount; AnsiString fileName = "", newFilePath = "",szOddFile = "",szEvenFile = ""; int imageExistInReprot = 0; //ActiveControl = NULL; //控制bar上的那塊閃不閃爍 EdiScbValue->Text = IntToStr(ScrollBar1->Position); oddDirFileAmount = 0, oddCount = 0; evenDirFileAmount = 0, evenCount = 0; //Get the amount pictures from odd directory GetFileAmountInSpecifirdDir(oddDir,(int*)&oddDirFileAmount); oddDifference = oddDirFileAmount- (ScrollBar1->Position-1); //Get the amount pictures from even directory GetFileAmountInSpecifirdDir(evenDir,(int*)&evenDirFileAmount); evenDifference = evenDirFileAmount- (ScrollBar1->Position-1); if(oddDifference <= 0 || evenDifference <= 0) { for(int i=1;i<=11;i ) { ((TEdit *)FindComponent("Edit" IntToStr(i)))->Text = ""; ((TEdit *)FindComponent("Edit" IntToStr(i)))->Color = clWhite; ((TImage *)FindComponent("Image" IntToStr(i)))->Picture = NULL; ((TEdit *)FindComponent("Edit" IntToStr(i 11)))->Text = ""; ((TEdit *)FindComponent("Edit" IntToStr(i 11)))->Color = clWhite; ((TImage *)FindComponent("Image" IntToStr(i 11)))->Picture = NULL; } return; } if(oddDifference<=11 ) //if the oddDifference is less than 11 image components { //clear the contents of difference components for(int i=oddDifference;i<=11;i ) { ((TEdit *)FindComponent("Edit" IntToStr(i)))->Text = ""; ((TEdit *)FindComponent("Edit" IntToStr(i)))->Color = clWhite; ((TImage *)FindComponent("Image" IntToStr(i)))->Picture = NULL; } } if(evenDifference<=11)//if the evenDifference is less than 11 image components { //clear the contents of difference components for(int i=evenDifference;i<=11;i ) { ((TEdit *)FindComponent("Edit" IntToStr(i 11)))->Text = ""; ((TEdit *)FindComponent("Edit" IntToStr(i 11)))->Color = clWhite; ((TImage *)FindComponent("Image" IntToStr(i 11)))->Picture = NULL; } } if(!DirectoryExists(oddDir)||!DirectoryExists(evenDir)) //check the odd/even directory exists or not return; if( oddDir.SubString(oddDir.Length(),1) != "\\" ) oddDir=oddDir "\\"; if( evenDir.SubString(evenDir.Length(),1) != "\\" ) evenDir=evenDir "\\"; oddIFound=FindFirst(oddDir "*.*", iAttr, SearchOddRec); evenIFound=FindFirst(evenDir "*.*", iAttr, SearchEvenRec); while(oddIFound==0 || evenIFound==0) { if((SearchOddRec.Attr!=faDirectory) && (oddCount if((oddCount-(ScrollBar1->Position))>=11) { oddIFound = 1; evenIFound = 1; return ; } if((oddCount oddCount ; else { szOddFile = oddDir (AnsiString)SearchOddRec.Name; fileName = szOddFile.SubString(szOddFile.LastDelimiter("\\") 1,szOddFile.Length()); if(fileName != "Thumbs.db") { newFilePath = oddDir fileName; ((TImage *)FindComponent("Image" IntToStr(oddCount-(ScrollBar1->Position-1))))->Picture->LoadFromFile(newFilePath) ; ((TEdit *)FindComponent("Edit" IntToStr(oddCount-(ScrollBar1->Position-1))))->Text = fileName; oddCount ; } } }if(SearchOddRec.Attr!=faDirectory) if((SearchEvenRec.Attr!=faDirectory) && (evenCount if((evenCount-(ScrollBar1->Position))>=11) { oddIFound = 1; evenIFound = 1; return ; } if(evenCount evenCount ; else { szEvenFile=evenDir (AnsiString)SearchEvenRec.Name; fileName = szEvenFile.SubString(szEvenFile.LastDelimiter("\\") 1,szEvenFile.Length()); if(fileName != "Thumbs.db") { newFilePath = evenDir fileName; ((TImage *)FindComponent("Image" IntToStr(evenCount-(ScrollBar1->Position-1) 11)))->Picture->LoadFromFile(newFilePath) ; ((TEdit *)FindComponent("Edit" IntToStr(evenCount-(ScrollBar1->Position-1) 11)))->Text = fileName; evenCount ; } } }//if(SearchEvenRec.Attr!=faDirectory) oddIFound=FindNext(SearchOddRec); evenIFound=FindNext(SearchEvenRec); Application->ProcessMessages(); } FindClose(SearchOddRec); FindClose(SearchEvenRec); }
------
大家心地都很好 一起來學習吧 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |