Basit bir dikdörtgen çizecek TGraphicControl dalında component oluşturdum.
type
TMyRect=class(TGraphicControl)
published
property OnClick;
property OnMouseDown;
property ONMouseUp;
property OnDragDrop;
property OnDragOver;
property OnEndDrag; tanımlı
formda bu componenti kullanabiliyorum. componenti sürükleyebilmek için OnMouseDown olayına
ReleaseCapture;
MyRect1.Perform(WM_SYSCOMMAND, $F012, 0); yazmama rağmen programı derledikten sonra componenti sürükleyemiyorum. tanımladığım olaylara kod yazmadığım için mi oluyor bu?
hazırladığım componenti sürükleyemiyorum
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
- fatihtolgaata
- Üye
- Mesajlar: 382
- Kayıt: 04 Mar 2004 09:46
- Konum: K.çekmece / İstanbul
- İletişim:
Sürükleyebilmek için Handle'ı olan bir sınıftan türetmen lazım. TControl sınıf iki dala ayrılır. Biri TGraphicControl diğeri TWinControl. TWinControl'da handle, parent gibi özelliklere sahiptir. Ama TGraphicControlda bu mevcut değildir. Yani tam manasıyla bir windows nesnesi sayılmazlar. Buna handle gibi özellikler eklemek için çok uğraşman lazım. Buna gerek yok. TGraphicControl yerine TWinControl'ü dene. (Not: TImage da GraphicControl olduğundan onu da bu şekilde sürükleymezsin.)
delphi 6 helpinden alıntıdır.
Once you derive a component type, you can decide which of the properties and events declared in the protected parts of the ancestor class you want to surface in the new component. TGraphicControl already publishes all the properties that enable the component to function as a control, so all you need to publish is the ability to respond to mouse events and handle drag-and-drop.
Publishing inherited properties and events is explained in Publishing inherited properties and Making events visible. Both processes involve redeclaring just the name of the properties in the published part of the class declaration.
For the shape control, you can publish the three mouse events, the three drag-and-drop events, and the two drag-and-drop properties:
type
TSampleShape = class(TGraphicControl)
published
property DragCursor; { drag-and-drop properties }
property DragMode;
property OnDragDrop; { drag-and-drop events }
property OnDragOver;
property OnEndDrag;
property OnMouseDown; { mouse events }
property OnMouseMove;
property OnMouseUp;
end;
The sample shape control now makes mouse and drag-and-drop interactions available to its users.
bu doğru değil o zaman!
Once you derive a component type, you can decide which of the properties and events declared in the protected parts of the ancestor class you want to surface in the new component. TGraphicControl already publishes all the properties that enable the component to function as a control, so all you need to publish is the ability to respond to mouse events and handle drag-and-drop.
Publishing inherited properties and events is explained in Publishing inherited properties and Making events visible. Both processes involve redeclaring just the name of the properties in the published part of the class declaration.
For the shape control, you can publish the three mouse events, the three drag-and-drop events, and the two drag-and-drop properties:
type
TSampleShape = class(TGraphicControl)
published
property DragCursor; { drag-and-drop properties }
property DragMode;
property OnDragDrop; { drag-and-drop events }
property OnDragOver;
property OnEndDrag;
property OnMouseDown; { mouse events }
property OnMouseMove;
property OnMouseUp;
end;
The sample shape control now makes mouse and drag-and-drop interactions available to its users.
bu doğru değil o zaman!
nesneyi form üzerinde hareket ettirmek istiyorum.
birde şu sorunla karşılaştım. oluşturduğum nesneyi tasarım anında form üzerinde koyarsam kullanabiliyorum. aça çallışma sırasında oluşturmak istediğimde nesne oluşuyor (aynı nesneden ismini bilerek değiştirmiyorum tekrar oluşturmak istiyorum derleyici 'bu isimde nesne var' diyehata mesajı veriyor) fakat form üzerinde görünmüyor. neden olduğunu anlayamadım.
birde şu sorunla karşılaştım. oluşturduğum nesneyi tasarım anında form üzerinde koyarsam kullanabiliyorum. aça çallışma sırasında oluşturmak istediğimde nesne oluşuyor (aynı nesneden ismini bilerek değiştirmiyorum tekrar oluşturmak istiyorum derleyici 'bu isimde nesne var' diyehata mesajı veriyor) fakat form üzerinde görünmüyor. neden olduğunu anlayamadım.
görünmemesinin nedeni parent atanmamış olmaması olabilir.
gibi..
Kod: Tümünü seç
....
....
nesne.Parent := Form1;
.....
- fatihtolgaata
- Üye
- Mesajlar: 382
- Kayıt: 04 Mar 2004 09:46
- Konum: K.çekmece / İstanbul
- İletişim:
kardeşim Drag drop ayrı, window move ayrı şeyler. Sen WM_SYSCOMMAND mesajı na wParam olarak $F012 gönderdiğinde drag drop değil, window move yaptırırsın. Haliyle handle olmayan bir şeyi de bu şekilde sürükleyemezsin. Eğer illaki graphic controlü kullanacaksan, Drag Object'den yararlanacaksın ki, bu senin istediğini tam karşılar mı bilmem.