Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.10.16;
Скачать: CL | DM;

Вниз

ClsStyle or CS_NOCLOSE doesn t work properly   Найти похожие ветки 

 
thaddy   (2005-02-17 12:02) [0]

form.Clsstyle:=form.Clsstyle + CS_NOCLOSE;

This code should disable the close button on the titlebar (and it does),
but it also should remove close from the system menu: It doesn"t.
Furthermore, there"s a huge repaint bug when I try to do this.

Does anyone have a solution other than overriding CreateParams? (that does work, but breaks the pure Tcontrol).
Is this a bug?


 
ECM ©   (2005-02-17 12:19) [1]

DeleteMenu( GetSystemMenu(Form.GetWindowHandle, False ), SC_CLOSE, MF_BYCOMMAND ); не устраивает?
Меню исчезает... Или я не верно понял?
Надо чтобы не исчезало? (становилось "серым" например)


 
thaddy   (2005-02-17 12:28) [2]

No, according to the API documentation, the clstyle CS_NOCLOSE should remove the menu entry enirely, just like your code can do, and it also grays out the cross. The VCL behaves correctly, Plain API program behaves correctly, KOL doesn't :/ unless I override Createparams (which is what I did with the VCL versiob, to be fair)


 
ECM ©   (2005-02-17 13:03) [3]

Да, в этом случае проблема имеет место...:(
VCL - это не показатель - там окно "тупо" пересоздается (ИМХО...), а это часто неудобно - при этом изменяется HWND.
А как в "Plain API program" устанавливался CS_NOCLOSE?
Через SetClassLong?


 
ECM ©   (2005-02-17 13:54) [4]

EnableMenuItem( GetSystemMenu( Form.GetWindowHandle, FALSE), SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
Это конечно не совсем то, что требовалось, но выглядит логичнее - и меню и кнопка становятся серыми и не реагируют на нажатие... :)


 
thaddy   (2005-02-17 15:47) [5]

I have tested all exactly like eachother. VCL and KOL behave the same in all cases. So I have to do it with your advice, or use my koldetour library to patch in a new CreateParams ;) In that case I do not have to override Tcontrol.
Tnx!


 
ECM ©   (2005-02-17 16:26) [6]

IMHO: CS_NOCLOSE - срабатывает только при создании окна ...:(


 
thaddy   (2005-02-17 17:10) [7]

type

PHack = ^Tcontrol;

then:

 destroywindow(form.getwindowhandle;
 PHack(form).fhandle:=0;
 form.clsStyle:=form.ClsStyle or CS_NOCLOSE;
 form.Createwindow; // or form.getwindowhandle;

This does what I wanted. Pity about the hack but it works as in API.

If you add Closequeryhandler, you have "uncloseable form", only task manager can close it. That was what I wanted.


 
thaddy   (2005-02-17 17:12) [8]

Ofcourse:
type
 PHack = ^THack;
 THack = object(TControl)end;


 
thaddy   (2005-02-17 17:27) [9]

// Maybe good utility routine for KOL.pas:
// hack not becessary if included in kol.pas
// maybe even in Tcontrol? like VCL recreatewindow?
// Are more uses than what I wanted.

type
 PHack = ^THack;
 THack = object(TControl)end;

procedure ReCreateWindow(aControl:PControl);
begin
DestroyWindow(aControl.Getwindowhandle);
PHack(aControl).fHandle:=0;
aControl.CreateWindow;
end;



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

Текущий архив: 2005.10.16;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.049 c
3-1125497727
Dmitrich
2005-08-31 18:15
2005.10.16
Почему БД (interBase 6.0) не работает с диска?


3-1125572079
Term
2005-09-01 14:54
2005.10.16
Проблема с UNION


4-1124185150
BPK
2005-08-16 13:39
2005.10.16
Возврат значения через сообщение


1-1127739413
MakedoneZ
2005-09-26 16:56
2005.10.16
Работа с реестром,запуск проги при старте OC


6-1119465288
bugman
2005-06-22 22:34
2005.10.16
UDP Redirect, port mapping, TidMappedPortUDP