English
Forum

zulässige input in the num. Edit steer

 

Thomas
Freier
with one middle-aged code be I do not right happy. has of/ one of you something better or a idea?
my Hauptproblem was thereby, that if the Content by "BackSpace" deleted becomes, no point to whom pretended characters to the point (=Komma) More staid becomes.
Def GetSysColor(1) !"USER32","GetSysColor"
cls GetSysColor(15)
UseFont "Arial",15,0,0,0,0
SETDIALOGFONT 1
CreateText(%hwnd,"num. input max.: nn.nn",30,120,200,22)
var Ed&=Create("Edit",%hwnd,"",30,165,80,20)
@sendmessage(Ed&,$00C5,5,0)'and on 5 to put (nn.nn) terminable
SetFocus(Ed&)

While 1

    WaitInput
    case %key=2 : BREAK
    case GETFOCUS(Ed&): NUMWERT Ed&,2'lever, characters before the comma

EndWhile

End

Proc NUMWERT' AUSWERTUNG on characters and to put

    Parameters ED.N&,ED.n%
    var a$="abcdefghijklmnopqrstuvwxyz"
    a$=a$+Upper $("abcdefghijklmnopqrstuvwxyz")
    a$=a$+"!§$%&/()=?''*':;,-_²³{[]}\^°<>|++-"
    var c$=""

    WhileLoop len(a$)

        c$ = MID$(a$,&Loop,1)' c$= the nte Stringteil
        Settext ED.N&,@Translate$(gettext$(ED.N&),c$,"")' unzulässige delete
        Settext ED.N&,@Translate$(gettext$(ED.N&),"..",".")' double delete

    EndWhile

    a$=trim$(gettext$(ED.N&))

    WhileLoop ED.n%+1

        @Match $("~.", a$)

        If (%MatchPos>0) AND (%MatchPos<ED.n%+1)

            a$="0"+a$

        EndIf

    EndWhile

    If len(a$)=ED.n%

        casenot @IsKey(8):a$=left$(a$,ED.n%)+"."

    EndIf

    SetText ED.N&,a$
    sendmessage(ED.N&,$00B1,len(gettext$(ED.N&)),len(gettext$(ED.N&))+1)'Cursor ans end
    SetFocus(ED.N&)

ENDPROC

 
Gruß Thomas
Windows XP SP2, XProfan X2
06/10/11  
 



Perhaps. about something like:
var erlaubteZeichen$="abcdefghijklmnopqrstuvwxyz"+Upper $("abcdefghijklmnopqrstuvwxyz")+"!§$%&/()=?''*':;,-_²³{[]}\\^°<>|++-"
Def GetSysColor(1) !"USER32","GetSysColor"
cls GetSysColor(15)
UseFont "Arial",15,0,0,0,0
SETDIALOGFONT 1
var nix&=CreateText(%hwnd,"num. input max.: nn.nn",30,120,200,22)
var Ed&=Create("Edit",%hwnd,"",30,165,80,20)
SetFocus(Ed&)
subclass ed&,1//true

While 1

    WaitInput
    case %key=2 : BREAK

EndWhile

End

subClassProc

    if &sWnd=ed&

        if %sMessage=258//wm_char

            var p&=hiWord(sendMessage(ed&,$B0,0,0))//em_getSel
            var s$=getText$(ed&)
            var ch$=chr $(&swParam)

            ifnot instr(ch$,erlaubteZeichen$)

                if &swParam=8

                    if p&

                        if p&=3

                            s$=del$(s$,p&,1)
                            dec p&,1

                        endif

                        s$=del$(s$,p&,1)
                        dec p&,1

                    endif

                endif

                s$=translate $(s$,".","")
                case len(s$)>1 : s$=in that$(".",s$,3)
                setText ed&,s$
                sendMessage(ed&,$B1,p&,p&)//em_setSel

            else

                s$=in that$(ch$,s$,p&+1)
                s$=translate $(s$,".","")
                case len(s$)>1 : s$=in that$(".",s$,3)
                s$=mid$(s$,1,5)
                setText ed&,s$
                case p&=1 : add p&,1
                sendMessage(ed&,$B1,p&+1,p&+1)//em_setSel

            endif

            set("winproc",0)

        endif

    endif

endProc

 
06/10/11  
 




Thomas
Freier
@iF, one SubClassProc wished I of course not take. in the momentum can I with your Script no numbers prompt. Error have I not yet sought. moreover should führende nobodies complement go. otherwise can More Nachkommastellen as permitted association go or it must each times the zulässige Number of characters according to Kommalage adjusted go. Z.B.:
zul. nnnn.nn = 7 -> Eingabewert= 1.22 -> to the last 2 must no further input More possible his. now means only yet max. 4 characters.
and How siehts with unterschiedlichen Edits from?

PS. Error is at Zulässigen, that must in your Script naturally go: var erlaubteZeichen$="1234567890" .
 
Gruß Thomas
Windows XP SP2, XProfan X2
06/10/11  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

3.095 Views

Untitledvor 0 min.
GC5708/04/16
Ernst06/13/16
rquindt02/21/16
Rainer Hoefs06/30/15
More...

Themeninformationen

this Topic has 2 subscriber:

Thomas Freier (2x)
iF (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie