Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » fill date bars automatically
fill date bars automatically [message #56846] Tue, 20 April 2021 05:53 Go to next message
BetoValle is currently offline  BetoValle
Messages: 202
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,
Does the EditDate field have any settings to automatically fill in the date bars? / /

Thanks
Re: fill date bars automatically [message #56858 is a reply to message #56846] Wed, 21 April 2021 20:25 Go to previous message
BetoValle is currently offline  BetoValle
Messages: 202
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,
I did this routine and it works in my country with a formatted date. Of course, the code needs to be optimized, but it works.

...
    SetLanguage ( "pt-br" );
    SetDateFormat("%3:02d/%2:02d/%1:4d");            // dd/mm/aaaa
    SetDateScan("dmy");	
...    

boolean rotinaData(dword key, EditField* cpo)
{
   if(cpo->HasFocus()){ 
     String x = GetKeyDesc(key);
     String s = GetKeyDesc(key & ~K_KEYUP);
     
     int L=cpo->GetText().GetLength();
     
     LOG(" conteudo " << s << " comprimento " << L << EOL );
     if( s.IsEqual("Backspace") || s.IsEqual("Delete") || s.IsEqual("Enter") || s.IsEqual("Tab") 
     ||  s.IsEqual("Home") || s.IsEqual("Left") || s.IsEqual("Right") || s.IsEqual("End") 
     ){
       return true;   
     }
     
     int i=cpo->GetText().ToString().Find("//");
     if(i>-1){ //remove uma barra
       s=cpo->GetText().ToString();
       s.Remove(i);
       cpo->SetText(s);
       cpo->SetSelection(i+1);
       return true;  
     }

     char c =s[0]; //converte String para char
     if( (int)c>=48 && (int)c<=57  ){  //numero decimal dos caracteres de 0 a 9 
       
     }else{
        i=s.Find("Num");
        if(i==-1){
           cpo->Key(K_BACKSPACE,1);
           return true;
        }
     }

     if(L==4){
        s=cpo->GetText().ToString();
        String v="";
        if(s.Mid ( 3, 1 ).IsEqual("/") ){
           v=s.Mid(0,3); 
        }else{
           if(s.Mid(3,1).IsEqual("0") || s.Mid(3,1).IsEqual("1")) 
				v=s.Mid(0,4);  
           
           else
              	v=s.Mid(0,3); 
        }
        cpo->SetText( v );
        cpo->SetSelection(5);
        return true;
     }
     if (L==5) {
        s=cpo->GetText().ToString();
        String v="";
        if(s.Mid ( 4, 1 ).IsEqual("/") ){
           v=s.Mid(0,4); 
        }else{
           int n = StrInt( s.Mid(3,2) );
           if((n>0)&&(n<=12))
              v=cpo->GetText().ToString()+"/"; 
           else   
              v=s.Mid(0,4);
        }
        cpo->SetText( v );
        cpo->SetSelection(6);
        return true;
     }
     
     if(L==2){
        s=cpo->GetText().ToString();
        String v="";
        if(s.Mid ( 3, 1 ).IsEqual("/") ){
           v=s.Mid(0,2); 
        }else{
           int n = StrInt( s.Mid(0,2) );
           if(n<=31)
              v=cpo->GetText().ToString()+"/"; 
           else   
              v=s.Mid(0,1);
        }
        cpo->SetText( v );
        cpo->SetSelection(3);
        return true;
     }
     
     if(L==1){
        s=cpo->GetText().ToString();
        String v="";
        if(s.Mid ( 0, 1 ).IsEqual("/") ){
           v=""; 
        }else{
           int n = StrInt( s.Mid(0,1) );
           if(n<=3)
              v=cpo->GetText().ToString(); 
           else   
              v="";
        }
        cpo->SetText( v );
        cpo->SetSelection(3);
        return true;
     }
   
     i=s.Find("Num ");
     if(i>-1){
         s.Remove(i,4);
	     char c =s[0]; //converte String para char
	     if( (int)c>=48 && (int)c<=57  ){  //numero decimal dos caracteres de 0 a 9 
	       return true;
	     }else{
           if(s.Find("[/]")>-1)
             cpo->Key(K_BACKSPACE,3);
           else
             cpo->Key(K_BACKSPACE,1);
	     }
        return true;  
     }else{
           i=s.Find("Num[/]");
           if(i>-1){
           } else{
 			 cpo->Key(K_BACKSPACE,1);
           }
     }
         
     return true;
   }

   return false;	
}

bool AA::Key(dword key, int count) // from virtual bool Key(dword key, int count);  
{   
   
   if(rotinaData(key,&dt))
       return false;
     
     
   
   return false;
}
   


Thanks!

Previous Topic: double-click in EditField
Next Topic: [BUG] LineEdit text renderer fails to correctly highlight underlined text .
Goto Forum:
  


Current Time: Fri Mar 29 06:17:51 CET 2024

Total time taken to generate the page: 0.01497 seconds