Sabtu, 29 November 2008

Pengertian Vishual Basic ( VB )

Belajar Visual Basic, seperti biasa dengan bahasa yang mudah dipahami. 

Seperti juga PHP, Visual basic adalah sebuah bahasa pemrograman yang mudah dipelajari dan tutorial ini akan mengantarkan anda untuk memasuki dunia VB dengan enjoy. 

Dengan Visual basic, kamu bisa ngembangin aplikasi dan game-game berbasis Windows. Visual Basic jauh lebih mudah dipelajari dibandingkan bahasa pemrograman lainnya (seperti Visual C++) namun tetap merupakan bahasa pemrograman yang sangat powerful.

Tertarik? Baca aja tutorial ini lebih lanjut.

Visual basic lebih cocok untuk pengembangan aplikasi dibandingkan pengembangan game. Kamu bisa aja membuat game yang menakjubkan menggunakan Visual basic, tetapi jika kamu ingin membuat game profesional yang lebih canggih seperti Quake 2, maka kamu mungkin lebih baik memilih untuk menggunakan bahasa lain (seperti C++), yang tentunya akan jauh lebih sulit untuk digunakan.

Namun demikian, Visual basic sebenarnya sudah sangat memadai untuk memenuhi hampir semua kebutuhan pemrograman aplikasi dangame yang kamu inginkan.


Keuntungan Visual basic:

- Bahasa yang sederhana. Banyak hal yang mungkin sulit dilakukan jikak kita menggunakan bahasa pemrograman lainnya, akan dapat dilakukan dengan mudah dengan menggunakan Visual basic.

- Karena Visual basic sangat populer, maka sangat banyak sumber-sumber yang dapat kamu gunakan untuk belajar dan mengembangkan kemampuan kau baik berupa buku, web site dll . Dengan banyaknya sumber-sumber tersebut, maka tentu saja kamu akan sangat mudah menemukan jawaban atas persoalan yang kamu hadapi kan?

- Kamu bisa memperoleh banyak tools baik gratis maupun tidak di Internet yang akan sangat membantu menghemat waktu kamu dalam pemrograman. Contoh, jika kamu ingin membuat program untuk melakukan ping ke salah satu komputer di jaringan kamu, alih-alih membuat program ping tersebut sendiri, kamu bisa donlot sebuah kontrol yang melakukan hal tersebut dan menempelkannya di program kamu. Jika dibandingkan dengan bahasa lain, Visual basic memiliki variasi tools yang paling luas lho.


Kekurangan Visual basic:

- Visual Basic adalah bahasa pemrograman yang powerful, tetapi sebenarnya tidak terlalu bagus untuk membuat game-game yang benar-benar memuaskan.

- Lebih lambat dibandingkan bahasa pemrograman lain.

Selengkapnya...

Selasa, 25 November 2008

Encapsulating graphics

Delphi simplifies Windows graphics by encapsulating various graphics tools into a canvas. The canvas represents the drawing surface of a window or control and contains other classes, such as a pen, a brush, and a font. A canvas is like a Windows device context, but it takes care of all the bookkeeping for you.

If you have written a graphical Windows application, you are familiar with the requirements imposed by Windows’ graphics device interface (GDI). For example, GDI limits the number of device contexts available and requires that you restore graphic objects to their initial state before destroying them.

With Delphi, you do not have to worry about these things. To draw on a form or other component, you access the component’s Canvas property. If you want to customize a pen or brush, you set its color or style. When you finish, Delphi disposes of the resources. Delphi caches resources to avoid recreating them if your application frequently uses the same kinds of resource.

You still have full access to the Windows GDI, but you will often find that your code is simpler and runs faster if you use the canvas built into Delphi components.

CLX graphics encapsulation works differently. A canvas is a painter instead. To draw on a form or other component, you access the component’s Canvas property. Canvas is a property and it is also an object called TCanvas. TCanvas is a wrapper around a Qt painter that is accessible through the Handle property. You can use the handle to access low-level Qt graphics library functions.

If you want to customize a pen or brush, you set its color or style. When you finish, Delphi or Kylix disposes of the resources. CLX applications also cache the resources.

You can use the canvas built into CLX components by descending from them. How graphics images work in the component depends on the canvas of the object from which your component descends.Graphics features are detailed in Chapter 6, “Using graphics in components.”
Selengkapnya...

Enkripsi Data String dan Stream ();

//-- Dikirim oleh: delphy pada Mar 31, 2005 - 04:02 PM [ Edit | Hapus ] begin
ingin meng-enkripsi data rahasia kamu? belum tahu source-code-nya?
saya lupa dulu mendapatkan skrip ini dari mana, tapi skrip ini bisa digunakan:
procedure EncodeStream(Input, Output: TStream);
procedure DecodeStream(Input, Output: TStream);
function EncodeString(const Input: string): string;
function DecodeString(const Input: string): string;


implementation


const
EncodeTable: array[0..63] of Char =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz' +
'0123456789+/';

DecodeTable: array[#0..#127] of Integer = (
Byte('='), 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64,
64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64);

type
PPacket = ^TPacket;
TPacket = packed record
case Integer of
0: (b0, b1, b2, b3: Byte);
1: (i: Integer);
2: (a: array[0..3] of Byte);
3: (c: array[0..3] of Char);
end;

procedure EncodePacket(const Packet: TPacket; NumChars: Integer; OutBuf: PChar);
begin
OutBuf[0] := EnCodeTable[Packet.a[0] shr 2];
OutBuf[1] := EnCodeTable[((Packet.a[0] shl 4) or (Packet.a[1] shr 4)) and $0000003f];
if NumChars < 2 then
OutBuf[2] := '='
else OutBuf[2] := EnCodeTable[((Packet.a[1] shl 2) or (Packet.a[2] shr 6)) and $0000003f];
if NumChars < 3 then
OutBuf[3] := '='
else OutBuf[3] := EnCodeTable[Packet.a[2] and $0000003f];
end;

function DecodePacket(InBuf: PChar; var nChars: Integer): TPacket;
begin
Result.a[0] := (DecodeTable[InBuf[0]] shl 2) or
(DecodeTable[InBuf[1]] shr 4);
NChars := 1;
if InBuf[2] <> '=' then
begin
Inc(NChars);
Result.a[1] := Byte((DecodeTable[InBuf[1]] shl 4) or (DecodeTable[InBuf[2]] shr 2));
end;
if InBuf[3] <> '=' then
begin
Inc(NChars);
Result.a[2] := Byte((DecodeTable[InBuf[2]] shl 6) or DecodeTable[InBuf[3]]);
end;
end;

procedure EncodeStream(Input, Output: TStream);
type
PInteger = ^Integer;
var
InBuf: array[0..509] of Byte;
OutBuf: array[0..1023] of Char;
BufPtr: PChar;
I, J, K, BytesRead: Integer;
Packet: TPacket;
begin
K := 0;
repeat
BytesRead := Input.Read(InBuf, SizeOf(InBuf));
I := 0;
BufPtr := OutBuf;
while I < BytesRead do
begin
if BytesRead - I < 3 then
J := BytesRead - I
else J := 3;
Packet.i := 0;
Packet.b0 := InBuf[I];
if J > 1 then
Packet.b1 := InBuf[I + 1];
if J > 2 then
Packet.b2 := InBuf[I + 2];
EncodePacket(Packet, J, BufPtr);
Inc(I, 3);
Inc(BufPtr, 4);
Inc(K, 4);
if K > 75 then
begin
BufPtr[0] := #$0D;
BufPtr[1] := #$0A;
Inc(BufPtr, 2);
K := 0;
end;
end;
Output.Write(Outbuf, BufPtr - PChar(@OutBuf));
until BytesRead = 0;
end;

procedure DecodeStream(Input, Output: TStream);
var
InBuf: array[0..75] of Char;
OutBuf: array[0..60] of Byte;
InBufPtr, OutBufPtr: PChar;
I, J, K, BytesRead: Integer;
Packet: TPacket;

procedure SkipWhite;
var
C: Char;
NumRead: Integer;
begin
while True do
begin
NumRead := Input.Read(C, 1);
if NumRead = 1 then
begin
if C in ['0'..'9','A'..'Z','a'..'z','+','/','='] then
begin
Input.Position := Input.Position - 1;
Break;
end;
end else Break;
end;
end;

function ReadInput: Integer;
var
WhiteFound, EndReached : Boolean;
CntRead, Idx, IdxEnd: Integer;
begin
IdxEnd:= 0;
repeat
WhiteFound := False;
CntRead := Input.Read(InBuf[IdxEnd], (SizeOf(InBuf)-IdxEnd));
EndReached := CntRead < (SizeOf(InBuf)-IdxEnd);
Idx := IdxEnd;
IdxEnd := CntRead + IdxEnd;
while (Idx < IdxEnd) do
begin
if not (InBuf[Idx] in ['0'..'9','A'..'Z','a'..'z','+','/','=']) then
begin
Dec(IdxEnd);
if Idx < IdxEnd then
Move(InBuf[Idx+1], InBuf[Idx], IdxEnd-Idx);
WhiteFound := True;
end
else
Inc(Idx);
end;
until (not WhiteFound) or (EndReached);
Result := IdxEnd;
end;

begin
repeat
SkipWhite;
{
BytesRead := Input.Read(InBuf, SizeOf(InBuf));
}
BytesRead := ReadInput;
InBufPtr := InBuf;
OutBufPtr := @OutBuf;
I := 0;
while I < BytesRead do
begin
Packet := DecodePacket(InBufPtr, J);
K := 0;
while J > 0 do
begin
OutBufPtr^ := Char(Packet.a[K]);
Inc(OutBufPtr);
Dec(J);
Inc(K);
end;
Inc(InBufPtr, 4);
Inc(I, 4);
end;
Output.Write(OutBuf, OutBufPtr - PChar(@OutBuf));
until BytesRead = 0;
end;

function EncodeString(const Input: string): string;
var
InStr, OutStr: TStringStream;
begin
InStr := TStringStream.Create(Input);
try
OutStr := TStringStream.Create('');
try
EncodeStream(InStr, OutStr);
Result := OutStr.DataString;
finally
OutStr.Free;
end;
finally
InStr.Free;
end;
end;

function DecodeString(const Input: string): string;
var
InStr, OutStr: TStringStream;
begin
InStr := TStringStream.Create(Input);
try
OutStr := TStringStream.Create('');
try
DecodeStream(InStr, OutStr);
Result := OutStr.DataString;
finally
OutStr.Free;
end;
finally
InStr.Free;
end;
end;


Selengkapnya...

Assembler di Delphi

(Pengantar) buat yang mau diet ketat, boosting performance, atau cuma sekedar ingin tahu...

Target Audiens:
• Idiot: Yes
• Pemula: Yes
• Terampil: ? (Questionable)
• Mahir: No
• Wizard: ? (Questionable)
• Guru: Yes


Prerequisites (prasyarat):
• pengetahuan assembler dikit-dikit
• pengetahuan pascal delphi, cukup dikit aja.
Pendahuluan
bla-bla-bla... (silakan isi sendiri)
Bagian A.
Assembler di Delphi (atau dalam bahasa pemrograman apapun) tujuannya cuma dua:
1. speed
2. more speed!
Dalam asm Delphi, hal pertama yang harus difahami adalah model pemanggilan dan pertukaran nilai, dalam istilah kerennya: Calling Convention dan Parameter Passing (sepertinya enakan istilah keren yah? OK, mulai saat ini pake istilah keren aja lah supaya kedengerannya tidak culun).
Oh hiya, Sebagai fanatik Delphi, kita tidak akan ambil pusing dengan model lainnya, yang perlu kita tahu adalah model: pascal dan register. model pascal ini sebenarnya cuma untuk backward compatibility aja, tidak umum lagi dipakai (terutama dalam Object-orientednya Delphi), sementara dalam model register, semua argumen (kalau muat) akan dilewatkan melalui register. jadi ya selesai sudah, tidak ada yang perlu dipelajari lagi.

Sip dah!
BTW, jangan terintimidasi dengan istilah pointer atau adress yang nanti mungkin agak bertebaran di sini. semua sama aja artinya: ANGKA atau NOMOR, tidak lebih dan tidak kurang.

end;

Selengkapnya...

Setting properties, methods, and events

Aside from the visible image manipulated in the Form designer, the most obvious attributes of a component are its properties, events, and methods. Each of these has a chapter devoted to it in this book, but the discussion that follows explains some of the motivation for their use.


Properties

Properties give the application developer the illusion of setting or reading the value of a variable, while allowing the component writer to hide the underlying data structure or to implement special processing when the value is accessed.

There are several advantages to using properties:


• Properties are available at design time. The application developer can set or change initial values of properties without having to write code.

• Properties can check values or formats as the application developer assigns them. Validating input at design time prevents errors.

• The component can construct appropriate values on demand. Perhaps the most common type of error programmers make is to reference a variable that has not been initialized. By representing data with a property, you can ensure that a value is always available on demand.

• Properties allow you to hide data under a simple, consistent interface. You can alter the way information is structured in a property without making the change visible to application developers.

Chapter 3, “Creating properties,” explains how to add properties to your components.

Methods

Class methods are procedures and functions that operate on a class rather than on specific instances of the class. For example, every component’s constructor method (Create) is a class method. Component methods are procedures and functions that operate on the component instances themselves. Application developers use methods to direct a component to perform a specific action or return a value not contained by any property.

Because they require execution of code, methods can be called only at runtime. Methods are useful for several reasons:

• Methods encapsulate the functionality of a component in the same object where the data resides.

• Methods can hide complicated procedures under a simple, consistent interface. An application developer can call a component’s AlignControls method without knowing how the method works or how it differs from the AlignControls method in another component.

• Methods allow updating of several properties with a single call.

Chapter 5, “Creating methods,” explains how to add methods to your components.

Events

An event is a special property that invokes code in response to input or other activity at runtime. Events give the application developer a way to attach specific blocks of code to specific runtime occurrences, such as mouse actions and keystrokes. The code that executes when an event occurs is called an event handler.

Events allow application developers to specify responses to different kinds of input without defining new components.

Chapter 4, “Creating events,” explains how to implement standard events and how to define new ones.
Selengkapnya...

Senin, 24 November 2008

Components and classes

Because components are classes, component writers work with objects at a different level from application developers. Creating new components requires that you derive new classes.

Briefly, there are two main differences between creating components and using them in applications. When creating components,

• You access parts of the class that are inaccessible to application programmers.

• You add new parts (such as properties) to your components.

Because of these differences, you need to be aware of more conventions and think about how application developers will use the components you write. Selengkapnya...

Overview of component creation

This chapter provides an overview of component design and the process of writing components for Delphi applications. The material here assumes that you are familiar with Delphi and its standard components.

• Class library

• Components and classes

• Creating components
• What goes into a component?

• Creating a new component

• Testing uninstalled components
• Testing installed components

• Installing a component on the Component palette

For information on installing new components, see “Installing component packages” on page 16-10 of the Developer’s Guide.

Class library

Delphi’s components reside in a component library that includes the Visual Component Library (VCL) and the Component Library for Cross-Platform (CLX). Figure 1.1 shows the relationship of selected classes that make up the VCL hierarchy. The CLX hierarchy is similar to the VCL hierarchy but Windows controls are called widgets (therefore TWinControl is called TWidgetControl, for example), and there are other differences. For a more detailed discussion of class hierarchies and the inheritance relationships among classes, see Chapter 2, “Object-oriented programming for component writers.” For an overview of how the hierarchies differ from each other, see “WinCLX versus VisualCLX” on page 15-7 of the Developer’s Guide and refer to the CLX online reference for details on the components. Selengkapnya...


Free Blogger Templates by Isnaini Dot Com. Powered by Blogger