Jeg prøvede Madshi, men hvordan får jeg modulet ind i Delphi? Jeg er ikke så erfaren med Delphi :P
Her kommer hele mit programs kildekode:
//Jeg siger mange tak til de gode og letforståelige svar inde på
www.eksperten.dk.//Uden jeres hjælp, var jeg nok aldrig nået langt med programmet.
//Jeg siger tak til Delphi-PRAXiS
unit hovedprogram;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, Printers, StdCtrls, ComCtrls, ToolWin, OleCtrls, SHDocVw,
ExtCtrls;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Filer1: TMenuItem;
Ny1: TMenuItem;
bn1: TMenuItem;
Afslut1: TMenuItem;
Gemsom1: TMenuItem;
Om1: TMenuItem;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
PrintDialog1: TPrintDialog;
Print1: TMenuItem;
N1: TMenuItem;
FontDialog1: TFontDialog;
Indstillinger1: TMenuItem;
Skrifttype1: TMenuItem;
Rediger1: TMenuItem;
Sg1: TMenuItem;
Fortryd1: TMenuItem;
N2: TMenuItem;
Klip1: TMenuItem;
Kopier1: TMenuItem;
Stind1: TMenuItem;
Vlgalt1: TMenuItem;
Timer1: TTimer;
Tekstomraade: TMemo;
StatusBar1: TStatusBar;
Funktioner1: TMenuItem;
FindDialog1: TFindDialog;
Gem1: TMenuItem;
PrinterSetupDialog1: TPrinterSetupDialog;
Udskiftsindstillinger1: TMenuItem;
procedure Afslut1Click(Sender: TObject);
procedure bn1Click(Sender: TObject);
procedure Gemsom1Click(Sender: TObject);
procedure Print1Click(Sender: TObject);
procedure Ny1Click(Sender: TObject);
procedure Skrifttype1Click(Sender: TObject);
procedure Fortryd1Click(Sender: TObject);
procedure Klip1Click(Sender: TObject);
procedure Kopier1Click(Sender: TObject);
procedure Stind1Click(Sender: TObject);
procedure Vlgalt1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure TekstomraadeChange(Sender: TObject);
procedure Gem1Click(Sender: TObject);
procedure Udskiftsindstillinger1Click(Sender: TObject);
procedure Sg1Click(Sender: TObject);
procedure FindDialog1Find(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Afslut1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.bn1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
Tekstomraade.Lines.LoadFromFile(Opendialog1.FileName);
end;
end;
procedure TForm1.FindDialog1Find(Sender: TObject);
var
BuffLength: Word;
FindDialog: TFindDialog;
Buffer, Pos, tPointer: PChar;
begin
assert(Sender is TFindDialog);
FindDialog := Sender as TFindDialog;
GetMem(tPointer, Length(FindDialog.FindText) + 1);
try
StrPCopy(tPointer, FindDialog.FindText);
BuffLength := Tekstomraade.GetTextLen + 1;
GetMem(Buffer, BuffLength);
try
Tekstomraade.GetTextBuf(Buffer,BuffLength);
Pos:= Buffer + Tekstomraade.SelStart + Tekstomraade.SelLength;
Pos:= StrPos(Pos, tPointer);
if assigned(Pos) then
begin
Tekstomraade.SelStart := Pos - Buffer;
Tekstomraade.SelLength := Length(FindDialog.FindText);
end
else
MessageBeep(0);
finally
FreeMem(Buffer);
end;
finally
FreeMem(tPointer);
end;
Tekstomraade.SetFocus;
end;
procedure TForm1.Fortryd1Click(Sender: TObject);
begin
Tekstomraade.Undo;
end;
procedure TForm1.Gem1Click(Sender: TObject);
begin
if OpenDialog1.FileName <> '' then
begin
Tekstomraade.Lines.SaveToFile(OpenDialog1.FileName);
end
else GemSom1Click(Sender);
end;
procedure TForm1.Gemsom1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
Tekstomraade.Lines.SaveToFile(SaveDialog1.FileName);
end;
end;
procedure TForm1.Klip1Click(Sender: TObject);
begin
Tekstomraade.CutToClipboard;
end;
procedure TForm1.Kopier1Click(Sender: TObject);
begin
Tekstomraade.CopyToClipboard
end;
procedure TForm1.Ny1Click(Sender: TObject);
begin
Tekstomraade.Clear;
Statusbar1.Panels[6].Text := '';
Statusbar1.Panels[8].Text := '';
Caption := 'Tekstprogram - [Uden navn]';
end;
procedure TForm1.Print1Click(Sender: TObject);
var
I, XPixelsPrTomme, YPixelsPrTomme, Margen,
LinieHoejde, LinieTaeller: Integer;
begin
if PrintDialog1.Execute then
begin
Printer.Canvas.Font := Tekstomraade.Font;
XPixelsPrTomme := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
Margen := XPixelsPrTomme;
YPixelsPrTomme := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
LinieHoejde := Round(Abs(Printer.Canvas.Font.Size) / 72 *
YPixelsPrTomme * 1.40);
LinieTaeller := 3;
Printer.BeginDoc;
for I := 0 to Tekstomraade.Lines.Count - 1 do
begin
Inc(LinieTaeller);
Printer.Canvas.TextOut(Margen, LinieTaeller * LinieHoejde, Tekstomraade.Lines.Strings[I]);
end;
Printer.EndDoc;
end;
end;
procedure TForm1.Sg1Click(Sender: TObject);
begin
FindDialog1.Execute;
end;
procedure TForm1.Skrifttype1Click(Sender: TObject);
begin
if fontdialog1.execute then Tekstomraade.font := Fontdialog1.font;
end;
procedure TForm1.Stind1Click(Sender: TObject);
begin
Tekstomraade.PasteFromClipboard;
end;
procedure TForm1.TekstomraadeChange(Sender: TObject);
begin
Statusbar1.Panels[6].Text := IntToStr(Tekstomraade.Lines.Count);
Statusbar1.Panels[8].Text := IntToStr(length(Tekstomraade.Lines.Text));
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Statusbar1.Panels[2].Text := TimeToStr(now);
Statusbar1.Panels[4].Text := DateToStr(now);
end;
procedure TForm1.Udskiftsindstillinger1Click(Sender: TObject);
begin
PrinterSetupDialog1.Execute;
end;
procedure TForm1.Vlgalt1Click(Sender: TObject);
begin
Tekstomraade.SelectAll
end;
end.
(overstående linje er linje 225)