Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //InputBoxNumeric (with MaxLength and numbers only)
- //Coded by HEX0x29A
- function InputBoxNumeric(Caption: string; Prompt: string; Default: Integer;
- const MaxLength: Integer = 0): Integer;
- type
- PThreadParam = ^TThreadParam;
- TThreadParam = packed record
- dwLength: DWORD;
- dwParent: DWORD;
- szCaption: string;
- end;
- var
- Param: TThreadParam;
- hThread: DWORD;
- procedure InputBoxThreadProc(Param: Pointer); stdcall;
- var
- wnd, tmp: HWND;
- begin
- wnd := 0;
- repeat
- Application.ProcessMessages;
- tmp := FindWindowW('TInputQueryForm', PWideChar(WideString(PThreadParam(Param).szCaption)));
- if tmp <> 0 then
- begin
- if GetParent(tmp) = PThreadParam(Param).dwParent then
- begin
- wnd := FindWindowEx(tmp, 0, 'TEdit', nil);
- if wnd <> 0 then
- begin
- SendMessage(wnd, EM_LIMITTEXT, PThreadParam(Param).dwLength, 0);
- SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd, GWL_STYLE) or ES_NUMBER);
- end;
- end;
- end;
- until wnd <> 0;
- ExitThread(0);
- end;
- begin
- with Param do
- begin
- dwParent := Application.ActiveFormHandle;
- dwLength := MaxLength;
- szCaption := Caption;
- end;
- CreateThread(nil, 0, @InputBoxThreadProc, @Param, 0, hThread);
- Result := StrToIntDef(InputBox(Caption, Prompt, IntToStr(Default)), 0);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement