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

Вниз

Немодальная форма и Shortcuts в главной форме   Найти похожие ветки 

 
Sir Alex   (2004-01-25 02:19) [0]

В главной форме есть меню (главное и контексные) с назначенными shortcuts. Создаю немодальную форму. Находясь в этой форме при нажатии любой shortcut кнопки от главного окна она почему-то срабатывает, хотя ее никто и не просил...

Т.е. как отключить shortcuts главной формы, когда я нахожусь в немодальной?


 
Sir Alex   (2004-01-25 03:56) [1]

Вот и ответ:

Solution / workaround
By Ray Lischner
You can set a message hook for the main form, to intercept these messages, and prevent them from reaching the main form. That lets the child form handle the keyboard events normally.
To set the hook, read about TApplication.HookMainWindow in the on-line documentation. Unfortunately, the Cm_AppKeyDown and Cm_AppSysCommand messages are not documented (Note: They are documented in Ray Lischner"s book "Secrets of Delphi 2"). To handle these messages, the hook function returns True, saying that the message has been handled, but the handler leaves the message Result as 0, which tells the child form to continue processing the message normally.
For example:


function TMainForm.AppKeyDownHook(var Msg: TMessage): Boolean;
begin
case Msg.Msg of
Cm_AppkeyDown:
Result := True; { test here whether to act locally }
Cm_AppSysCommand:
Result := True; { test here whether to act locally }
else
Result := False; { event will go to the parent"s main menu }
end;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.HookMainWindow(AppKeyDownHook)
end;



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

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

Наверх





Память: 0.44 MB
Время: 0.025 c
14-16615
InBass Project
2004-01-08 08:29
2004.02.06
Вот такого я от себя не ожидал...


3-16175
NewD
2004-01-14 07:03
2004.02.06
Отчет по шаблону в MS WORD


14-16634
Piter
2004-01-13 23:18
2004.02.06
NOD32 Antivirus System


4-16814
_san_
2003-11-28 14:13
2004.02.06
Вывод сообщений из tray


7-16761
AndriyS
2003-11-17 15:27
2004.02.06
getvolumeinformation





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский