C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[24425] Re:무식한 코딩을 간단히 할수 있는 좋은 방법 없나요?
꼴.Free [kkol] 658 읽음    2003-02-20 21:00
TImage의 배열을 쓰시면 간단할겁니다.


예를 들어 여섯개만 있다고 생각하면..
TImage *pImg[] = { Image1, Image46, Image47, Image39, Image40, Image41};
이렇게 만들고..

for(int i=0; i<6; i++)
{
   if(POld[1][i+5] != P[1][i+5]){
:   if(P[1][i+5] == false)  pImg[i]->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else pImg[i]->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:
}

대충 아시겠죠?
이런식으로하면 처음에 이미지 포인터의 배열 만 만들면 for루프로 간단히 돌릴 수 있습니다.

님의 소스는 for루프 두번 돌리면 될 것 같은데요.함 해보세요. ^^





강영준 님이 쓰신 글 :
: 아래와 같은 무식한 방법을 사용하는데요.. 효과는 좋은데. 좀더 ..
:
: 간단한 방법은 없을까요?
:
: 여러분의 응모를 기다립니다.
:
:
: void __fastcall TForm1::RampOnOff()
: {
:
:   if(POld[1][5] != P[1][5]){
:   if(P[1][5] == false)  Image1->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image1->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][6] != P[1][6]){
:   if(P[1][6] == false)  Image46->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image46->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][7] != P[1][7]){
:   if(P[1][7] == false)  Image47->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image47->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][8] != P[1][8]){
:   if(P[1][8] == false)  Image39->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image39->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][9] != P[1][9]){
:   if(P[1][9] == false)  Image40->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image40->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][10] != P[1][10]){
:   if(P[1][10] == false)  Image41->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image41->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][11] != P[1][11]){
:   if(P[1][11] == false)  Image42->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image42->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][12] != P[1][12]){
:   if(P[1][12] == false)  Image43->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image43->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][13] != P[1][13]){
:   if(P[1][13] == false)  Image44->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image44->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][14] != P[1][14]){
:   if(P[1][14] == false)  Image45->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image45->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[1][15] != P[1][15]){
:   if(P[1][15] == false)  Image30->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image30->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:
:   if(POld[2][0] != P[2][0]){
:   if(P[2][0] == false)  Image31->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image31->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[2][1] != P[2][1]){
:   if(P[2][1] == false)  Image32->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image32->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[2][2] != P[2][2]){
:   if(P[2][2] == false)  Image33->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image33->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[2][3] != P[2][3]){
:   if(P[2][3] == false)  Image34->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image34->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[2][4] != P[2][4]){
:   if(P[2][4] == false)  Image35->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image35->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][5] != P[2][5]){
:   if(P[2][5] == false)  Image36->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image36->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][6] != P[2][6]){
:   if(P[2][6] == false)  Image37->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image37->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][7] != P[2][7]){
:   if(P[2][7] == false)  Image38->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image38->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][8] != P[2][8]){
:   if(P[2][8] == false)  Image2->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image2->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][9] != P[2][9]){
:   if(P[2][9] == false)  Image3->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image3->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][10] != P[2][10]){
:   if(P[2][10] == false)  Image4->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image4->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][11] != P[2][11]){
:   if(P[2][11] == false)  Image5->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image5->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][12] != P[2][12]){
:   if(P[2][12] == false)  Image6->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image6->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[2][13] != P[2][13]){
:   if(P[2][13] == false)  Image7->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image7->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[2][14] != P[2][14]){
:   if(P[2][14] == false)  Image8->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image8->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[2][15] != P[2][15]){
:   if(P[2][15] == false)  Image9->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image9->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:
:   if(POld[3][0] != P[3][0]){
:   if(P[3][0] == false)  Image10->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image10->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[3][1] != P[3][1]){
:   if(P[3][1] == false)  Image11->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image11->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[3][2] != P[3][2]){
:   if(P[3][2] == false)  Image12->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image12->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[3][3] != P[3][3]){
:   if(P[3][3] == false)  Image13->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image13->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");  }
:   if(POld[3][4] != P[3][4]){
:   if(P[3][4] == false)  Image14->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image14->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][5] != P[3][5]){
:   if(P[3][5] == false)  Image17->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image17->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][6] != P[3][6]){
:   if(P[3][6] == false)  Image18->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image18->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][7] != P[3][7]){
:   if(P[3][7] == false)  Image21->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image21->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][8] != P[3][8]){
:   if(P[3][8] == false)  Image22->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image22->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][9] != P[3][9]){
:   if(P[3][9] == false)  Image23->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image23->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][10] != P[3][10]){
:   if(P[3][10] == false)  Image24->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image24->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][11] != P[3][11]){
:   if(P[3][11] == false)  Image25->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image25->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][12] != P[3][12]){
:   if(P[3][12] == false)  Image26->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image26->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][13] != P[3][13]){
:   if(P[3][13] == false)  Image27->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image27->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp"); }
:   if(POld[3][14] != P[3][14]){
:   if(P[3][14] == false)  Image28->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image28->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:   if(POld[3][15] != P[3][15]){
:   if(P[3][15] == false)  Image29->Picture->Bitmap->LoadFromFile(".\\Ramp_Off.bmp");
:      else Image29->Picture->Bitmap->LoadFromFile(".\\Ramp_On.bmp");}
:
:
: }

+ -

관련 글 리스트
24410 무식한 코딩을 간단히 할수 있는 좋은 방법 없나요? 강영준 604 2003/02/20
31931     Re:무식한 코딩을 간단히 할수 있는 좋은 방법 없나요? 김백일.cedar 784 2003/02/20
31930     Re:무식한 코딩을 간단히 할수 있는 좋은 방법 없나요? 김백일.cedar 709 2003/02/20
31929     Re:무식한 코딩을 간단히 할수 있는 좋은 방법 없나요? 하안인 739 2003/02/20
24425     Re:무식한 코딩을 간단히 할수 있는 좋은 방법 없나요? 꼴.Free 658 2003/02/20
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.