Programlama yapalım ve Öğrenelim. - Delphi Eğitim164
  Ana Sayfa
  .NET Eğitim Notları
  Visual C# .NET Örnek Kodları
  VisualBasic.NET Örnek Kodları
  J# Örnekleri
  ASP.NET Örnek Kodları
  Delphi Eğitim
  => Delphi Eğitim1
  => Delphi Eğitim2
  => Delphi Eğitim3
  => Delphi Eğitim4
  => Delphi Eğitim5
  => Delphi Eğitim6
  => Delphi Eğitim7
  => Delphi Eğitim8
  => Delphi Eğitim9
  => Delphi Eğitim10
  => Delphi Eğitim11
  => Delphi Eğitim13
  => Delphi Eğitim14
  => Delphi Eğitim15
  => Delphi Eğitim16
  => Delphi Eğitim17
  => Delphi Eğitim18
  => Delphi Eğitim19
  => Delphi Eğitim20
  => Delphi Eğitim21
  => Delphi Eğitim22
  => Delphi Eğitim23
  => Delphi Eğitim24
  => Delphi Eğitim25
  => Delphi Eğitim26
  => Delphi Eğitim27
  => Delphi Eğitim28
  => Delphi Eğitim29
  => Delphi Eğitim30
  => Delphi Eğtim31
  => Delphi Eğitim32
  => Delphi Eğitim33
  => Delphi Eğitim34
  => Delphi Eğitim35
  => Delphi Eğitim36
  => Delphi Eğitim37
  => Delphi Eğitim38
  => Delphi Eğitim39
  => Delphi Eğitim40
  => Delphi Eğitim41
  => Delphi Eğitim42
  => Delphi Eğitim43
  => Delphi Eğitim44
  => Delphi Eğitim45
  => Delphi Eğitim46
  => Delphi Eğitim47
  => Delphi Eğitim48
  => Delphi Eğitim49
  => Delphi Eğitim50
  => Delphi Eğitim51
  => Delphi Eğitim52
  => Delphi Eğitim53
  => Delphi Eğitim54
  => Delphi Eğitim55
  => Delphi Eğitim56
  => Delphi Eğitim57
  => Delphi Eğitim58
  => Delphi Eğitim59
  => Delphi Eğitim60
  => Delphi Eğitim61
  => Delphi Eğitim62
  => Delphi Eğitim63
  => Delphi Eğitim64
  => Delphi Eğitim65
  => Delphi Eğitim66
  => Delphi Eğitim67
  => Delphi Eğitim68
  => Delphi Eğitim69
  => Delphi Eğitim70
  => Delphi Eğitim71
  => Delphi Eğitim72
  => Delphi Eğitim73
  => Delphi Eğitim74
  => Delphi Eğitim75
  => Delphi Eğitim76
  => Delphi Eğitim77
  => Delphi Eğitim78
  => Delphi Eğitim79
  => Delphi Eğitim80
  => Delphi Eğitim81
  => Delphi Eğitim82
  => Delphi Eğitim83
  => Delphi Eğitim84
  => Delphi Eğitim85
  => Delphi Eğitim86
  => Delphi Eğitim87
  => Delphi Eğitim88
  => Delphi Eğitim89
  => Delphi Eğitim90
  => Delphi Eğitim91
  => Delphi Eğitim92
  => Delphi Eğitim93
  => Delphi Eğitim94
  => Delphi Eğitim95
  => Delphi Eğitim96
  => Delphi Eğitim97
  => Delphi Eğitim98
  => Delphi Eğitim99
  => Delphi Eğitim100
  => Delphi Eğitim101
  => Delphi Eğitim102
  => Delphi Eğitim103
  => Delphi Eğitim104
  => Delphi Eğitim105
  => Delphi Eğitim106
  => Delphi Eğitim107
  => Delphi Eğitim108
  => Delphi Eğitim109
  => Delphi Eğitim110
  => Delphi Eğitim111
  => Delphi Eğitim112
  => Delphi Eğitim113
  => Delphi Eğitim114
  => Delphi Eğitim115
  => Delphi Eğitim116
  => Delphi Eğitim117
  => Delphi Eğitim118
  => Delphi Eğitim119
  => Delphi Eğitim120
  => Delphi Eğitim121
  => Delphi Eğitim122
  => Delphi Eğitim123
  => Delphi Eğitim124
  => Delphi Eğitim125
  => Delphi Eğitim126
  => Delphi Eğitim127
  => Delphi Eğitim128
  => Delphi Eğitim129
  => Delphi Eğitim130
  => Delphi Eğitim131
  => Delphi Eğitim132
  => Delphi Eğitim133
  => Delphi Eğitim134
  => Delphi Eğitim135
  => Delphi Eğitim136
  => Delphi Eğitim137
  => Delphi Eğitim138
  => Delphi Eğitim139
  => Delphi Eğitim140
  => Delphi Eğitim141
  => Delphi Eğitim142
  => Delphi Eğitim143
  => Delphi Eğitim144
  => Delphi Eğitim145
  => Delphi Eğitim146
  => Delphi eğitim147
  => Delphi Eğitim148
  => Delphi Eğitim149
  => Delphi Eğitim150
  => Delphi Eğitim151
  => Delphi Eğitim152
  => Delphi Eğitim153
  => Delphi Eğitim154
  => Delphi Eğitim155
  => Delphi Eğitim156
  => Delphi Eğitim157
  => Delphi Eğitim158
  => Delphi Eğitim159
  => Delphi Eğitim160
  => Delphi Eğitim161
  => Delphi Eğitim162
  => Delphi Eğitim164
  => Delphi Eğitim165
  => Delphi Eğitim166
  => Delphi Eğitim167
  => Delphi Eğitim168
  => Delphi Eğitim169
  => Delphi Eğitim170
  => Delphi Eğitim171
  => Delphi Eğitim172
  => Delphi Eğitim173
  => Delphi Eğitim174
  => Delphi Eğitim175
  => Delphi Eğitim176
  => Delphi Eğitim177
  => Delphi Eğitim178
  => Delphi Eğitim179
  => Delphi Eğitim180
  => Delphi Eğitim181
  => Delphi Eğitim182
  => Delphi Eğitim183
  => Delphi Eğitim184
  => Delphi Eğitim185
  => Delphi Eğitim186
  => Delphi Eğitim187
  => Delphi Eğitim188
  => Delphi Eğitim189
  => Delphi Eğitim190
  => Delphi Eğitim191
  => Delphi Eğitim192
  => Delphi Eğitim193
  => Delphi Eğitim194
  => Delphi Eğitim195
  => Delphi Eğitim196
  => Delphi Eğitim197
  => Delphi Eğitim198
  => Delphi Eğitim199
  => Delphi Eğitim200
  => Delphi Eğitim201
  => Delphi Eğitim202
  => Delphi Eğitim203
  => Delphi Eğitim204
  => Delphi Eğitim205
  => Delphi Eğitim206
  => Delphi Eğitim207
  => Delphi Eğitim208
  => Delphi Eğitim209
  => Delphi Eğitim210
  => Delphi Eğitim211
  => Delphi Eğitim212
  => Delphi Eğitim213
  => Delphi Eğitim214
  => Delphi Eğitim215
  => Delphi Eğitim216
  => Delphi Eğitim217
  => Delphi Eğitim218
  => Delphi Eğitim219
  => Delphi Eğitim220
  => Delphi Eğitim221
  => Delphi Eğitim222
  => Delphi Eğitim223
  => Delphi Eğitim224
  => Delphi Eğitim225
  => Delphi Eğitim226
  => Delphi Eğitim227
  => Delphi Eğitim228
  => Delphi Eğitim229
  => Delphi Eğitim230
  => Delphi Eğitim231
  => Delphi Eğitim232
  => Delphi Eğitim233
  => Delphi Eğitim234
  => Delphi Eğitim235
  => Delphi Eğitim236
  => Delphi Eğitim237
  => Delphi Eğitim238
  => Delphi Eğitim239
  => Delphi Eğitim240
  => Delphi Eğitim241
  => Delphi Eğitim242
  İletişim

neoturk: ...Shape a form to a bitmap ?...

unit Unit1;

 

interface

 

uses

  Windows, Classes, SysUtils, Graphics, Forms;

 

type

  TRGBArray = array[0..32767] of TRGBTriple;

  PRGBArray = ^TRGBArray;

 

type

  TForm1 = class(TForm)

    procedure FormCreate(Sender: TObject);

    procedure FormDestroy(Sender: TObject);

  private

    { Private declarations }

    FRegion: THandle;

    function CreateRegion(Bmp: TBitmap): THandle;

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

function TForm1.CreateRegion(Bmp: TBitmap): THandle;

var

  X, Y, StartX: Integer;

  Excl: THandle;

  Row: PRGBArray;

  TransparentColor: TRGBTriple;

begin

  Bmp.PixelFormat := pf24Bit;

 

  Result := CreateRectRGN(0, 0, Bmp.Width, Bmp.Height);

 

  for Y := 0 to Bmp.Height - 1 do

  begin

    Row := Bmp.Scanline[Y];

 

    StartX := -1;

 

    if Y = 0 then

      TransparentColor := Row[0];

 

    for X := 0 to Bmp.Width - 1 do

    begin

      if (Row[X].rgbtRed = TransparentColor.rgbtRed) and

        (Row[X].rgbtGreen = TransparentColor.rgbtGreen) and

        (Row[X].rgbtBlue = TransparentColor.rgbtBlue) then

      begin

        if StartX = -1 then StartX := X;

      end

      else

      begin

        if StartX > -1 then

        begin

          Excl := CreateRectRGN(StartX, Y, X + 1, Y + 1);

          try

            CombineRGN(Result, Result, Excl, RGN_DIFF);

            StartX := -1;

          finally

            DeleteObject(Excl);

          end;

        end;

      end;

    end;

 

    if StartX > -1 then

    begin

      Excl := CreateRectRGN(StartX, Y, Bmp.Width, Y + 1);

      try

        CombineRGN(Result, Result, Excl, RGN_DIFF);

      finally

        DeleteObject(Excl);

      end;

    end;

  end;

end;

 

procedure TForm1.FormCreate(Sender: TObject);

var

  Bmp: TBitmap;

begin

  Bmp := TBitmap.Create;

  try

    Bmp.LoadFromFile('C:YourBitmap.bmp');

    FRegion := CreateRegion(Bmp);

    SetWindowRGN(Handle, FRegion, True);

  finally

    Bmp.Free;

  end;

end;

 

procedure TForm1.FormDestroy(Sender: TObject);

begin

  DeleteObject(FRegion);

end;

 

end.

 

Delphi - .....................................

 

neoturk: ...Show a form in full-screen mode ?...

{

  Make your application like a game. Full Screen.

  Disable all of the system keys.

}

 

procedure TForm1.FormCreate(Sender: TObject);

var

  HTaskbar: HWND;

  OldVal: LongInt;

begin

  try

    // Find handle of TASKBAR

    HTaskBar := FindWindow('Shell_TrayWnd', nil);

    // Turn SYSTEM KEYS off, Only Win 95/98/ME

    SystemParametersInfo(97, Word(True), @OldVal, 0);

    // Disable the taskbar

    EnableWindow(HTaskBar, False);

    // Hide the taskbar

    ShowWindow(HTaskbar, SW_HIDE);

  finally

    with Form1 do

    begin

      BorderStyle := bsNone;

      FormStyle   := fsStayOnTop;

      Left        := 0;

      Top         := 0;

      Height      := Screen.Height;

      Width       := Screen.Width;

    end;

  end

end;

 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

var

  HTaskbar: HWND;

  OldVal: LongInt;

begin

  //Find handle of TASKBAR

  HTaskBar := FindWindow('Shell_TrayWnd', nil);

  //Turn SYSTEM KEYS Back ON, Only Win 95/98/ME

  SystemParametersInfo(97, Word(False), @OldVal, 0);

  //Enable the taskbar

  EnableWindow(HTaskBar, True);

  //Show the taskbar

  ShowWindow(HTaskbar, SW_SHOW);

end;

 

 

{

  Hope you like it !

  So if you have any problem using these codes

  please e-mail me at :

  babak_sateli@yahoo.com

  Babak Sateli

  www.cdcenterco.com

}

 

Delphi - .....................................

 

neoturk: ...Show a form in full-screen mode ?...

{

  Make your application like a game. Full Screen.

  Disable all of the system keys.

}

 

procedure TForm1.FormCreate(Sender: TObject);

var

  HTaskbar: HWND;

  OldVal: LongInt;

begin

  try

    // Find handle of TASKBAR

    HTaskBar := FindWindow('Shell_TrayWnd', nil);

    // Turn SYSTEM KEYS off, Only Win 95/98/ME

    SystemParametersInfo(97, Word(True), @OldVal, 0);

    // Disable the taskbar

    EnableWindow(HTaskBar, False);

    // Hide the taskbar

    ShowWindow(HTaskbar, SW_HIDE);

  finally

    with Form1 do

    begin

      BorderStyle := bsNone;

      FormStyle   := fsStayOnTop;

      Left        := 0;

      Top         := 0;

      Height      := Screen.Height;

      Width       := Screen.Width;

    end;

  end

end;

 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

var

  HTaskbar: HWND;

  OldVal: LongInt;

begin

  //Find handle of TASKBAR

  HTaskBar := FindWindow('Shell_TrayWnd', nil);

  //Turn SYSTEM KEYS Back ON, Only Win 95/98/ME

  SystemParametersInfo(97, Word(False), @OldVal, 0);

  //Enable the taskbar

  EnableWindow(HTaskBar, True);

  //Show the taskbar

  ShowWindow(HTaskbar, SW_SHOW);

end;

 

 

{

  Hope you like it !

  So if you have any problem using these codes

  please e-mail me at :

  babak_sateli@yahoo.com

  Babak Sateli

  www.cdcenterco.com

}

 

Delphi - .....................................

 

neoturk: ...Minimize a secondary-form to the taskbar ?...

type

  TForm = class(TForm)

    {...}

  protected

    procedure CreateParams(var Params: TCreateParams); override;

  end;

 

implementation

 

{...}

 

procedure TForm2.CreateParams(var Params: TCreateParams);

begin

  inherited CreateParams(Params);

  Params.ExStyle   := Params.ExStyle or WS_EX_APPWINDOW;

  Params.WndParent := GetDesktopWindow;

end;

 

Delphi - .....................................

 

neoturk: ...Minimize a secondary-form to the taskbar ?...

type

  TForm = class(TForm)

    {...}

  protected

    procedure CreateParams(var Params: TCreateParams); override;

  end;

 

implementation

 

{...}

 

procedure TForm2.CreateParams(var Params: TCreateParams);

begin

  inherited CreateParams(Params);

  Params.ExStyle   := Params.ExStyle or WS_EX_APPWINDOW;

  Params.WndParent := GetDesktopWindow;

end;

 

Delphi - .....................................

 

neoturk: ...Make a form semi-- transparent ?...

// Make your forms 25%, 50% Transparent...

 

TMyForm = class (TForm);

 

TrackBar1: TTrackBar;

//..

private

FColorKey: TCOLOR;

 

end;

 

const

  // Use crKey as the transparency color.

  LWA_COLORKEY = 1;

  // Use bAlpha to determine the opacity of the layered window..

  LWA_ALPHA     = 2;

  WS_EX_LAYERED = $80000;

 

implementation

 

{$R *.DFM}

 

// The SetLayeredWindowAttributes function sets the opacity and transparency

// color key of a layered window.

// Note : This function is only available with Windows 2000 and XP!

function SetLayeredWindowAttributes(

  // Handle to the layered window.

  Wnd: hwnd;

  // Pointer to a COLORREF value that specifies the transparency

  // color key to be used when composing the layered window

  crKey: ColorRef;

  // Alpha value used to describe the opacity of the layered window

  Alpha: Byte;

  // Specifies an action to take

  // LWA_COLORKEY or LWA_ALPHA

  // This parameter can be one or more of the following values:

  dwFlags: DWORD): Boolean;

  stdcall; external 'user32.dll';

 

 

procedure TMyForm.TrackBar1Change(Sender: TObject);

  // Trackbar.Position must run at range 1-255...

begin

  SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED);

  SetLayeredWindowAttributes(Handle, ColorToRGB(FColorKey), TrackBar1.Position, LWA_ALPHA);

end;

 

{******************************************************************}

 

{ To load the SetLayeredWindowAttributes() function dynamically, use this function:}

 

function MakeWindowTransparent(Wnd: HWND; nAlpha: Integer = 10): Boolean;

type

  TSetLayeredWindowAttributes = function(hwnd: HWND; crKey: COLORREF; bAlpha: Byte;

    dwFlags: Longint): Longint;

  stdcall;

const

  // Use crKey as the transparency color.

  LWA_COLORKEY = 1;

  // Use bAlpha to determine the opacity of the layered window..

  LWA_ALPHA     = 2;

  WS_EX_LAYERED = $80000;

var

  hUser32: HMODULE;

  SetLayeredWindowAttributes: TSetLayeredWindowAttributes;

  i: Integer;

begin

  Result := False;

  // Here we import the function from USER32.DLL

  hUser32 := GetModuleHandle('USER32.DLL');

  if hUser32 <> 0 then

  begin @SetLayeredWindowAttributes := GetProcAddress(hUser32, 'SetLayeredWindowAttributes');

    // If the import did not succeed, make sure your app can handle it!

    if @SetLayeredWindowAttributes <> nil then

    begin

      // Check the current state of the dialog, and then add the WS_EX_LAYERED attribute

      SetWindowLong(Wnd, GWL_EXSTYLE, GetWindowLong(Wnd, GWL_EXSTYLE) or WS_EX_LAYERED);

      // The SetLayeredWindowAttributes function sets the opacity and

      // transparency color key of a layered window

      SetLayeredWindowAttributes(Wnd, 0, Trunc((255 / 100) * (100 - nAlpha)), LWA_ALPHA);

      Result := True;

    end;

  end;

end;

 

Delphi - .....................................

 

neoturk: ...Make a form semi-- transparent ?...

// Make your forms 25%, 50% Transparent...

 

TMyForm = class (TForm);

 

TrackBar1: TTrackBar;

//..

private

FColorKey: TCOLOR;

 

end;

 

const

  // Use crKey as the transparency color.

  LWA_COLORKEY = 1;

  // Use bAlpha to determine the opacity of the layered window..

  LWA_ALPHA     = 2;

  WS_EX_LAYERED = $80000;

 

implementation

 

{$R *.DFM}

 

// The SetLayeredWindowAttributes function sets the opacity and transparency

// color key of a layered window.

// Note : This function is only available with Windows 2000 and XP!

function SetLayeredWindowAttributes(

  // Handle to the layered window.

  Wnd: hwnd;

  // Pointer to a COLORREF value that specifies the transparency

  // color key to be used when composing the layered window

  crKey: ColorRef;

  // Alpha value used to describe the opacity of the layered window

  Alpha: Byte;

  // Specifies an action to take

  // LWA_COLORKEY or LWA_ALPHA

  // This parameter can be one or more of the following values:

  dwFlags: DWORD): Boolean;

  stdcall; external 'user32.dll';

 

 

procedure TMyForm.TrackBar1Change(Sender: TObject);

  // Trackbar.Position must run at range 1-255...

begin

  SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED);

  SetLayeredWindowAttributes(Handle, ColorToRGB(FColorKey), TrackBar1.Position, LWA_ALPHA);

end;

 

{******************************************************************}

 

{ To load the SetLayeredWindowAttributes() function dynamically, use this function:}

 

function MakeWindowTransparent(Wnd: HWND; nAlpha: Integer = 10): Boolean;

type

  TSetLayeredWindowAttributes = function(hwnd: HWND; crKey: COLORREF; bAlpha: Byte;

    dwFlags: Longint): Longint;

  stdcall;

const

  // Use crKey as the transparency color.

  LWA_COLORKEY = 1;

  // Use bAlpha to determine the opacity of the layered window..

  LWA_ALPHA     = 2;

  WS_EX_LAYERED = $80000;

var

  hUser32: HMODULE;

  SetLayeredWindowAttributes: TSetLayeredWindowAttributes;

  i: Integer;

begin

  Result := False;

  // Here we import the function from USER32.DLL

  hUser32 := GetModuleHandle('USER32.DLL');

  if hUser32 <> 0 then

  begin @SetLayeredWindowAttributes := GetProcAddress(hUser32, 'SetLayeredWindowAttributes');

    // If the import did not succeed, make sure your app can handle it!

    if @SetLayeredWindowAttributes <> nil then

    begin

      // Check the current state of the dialog, and then add the WS_EX_LAYERED attribute

      SetWindowLong(Wnd, GWL_EXSTYLE, GetWindowLong(Wnd, GWL_EXSTYLE) or WS_EX_LAYERED);

      // The SetLayeredWindowAttributes function sets the opacity and

      // transparency color key of a layered window

      SetLayeredWindowAttributes(Wnd, 0, Trunc((255 / 100) * (100 - nAlpha)), LWA_ALPHA);

      Result := True;

    end;

  end;

end;

 

Delphi - .....................................

 

neoturk: ...Show hints in the statusbar ?...

private

  procedure MyHint(Sender: TObject);

end;

 

 

implementation

 

 {....}

 

procedure TForm1.FormCreate(Sender: TObject);

begin

  Application.OnHint := MyHint;

  ShowHint           := True;

  Button1.Hint       := 'normal yellow hint|Text in Statusbar';

  Button2.Hint       := 'only yellow hint|';

  Button3.Hint       := '|text only in statusbar';

  Edit1.Hint         := 'same text';

end;

 

procedure TForm1.MyHint(Sender: TObject);

begin

  StatusBar1.SimpleText := Application.Hint;

end;

 

Delphi - .....................................

 

neoturk: ...Show hints in the statusbar ?...

private

  procedure MyHint(Sender: TObject);

end;

 

 

implementation

 

 {....}

 

procedure TForm1.FormCreate(Sender: TObject);

begin

  Application.OnHint := MyHint;

  ShowHint           := True;

  Button1.Hint       := 'normal yellow hint|Text in Statusbar';

  Button2.Hint       := 'only yellow hint|';

  Button3.Hint       := '|text only in statusbar';

  Edit1.Hint         := 'same text';

end;

 

procedure TForm1.MyHint(Sender: TObject);

begin

  StatusBar1.SimpleText := Application.Hint;

end;

 

Delphi - .....................................

 

neoturk: ...Draw a color outline around tform ?...

{

  Erstelle ein Message Handler für die Windows Message WM_NCPAINT Message. Das

  folgende Beispiel zeichnet ein 1 Pixel breiter roter Rahmen um

  das Formular.

 

  Create a message handler for the Windows Message WM_NCPAINT

  message. The following example paints a 1 pixel red border around the

  frame of the form.

}

 

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs;

 

type

  TForm1 = class(TForm)

  private

    { Private-Deklarationen }

    procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT;

  public

    { Public-Deklarationen }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);

var

  dc: hDc;

  Pen: hPen;

  OldPen: hPen;

  OldBrush: hBrush;

begin

  inherited;

  dc := GetWindowDC(Handle);

  Msg.Result := 1;

  //Change the RGB value to change the color

  Pen := CreatePen(PS_SOLID, 1, RGB(255, 0, 0));

  OldPen := SelectObject(dc, Pen);

  OldBrush := SelectObject(dc, GetStockObject(NULL_BRUSH));

  Rectangle(dc, 0, 0, Form1.Width, Form1.Height);

  SelectObject(dc, OldBrush);

  SelectObject(dc, OldPen);

  DeleteObject(Pen);

  ReleaseDC(Handle, Canvas.Handle);

end;

 

 

end.

 

Delphi - .....................................

 

neoturk: ...Draw a color outline around tform ?...

{

  Erstelle ein Message Handler für die Windows Message WM_NCPAINT Message. Das

  folgende Beispiel zeichnet ein 1 Pixel breiter roter Rahmen um

  das Formular.

 

  Create a message handler for the Windows Message WM_NCPAINT

  message. The following example paints a 1 pixel red border around the

  frame of the form.

}

 

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs;

 

type

  TForm1 = class(TForm)

  private

    { Private-Deklarationen }

    procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT;

  public

    { Public-Deklarationen }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);

var

  dc: hDc;

  Pen: hPen;

  OldPen: hPen;

  OldBrush: hBrush;

begin

  inherited;

  dc := GetWindowDC(Handle);

  Msg.Result := 1;

  //Change the RGB value to change the color

  Pen := CreatePen(PS_SOLID, 1, RGB(255, 0, 0));

  OldPen := SelectObject(dc, Pen);

  OldBrush := SelectObject(dc, GetStockObject(NULL_BRUSH));

  Rectangle(dc, 0, 0, Form1.Width, Form1.Height);

  SelectObject(dc, OldBrush);

  SelectObject(dc, OldPen);

  DeleteObject(Pen);

  ReleaseDC(Handle, Canvas.Handle);

end;

 

 

end.

 

Delphi - .....................................

 

neoturk: ...Shade components ?...

procedure ShadeIt(f: TForm; c: TControl; Width: Integer; Color: TColor);

var

  rect: TRect;

  old: TColor;

begin

  if (c.Visible) then

  begin

    rect := c.BoundsRect;

    rect.Left := rect.Left + Width;

    rect.Top := rect.Top + Width;

    rect.Right := rect.Right + Width;

    rect.Bottom := rect.Bottom + Width;

    old := f.Canvas.Brush.Color;

    f.Canvas.Brush.Color := Color;

    f.Canvas.fillrect(rect);

    f.Canvas.Brush.Color := old;

  end;

end;

 

procedure TForm1.FormPaint(Sender: TObject);

var

  i: Integer;

begin

  for i := 0 to Self.ControlCount - 1 do

    ShadeIt(Self, Self.Controls[i], 3, clBlack);

end;

 

Delphi - .....................................

 

neoturk: ...Shade components ?...

procedure ShadeIt(f: TForm; c: TControl; Width: Integer; Color: TColor);

var

  rect: TRect;

  old: TColor;

begin

  if (c.Visible) then

  begin

    rect := c.BoundsRect;

    rect.Left := rect.Left + Width;

    rect.Top := rect.Top + Width;

    rect.Right := rect.Right + Width;

    rect.Bottom := rect.Bottom + Width;

    old := f.Canvas.Brush.Color;

    f.Canvas.Brush.Color := Color;

    f.Canvas.fillrect(rect);

    f.Canvas.Brush.Color := old;

  end;

end;

 

procedure TForm1.FormPaint(Sender: TObject);

var

  i: Integer;

begin

  for i := 0 to Self.ControlCount - 1 do

    ShadeIt(Self, Self.Controls[i], 3, clBlack);

end;

 

Delphi - .....................................

 

neoturk: ...Make a form not resizable but moveable ?...

private

   procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;

end;

 

{...}

 

implementation

 

procedure TForm1.WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo);

begin

  inherited;

  with Msg.MinMaxInfo^ do

  begin

    ptMinTrackSize.x := Form1.Width;

    ptMaxTrackSize.x := Form1.Width;

    ptMinTrackSize.y := Form1.Height;

    ptMaxTrackSize.y := Form1.Height;

  end;

end;

 

Delphi - .....................................

 

neoturk: ...Make a form not resizable but moveable ?...

private

   procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;

end;

 

{...}

 

implementation

 

procedure TForm1.WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo);

begin

  inherited;

  with Msg.MinMaxInfo^ do

  begin

    ptMinTrackSize.x := Form1.Width;

    ptMaxTrackSize.x := Form1.Width;

    ptMinTrackSize.y := Form1.Height;

    ptMaxTrackSize.y := Form1.Height;

  end;

end;

 

Delphi - .....................................

 

neoturk: ...Scale a form manually ?...

{

  Der erste Parameter von ScaleBy ist der Multiplikator, der zweite

  der Divisor. Folgendes Beispiel skaliert die Form auf 150%

 

  The first parameter of ScaleBy is the multiplier, the second

  the divisor. The example scale the form to 150%

}

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  ScaleBy(150, 100);

end;

 

Delphi - .....................................

 

neoturk: ...Scale a form manually ?...

{

  Der erste Parameter von ScaleBy ist der Multiplikator, der zweite

  der Divisor. Folgendes Beispiel skaliert die Form auf 150%

 

  The first parameter of ScaleBy is the multiplier, the second

  the divisor. The example scale the form to 150%

}

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  ScaleBy(150, 100);

end;

 

Delphi - .....................................

 

neoturk: ...Close a mdichild form ?...

unit Child;

 

// Have you noticed that when you try to close a MDIChild form

// the form minimizes but doesn't disappear from your Main form

// client area?

//

// With this tip you can learn how to really close the MDI child

// form and free the memory occupied by the form

 

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

 

type

  TMDIChildForm = class(TForm)

    procedure FormClose(Sender: TObject; var Action: TCloseAction);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  MDIChildForm: TMDIChildForm;

 

implementation

 

{$R *.DFM}

 

procedure TMDIChildForm.FormClose(Sender: TObject;

  var Action: TCloseAction);

begin

  // This line of code frees memory and closes the form

  Action := caFree;

end;

 

end.

 

Delphi - .....................................

 

neoturk: ...Close a mdichild form ?...

unit Child;

 

// Have you noticed that when you try to close a MDIChild form

// the form minimizes but doesn't disappear from your Main form

// client area?

//

// With this tip you can learn how to really close the MDI child

// form and free the memory occupied by the form

 

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

 

type

  TMDIChildForm = class(TForm)

    procedure FormClose(Sender: TObject; var Action: TCloseAction);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  MDIChildForm: TMDIChildForm;

 

implementation

 

{$R *.DFM}

 

procedure TMDIChildForm.FormClose(Sender: TObject;

  var Action: TCloseAction);

begin

  // This line of code frees memory and closes the form

  Action := caFree;

end;

 

end.

Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol