Class of …… | Delphi Programming

Transkript

Class of …… | Delphi Programming
Contact Me | Subscribe
D e l p h i
P r o g r a m m i n g
Search Keywords
There are only 10 types of people in the world: Those who understand binary, and those
who don’t.
Home
TObject.Create
Delphi
Hakkında
Ziyaretçi Defteri
Posted by Tuğrul HELVACI - Mayıs 15, 2009 Comments 0
Class of ……
Interface’lerla ilgili örneğim de TRadioGroup nesnesi üzerinden yapılan bir seçimle çeşit çeşit
veritabanına bağlanıyorduk.Bu benim aklıma başka bir şey daha getirdi.Onu da sizlerle
paylaşmak istedim. Bazen çalışma anında(run-time) bazı nesnelerin üretilmesi kullanıcının
yapacağı seçime bağlı olur. Hemen somut bir örnek verelim. Mesela TRadioGroup nesnemizde
üç seçenek olsun, kullanıcı birinciyi seçerse bir adet TMemo oluşturmamız, ikinciyi seçerse
TEdit ve üçüncüyü seçerse de TPanel oluşturmamız gereksin. Bu durum şimdiye kadar
başınıza gelmedi ise bundan sonra gelmesi kuvvetle muhtemel bir durumdur. Eee bu durumda
ne yapacağız ? Şöyle bir şey yapsak olur mu acaba :
01.
02.
03.
04.
05.
06.
07.
08.
var
mem : TMemo;
edt : TEdit;
pnl : TPanel;
begin
case RadioGroup.ItemIndex of
0 :
begin
Plugin WP FlashTime by horoscop 2009.org
requires Flash Player 8 or better currency
converter calculator.Plugin creat de horoscop |
horoscop saptamanal | horoscop zilic | horoscop
| play sonic games
Etiketler
Absolute Abstract Classes ActionScript Algoritma
API
Bug Byte Arrays Class Reference CloseHandle
COM CreateDesktop CreateEvent CreateMutex
CreateProcess CreateRemoteThread CreateSemaphore
CreateToolHelp32SnapShot CreateWaitableTimer
DeleteCriticalSection delphi 2010 DTS EnterCriticalSection
Function
PDFmyURL.com
09.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
1 :
2 :
mem := TMemo.Create(Self);
mem.Left := 10;
mem.Top := 10;
mem.Width := 100;
mem.Height := 100;
mem.Parent := Self;
end;
begin
edt := TEdit.Create(Self);
edt.Left := 10;
edt.Top := 10;
edt.Width := 100;
edt.Height := 100;
edt.Parent := Self;
end;
begin
pnl := TPanel.Create(Self);
pnl.Left := 10;
pnl.Top := 10;
pnl.Width := 100;
pnl.Height:= 100;
pnl.Parent := Self;
end;
end; //case
end;
Şimdi yukarıdaki kullanım olmaz mı ? Olur tabii neden olmasın iş görüyor netice de ama pek
şık değil ve bazı güçlerden yoksun. Mesela artık TPanel yerine TLabel oluşturmak istesek
kodun bir sürü yerini değiştirmek zorunda kalacağız. Peki şöyle mis gibi bir fonksiyonum olsa
da ben ona yaptırsam bu işi diye düşünüyor ve böylelikle bir değişiklik yapmam gerektiğinde
sadece fonksiyonumu değiştirsem diyorsanız..Bence doğru düşünüyorsunuz derim sizlere.. O
halde bu fonksiyonumuz nasıl olmalı.? Şöyle bir düşünelim..Benim TForm nesnesi üzerine
koyduğum görünen tüm bileşenlerin hepsi TControl’den türemiş o halde bu fonksiyonuma ben
parametre olarak TControl geçsem her türlü nesneyi oluşturabilirim diyorsunuz.Evet güzel bir
yaklaşım..Ama doğru mu ? Hayır değil..! Neden değil, çünkü fonksiyona parametre olarak
geçeceğiniz bir TControl değişkeni için Delphi sizden daha önce oluşturulmuş bir nesne
örneği bekler. Ama bizim yapmak istediğimiz o değil ki.. Biz CreateControl(TEdit) gibi birşey
yazmak istiyoruz. TEdit nedir peki nesne midir ? Hayır nesne değildir.Bir class‘dır. O halde
bizim class’ları tutabilecek bir yapıya ihtiyacımız var ki fonksiyona bir class parametresi
geçebilelim.Kafalar biraz karıştı sanırım.Şimdi örnekle izah etmeye gayret edelim.
01.
02.
03.
type TControlClass = class of TControl; // Class’ları
içerebilen bir değişken tipi tanımladık.!!
function CreateControl(ControlClass : TControlClass;
ControlName : String) : TControl;
EnumDesktopProc EnumDesktops Flash
Function
Pointer GetCurrentProcess
GetIconInfo GetKeyState
GetLastInputInfo GetProcessMemoryInfo GetStartupInfo
GetThreadContext GetTickCount GetTickCount64
Hacking Inheritance InitializeCriticalSection
Interface InterlockedCompareExchange
InterlockedDecrement InterlockedExchange
InterlockedExchangeAdd InterlockedIncrement
JavaScript LeaveCriticalSection Method Pointer
Module32First Module32Next MSSQL OpenDesktop
OpenEvent OpenMutex OpenSemaphore
OpenWaitableTimer Operator Overloading
Persistance
Pointer Procedure Pointer Process
Process32First Process32Next Query QueryInterface
QueryPerformanceCounter Queue ReleaseMutex
ReleaseSemaphore Reqursion ResetEvent ResumeThread
RTTI SetEvent SetProcessWorkingSetSize
SetThreadContext SetWaitableTimer Smilarity SORT SQL
SQL Server
Stream SuspendThread Sw itchDesktop
TDateTime TerminateProcess TerminateThread
Thread TInterfacedObject TValue Untyped
Parameters VirtualAllocEx VirtualFreeEx
WaitForSingleObject
WaitForMultipleObjects
Weaver WriteProcessMemory _AddRef _Release
WP Cumulus Flash tag cloud by Roy Tanck
requires Flash Player 9 or better.
Son Yorumlar
Yeni Veri Tipleri ve Operator Overloading için
Tuğrul HELVACI
Yeni Veri Tipleri ve Operator Overloading için
Zafer Çelenk
Delphi ve Google Maps API için Tuğrul
HELVACI
Delphi ve Google Maps API için ahmet
Ziyaretçi Defteri için Tuğrul HELVACI
PDFmyURL.com
04.
05.
06.
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
begin
Result := ControlClass.Create(Form1);
Result.Left := 10;
Result.Top := 10;
Result.Width := 100;
Result.Height := 100;
Result.Name := ControlName;
Result.Parent := Form1;
end;
var
mControl : TControl;
begin
case RadioGroup1.ItemIndex of
0 : mControl := CreateControl(TMemo, ‘Memo1′);
1 : mControl := CreateControl(TEdit, ‘Edit1′);
2 : mControl := CreateControl(TPanel, ‘Panel1′);
end;
end;
Ziyaretçi Defteri için Tuğrul HELVACI
Son Yazılar
Yeni Veri Tipleri ve Operator Overloading
Interface Nedir, Nerelerde ve Neden Kullanırız ?
Derinlemesine Threading..(3)
SQL’de Benzerlik Algoritmaları…
Full Text Searching…
Kategoriler
Bu kullanım daha kolay ve daha esnek değil mi sizce de
Saygılar, sevgiler..
[Translate]
Share your comment
Name (required)
Genel (4)
IDE (1)
İşletim Sistemi (7)
Programlama (43)
.Net (3)
C# (2)
Delphi (43)
Grafik (2)
Internet (4)
Veritabanı (3)
Win32 (6)
Mail (required)
Takvim
Website
Temmuz 2010
Pts Sal Çar Per Cum Cts Paz
PDFmyURL.com
1
5 6 7 8
12 13 14 15
19 20 21 22
26 27 28 29
2
9
16
23
30
3
10
17
24
31
4
11
18
25
« Haz
Arşivler
Haziran 2010 (1)
Mayıs 2010 (1)
Nisan 2010 (3)
Ağustos 2009 (1)
Temmuz 2009 (2)
Haziran 2009 (7)
Mayıs 2009 (32)
Bağlantılar
Bir Türkçe Sevdalısı..
Delphi Türkiye Forum
Gürcan ÖZTÜRK
M.Fatih KÜÇÜKKELEPÇE
Memik YANIK Kişisel
Memik YANIK’ın Günlüğü
Nick Hodges
Sinan BARAN
Zafer Çelenk
PDFmyURL.com
Ziyaretçi Bilgileri
Ziyaret: 2 / 12072
Beğenilenler
Delphi 2010 (Weaver) ve TValue - 14 votes
Derinlemesine Threading..(3) - 13 votes
Derinlemesine Threading..(2) - 6 votes
Derinlemesine Threading..(1) - 6 votes
Yeni Veri Tipleri ve Operator Overloading - 4
votes
Win32 & .Net(Delphi->C#) - 4 votes
Delphi ve Google Maps API - 3 votes
TThread.WaitFor Bug.. - 3 votes
BITS(Background Intelligent Transfer Service)
ile sessiz sedasız download ;) - 3 votes
Bir Kiosk ve CreateDesktop macerası.. - 3
votes
Meta
Giriş
Yazılar RSS
Yorumlar RSS
WordPress.org
Etiketler-Liste
PDFmyURL.com
Absolute
API
Byte Arrays Class Reference
COM CreateDesktop CreateProcess
CreateToolHelp32SnapShot
DTS EnumDesktopProc EnumDesktops Function
Pointer GetCurrentProcess GetIconInfo GetKeyState
CreateRemoteThread
GetLastInputInfo GetProcessMemoryInfo GetStartupInfo
Hacking Inheritance Interface JavaScript
Method Pointer Module32First Module32Next
OpenDesktop Persistance Pointer Procedure
Pointer
Process Process32First Process32Next
RTTI SetProcessWorkingSetSize SQL
Server Sw itchDesktop TerminateProcess
Reqursion
Thread Untyped Parameters VirtualAllocEx
WaitForSingleObject
VirtualFreeEx
WriteProcessMemory
Delphi About
Auto Select All The Text For TCustomEdit On
Mouse Click 29 Haziran 2010
Memory Leak Notification in Delphi - Report
Memory Leak on Program Exit 27 Haziran
2010
PCRE Workbench - Regular Expression Test
Tool - Source Code Delphi Application 22
Haziran 2010
Deleting Dataset Records In a Loop - Poll
Results - Why All Records Are Not Deleted 21
Haziran 2010
Force TListView's Edit Mode using a Keyboard
Shortcut 17 Haziran 2010
Implementing On Item Click / Double Click for
Delphi's TListView control 16 Haziran 2010
Run Your Delphi Application in Full Screen Implement "F11 - Full Screen" 14 Haziran 2010
PDFmyURL.com
Displaying Enumerated Properties in a
Selectable List - Run-Time Enum Selection in
Delphi 10 Haziran 2010
How Do You Delete Dataset Records In a
Loop? 08 Haziran 2010
Display Custom Hints for Status Bar Panels 07
Haziran 2010
Sık Ziyaret Edilenler
Sayfa: Home
(16058)
Delphi ve Google Maps API
(4132)
Delphi ve Google Maps API
(1973)
Nedir bu Thread’lerden çektiğimiz..!
(1444)
Delphi & Animated Flash Charts(Fusion Charts)
(1174)
Delphi & JavaScript Kardeşliği
(933)
Delphi 2010 (Weaver) ve TValue
(918)
Derinlemesine Threading..(1)
(886)
Derinlemesine Threading..(2)
(695)
Win32 & .Net(Delphi->C#)
(617)
Kategori: Delphi
(613)
Bir Kiosk ve CreateDesktop macerası..
(565)
Sayfa: Hakkında
(563)
PDFmyURL.com
TThread.WaitFor Bug..
(540)
Delphi 2010 (Weaver) ve TValue
(530)
Oylama..
Sitedeki makaleleri yararlı buluyor musunuz
?
Evet, yararlı ama yetersiz.
Evet, son derece yararlı.
Evet, mükemmel.
Hayır, yararlı değil.
Hayır, hem yararlı değil, hem de yetersiz.
Hayır, rezalet.
Vote
View Results
Delphi'nin hangi sürümünü kullanıyorsunuz
?
Delphi 5 yada öncesi
Delphi 6
Delphi 7
Delphi 8
Delphi 2005
Delphi 2006
Delphi 2007
PDFmyURL.com
Delphi 2009
Delphi 2010
Vote
View Results
Son Yorumlar
Yeni Eklenenler
Linkler
Yorumunuza teşekkürler. Aslında operatör aşırı
yüklemenin sınıflarda pek bir avantaj... by Tuğrul
HELVACI
Yeni Veri Tipleri ve Operator Overloading
Bir Türkçe Sevdalısı.. - Taha EKREM
Interface Nedir, Nerelerde ve Neden Kullanırız ?
Delphi Türkiye Forum
Merhaba, Ben ilk olarak merakımdan dolayı uğraştığım
C++ dilinde görmüştüm Operatör... by Zafer Çelenk
Derinlemesine Threading..(3)
Gürcan ÖZTÜRK - Gürcan ÖZTÜRK
SQL’de Benzerlik Algoritmaları…
M.Fatih KÜÇÜKKELEPÇE
Full Text Searching…
Memik YANIK Kişisel
Delphi 2010 (Weaver) ve TValue
Memik YANIK’ın Günlüğü
Derinlemesine Threading..(2)
Nick Hodges
Merhaba, makaleyi yazdığım zaman kodlarda bir sorun
yoktu. Belki Google Maps'de bir şeyler... by Tuğrul
HELVACI
Merhaba Kodlarda bir sorun mu var? yoksa ggogle bu
hizmeti durdurdu mu? Sadece boş bir... by ahmet
Programcı arkadaşların daha fazla takıldığı bir yerde
yazsa idiniz mesajınızı daha... by Tuğrul HELVACI
Sinan BARAN
Tuğrul Bey Yeri Burasımıdır Bilmiyorum O nedenle
hata ediyorsam özür dilerm bir iş ilanı... by geyikben
Teşekkürler ;) by Tuğrul HELVACI
Copyright © 2009 Delphi Programming
Pow ered by WordPress | Increase Traffic w ith TrafficWhirl.
PDFmyURL.com

Benzer belgeler

Her türlü veritipini kıyaslamak için.. | Delphi Programming

Her türlü veritipini kıyaslamak için.. | Delphi Programming kadar uğraşmaya..” Doğru haklısınız, peki o zaman örneklere devam edelim

Detaylı

Delphi ve Google Maps API | Delphi Programming

Delphi ve Google Maps API | Delphi Programming Pointer GetCurrentProcess GetIconInfo GetKeyState

Detaylı