Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Create an Editbox to Accept Formatted Data
;editbox digits only ;WB 2001+ required ;api functions ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ;EditBox ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ;id : control id ; ;x : pixels from left of parent window ; ;y : pixels from top of parent window ; ;width : width in pixels ; ;height : height in pixels ; ;style : window & control style ; ;Returns: control handle ; ;ExStyle: WS_EX_CLIENTEDGE ; ;Style : WS_CHILD, WS_VISIBLE, WS_TABSTOP ; ;Returns: control handle ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; #DefineFunction Edit(id, x, y, Width, Height, style) hWndParent = DLLhWnd("") hInstance = DLLhInst("") sDLLName = StrCat(DirWindows(1), "User32.DLL") hedit = DLLCall(sDLLName,long:"CreateWindowExA",long:512,lpstr:"Edit",long:0,long:1073741824 | 268435456 | 65536 | style,long:x,long:y,long:Width,long:Height,long:hWndParent,long:Id,long:hInstance,long:0) Return hedit #EndFunction ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ;GetWindowText : The GetWindowText function copies the text of the specified ; ; window’s title bar (if it has one) into a buffer. ; ; If the specified window is a control, the text of the control ; ; is copied. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ;hwnd : Identifies the window or control containing the text. ; ;buf : Points to the buffer that will receive the text. ; ;read : Specifies the maximum number of characters to copy to the buffer. ; ;Returns : If the function succeeds, the return value is the length, ; ; in characters, of the copied string. ; ; If the window has no title bar or text, if the title bar is empty, ; ; or if the window or control handle is invalid, the return value is zero; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; #DefineFunction GetWindowText(hwnd, buf, read) sDLLName = StrCat(DirWindows(1), "user32.dll") rslt = DLLCall(sDLLName, long:"GetWindowTextA", long:hwnd, lpbinary:buf, long:read) Return rslt #EndFunction ;api constants ES_NUMBER = 8192 EM_LIMITTEXT = 197 ;edit control, allow only digits hedit = Edit(1, 20, 20, 50, 24, ES_NUMBER) ;limit text to 3 characters intcontrol(22, hedit, EM_LIMITTEXT, 3, 0) ;show box boxopen("Digits only", "%@crlf%%@crlf%%@crlf%%@crlf%CTRL to finish.") ;wait for key while 1 if iskeydown(@ctrl) then break endwhile ;get text strbuf = binaryalloc(10) GetWindowText(hedit, strbuf, 10) binaryeodset(strbuf, 10) str = binarypeekstr(strbuf, 0, 10) binaryfree(strbuf) boxdestroy(1) message("Edit:", str)
Article ID: W15508
File Created: 2003:05:13:11:28:26
Last Updated: 2003:05:13:11:28:26