Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //InputQueryEx (with MaxLength)
- //Coded by HEX0x29A
- function InputQueryEx(Caption: string; Prompt: string;
- var Value: string; MaxLength: integer): Boolean;
- type
- PThreadParam = ^TThreadParam;
- TThreadParam = packed record
- dwLength : DWORD;
- dwParent : DWORD;
- szCaption: string;
- end;
- var
- Param : TThreadParam;
- hThread: DWORD;
- procedure InputQueryThreadProc(Param: Pointer); stdcall;
- var
- wnd, tmp: HWND;
- begin
- wnd := 0;
- repeat
- Application.ProcessMessages;
- tmp := FindWindow('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);
- 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, @InputQueryThreadProc, @Param, 0, hThread);
- Result := InputQuery(Caption, Prompt, Value);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement