Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Система";
Текущий архив: 2002.04.15;
Скачать: [xml.tar.bz2];

Вниз

API, System resources and ******* (inside)   Найти похожие ветки 

 
Fellomena   (2002-01-18 14:06) [0]

Привет всем !
В своей программе понадобилось сделать примитивную ф-ию для проверки пароля.
Т.е. в программе что-то типа:
if PassTest() then ...;
Я пыталась сначала использовать InputQuery, думала послать окну ввода текста через API команду, что бы при вводе пароля были видны *****
НО, если мой SendMessage вызывается из того же потока, что и InputQuery, то естественно ничего подобного не происходит, т.к. InputQuery модально и программа (вернее поток в котором был сделан вызов InputQuery) ждёт результата.
Создавай отдельный поток, что бы из него посылать сообщение не хочется, динамически создавать такое окошко с нужными параметрами тоже не хочется, это ресурсы пожрёт.
В SDK не нашла способа создавать окно ввода пароля.

Есть идеи как реализовать **** с наименьшими затратами (min прирост к exe файлу и min занимаемого адрессного пространства) ?
Вернее, - какой из способов "дешевле" ?


 
Serghei   (2002-01-18 14:42) [1]

TPasswordDlg не подходит?


 
Serghei   (2002-01-18 14:51) [2]

Может это поможет

{
For example, we have some dialog for confirmation
and the user can check a checkbox ("Don"t show this
message again") - program can store this in a global
variable and the next time this dialog will not show.

The idea of realization in the next:
1. we must create a dialog using
CreateMessageDialog
2. this function will return a form object with
dialog
3. in this object we can add a checkbox
4. show diallog using ShowModal
5. check a result and process a state of our
checkbox
6. destroy a created checkbox and dialog object
}

procedure TForm1.Button1Click(Sender: TObject);
var
AMsgDialog: TForm;
ACheckBox: TCheckBox;
begin
AMsgDialog := CreateMessageDialog
("This is a test message.", mtWarning,
[mbYes, mbNo]);
ACheckBox := TCheckBox.Create(AMsgDialog);
with AMsgDialog do
try
Caption := "Dialog Title" ;
Height := 169;

with ACheckBox do begin
Parent := AMsgDialog;
Caption := "Don""t show me again.";
Top := 121;
Left := 8;
end;

if (ShowModal = ID_YES) then begin
if ACheckBox.Checked then begin
//... do if checked
end;
//... do if NOT checked
end;
finally
ACheckBox.Free;
Free;
end;
end;




 
VuDZ   (2002-01-18 18:48) [3]

если не правильно понял - сорри:
любоиу окну ввода (EDIT) можно послать мессагу EM_SETPASSWORDCHAR
MSDN:
EM_SETPASSWORDCHAR
The EM_SETPASSWORDCHAR message sets or removes the password character for an edit control. When a password character is set, that character is displayed in place of the characters typed by the user. You can send this message to either an edit control or a rich edit control.

To send this message, call the SendMessage function with the following parameters.

SendMessage(
(HWND) hWnd, // handle to destination window
EM_SETPASSWORDCHAR, // message to send
(WPARAM) wParam, // character
(LPARAM) lParam // not used; must be zero
);
Parameters
wParam
Specifies the character to be displayed in place of the characters typed by the user. If this parameter is zero, the control removes the current password character and displays the characters typed by the user.
lParam
This parameter is not used.
Return Values
This message does not return a value.

Remarks
When an edit control receives the EM_SETPASSWORDCHAR message, the control redraws all visible characters using the character specified by the wParam parameter. If wParam is zero, the control redraws all visible characters using the characters typed by the user.

If an edit control is created with the ES_PASSWORD style, the default password character is set to an asterisk (*). If an edit control is created without the ES_PASSWORD style, there is no password character. The ES_PASSWORD style is removed if an EM_SETPASSWORDCHAR message is sent with the wParam parameter set to zero.

Edit controls: Multiline edit controls do not support the password style or messages.

Rich Edit: Both single-line and multiline edit controls support the password style and messages. For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.

или я проглючил с пива, незабвенная?



 
Валерий Д   (2002-01-21 03:34) [4]

А не проще ли создать свое окошко с TEDit, у которого свойство (если не ошибаюсь) PasswordChar установить в * или любой другой на выбор?


 
Fellomena   (2002-01-21 11:41) [5]

ok: спасибо всем !

2 VuDZ: либо я непонятно формулирую, либо это всё пиво... ;)
То что EM_SETPASSWORDCHAR надо эдиту посылать - я сама прочитала, но я же написала, что посылать надо откуда-то, но не из потока, вызвавшего InputQuary 8)
Сам попробуй 8)

В итоге пришлось-таки делать свою формочку с Edit-ом и динамически создавать её при необходимости, затем уничтожая.




Страницы: 1 вся ветка

Форум: "Система";
Текущий архив: 2002.04.15;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.004 c
7-46527
Fellomena
2002-01-18 14:06
2002.04.15
API, System resources and ******* (inside)


1-46453
P.
2002-04-03 12:28
2002.04.15
MouseMove


14-46482
_Oleg
2002-03-06 00:02
2002.04.15
COM-port


4-46552
SuperBizon
2002-02-13 16:38
2002.04.15
Event log


4-46542
slym
2002-02-12 17:23
2002.04.15
Как из массива байтов сделать битмап?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский