ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • price(가격) Edit
    C++ Builder/사용자 정의 함수 2019. 3. 20. 14:04

    PriceText.zip
    0.01MB

    @TEdit컨트롤의 OnChange이벤트 함수에 소스 추가

    @TEdit컨트롤의 NumbersOnly 속성 True    // ***** TMaskEdit에는 NumbersOnly 속성 없음.*****

     

    //-------------------NumbersOnly기능 코드------------------------------

    //---------------------------------------------------------------------------

    __fastcall TForm1::TForm1(TComponent* Owner)

    : TForm(Owner)

    {

    LONG const dwStyle = GetWindowLong(Edit1->Handle, GWL_STYLE);

    SetWindowLong(Edit1->Handle, GWL_STYLE, dwStyle | ES_NUMBER);

    }

    //---------------------------------------------------------------------------

     

     

    @Edit 컨트롤의 Maxlength속성을 13지정 ( ,  자리값(3)추가 )

     

    //------------------------ 선언.h ------------------------------------------------

    void __fastcall PriceUpToBillian(TEdit *a_Edit);

    //---------------------------------------------------------------------------

    //---------------------------------------------------------------------------

     

     

    //------------------------ 구현.cpp ------------------------------------------------

    void __fastcall TForm1::PriceUpToBillian(TEdit *a_Edit)

    {

    UnicodeString sTemp = "";

    UnicodeString sValue = "";

    TStringList *psList = new TStringList;

    sValue = a_Edit->Text;

    psList->CommaText = sValue;                              // 텍스트를 스트링 리스트에 ","를 구분자로 저장

    if(sValue != ""){ // 텍스트가 ""값이 아닐경우

    for(int i=0; i<psList->Count; i++){ // 스트링 리스트 카운트 만큼 반복

    sTemp += psList->Strings[i]; // 리스트에 저장되어있는 숫자값들을 ,없이 숫자로먼 저장

    }

    if(StrToInt64(sTemp) >= 1000000000){ // 10억이상일경우

    sTemp = sTemp.Insert(",", sTemp.Length()-2); // 지정한위치에 ","삽입

    sTemp = sTemp.Insert(",", sTemp.Length()-6);

    sTemp = sTemp.Insert(",", sTemp.Length()-10);

    }else if(StrToInt64(sTemp) >= 1000000){ // 100만이상일경우

    sTemp = sTemp.Insert(",", sTemp.Length()-2);

    sTemp = sTemp.Insert(",", sTemp.Length()-6);

    }else if(StrToInt64(sTemp) >= 1000){ // 1000이상일경우

    sTemp = sTemp.Insert(",", sTemp.Length()-2);

    }

    }

    a_Edit->Text = sTemp;

    a_Edit->SelStart = sTemp.Length(); // edit의 focus위치를 텍스트 마지막위치로 지정.

     

    delete psList;

    }

    //---------------------------------------------------------------------------

     

    void __fastcall TForm1::Edit1Change(TObject *Sender)

    {

    PriceUpToBillian(Edit1);

    }
    //---------------------------------------------------------------------------
     

    void __fastcall TReceiveF::edCountChange(TObject *Sender)
    {
    if(edUnitPrice->Text != "" && edCount->Text != "" ){
    UnicodeString sTemp = "";
    UnicodeString sValue = "";
    TStringList *psList = new TStringList;
    sValue = edUnitPrice->Text;
    psList->CommaText = sValue;                              // 텍스트를 스트링 리스트에 ","를 구분자로 저장
    if(sValue != ""){  // 텍스트가 ""값이 아닐경우
    for(int i=0; iCount; i++){  // 스트링 리스트 카운트 만큼 반복
    sTemp += psList->Strings[i];  // 리스트에 저장되어있는 숫자값들을 ,없이 숫자로먼 저장
    }
    sValue = StrToInt64(sTemp) * StrToInt64(edCount->Text);            // 9999999999 * 99999999 까지 표현가능
    if(StrToInt64(sValue) >= 1000000000000000){
    sValue = sValue.Insert(",", sValue.Length()-2); // 지정한위치에 ","삽입
    sValue = sValue.Insert(",", sValue.Length()-6);
    sValue = sValue.Insert(",", sValue.Length()-10);
    sValue = sValue.Insert(",", sValue.Length()-14);
    sValue = sValue.Insert(",", sValue.Length()-18);
    }else if(StrToInt64(sValue) >= 1000000000000){
    sValue = sValue.Insert(",", sValue.Length()-2); // 지정한위치에 ","삽입
    sValue = sValue.Insert(",", sValue.Length()-6);
    sValue = sValue.Insert(",", sValue.Length()-10);
    sValue = sValue.Insert(",", sValue.Length()-14);
    }else if(StrToInt64(sValue) >= 1000000000){  // 10억이상일경우
    sValue = sValue.Insert(",", sValue.Length()-2); // 지정한위치에 ","삽입
    sValue = sValue.Insert(",", sValue.Length()-6);
    sValue = sValue.Insert(",", sValue.Length()-10);
    }else if(StrToInt64(sValue) >= 1000000){  // 100만이상일경우
    sValue = sValue.Insert(",", sValue.Length()-2);
    sValue = sValue.Insert(",", sValue.Length()-6);
    }else if(StrToInt64(sValue) >= 1000){  // 1000이상일경우
    sValue = sValue.Insert(",", sValue.Length()-2);
    }
    }
    edSumPrice->Text = sValue;
    }

    }

    728x90

    'C++ Builder > 사용자 정의 함수' 카테고리의 다른 글

    섹션 키값 추출  (0) 2019.01.25

    댓글

Designed by Tistory.