Dostosowanie kodu z D4 do kompilatora w D3

0

Witam! Kupiłem niedawno Delphi 3 standard z czego jestem bardzo zadowolony, postanowilem zainstalowac komponenty mODBC, z czego równiez jestem zadowolny poniewaz moim zdaniem sa bardzo dobre. niestety autor udogodnienie jakim jest wizualny edytor sql (taki jak w komponencie TStoredProc ktory generuje kod dla zapytania insert, delete oraz update) zrobil dla delphi w wersji => 4 . Szkoda bo przy duzych tabelach istnieje spora szansa popelnienia bledu dlatego bardzo by sie przydał.
Ponizej wklejam kod z pliku odpoiwedzialnego za ten edytor, bym bym szalenie zadowolony (na pewno innym tez by sie przydalo) gdyby jakis pasjonat dostosowal ten kod do kompilatora w wersji 3. W nagrode wysle mu kartke z Sopotu :-)

unit Mqueryex;
{$I mODBC.INC}
interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, ComCtrls,db,mquery,DsgnIntf;

{$IFDEF QUERYEDITOR}

type
  TmQueryEditor = class(TComponentEditor)
  private
    stdEditor: TComponentEditor;
    stdEditorVerbs:integer;
  public
    constructor Create(AComponent: TComponent; ADesigner: IFormDesigner); override;
    destructor Destroy;  override;
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
    procedure ShowEditor;
    procedure ShowWizard;
  end;

implementation

uses
   mqueryed,mDBWiz;

type PClass = ^TClass;

constructor TmQueryEditor.Create(AComponent: TComponent; ADesigner: IFormDesigner);
var
  saveClass: TClass;
begin
  inherited Create(AComponent,ADesigner);
  saveClass:=PClass(AComponent)^;
  try
    PClass(AComponent)^:=TDataSet;
    stdEditor:=GetComponentEditor(AComponent,ADesigner);
    stdEditorVerbs:=stdEditor.GetVerbCount;
  finally
    PClass(AComponent)^:=saveClass;
  end;
end;

destructor TmQueryEditor.Destroy;
begin
  stdEditor.Free;
  inherited Destroy;
end;

procedure TmQueryEditor.ExecuteVerb(Index: Integer);
begin
  if Index < stdEditor.GetVerbCount then begin
    stdEditor.ExecuteVerb(Index)
  end else begin
    case index-stdEditorVerbs of
      0:begin
        Showeditor;
      end;
      1:begin
        ShowWizard;
      end;
    end;
  end;
end;

function TmQueryEditor.GetVerb(Index: Integer): String;
begin
  if Index < stdEditorVerbs then begin
    Result:=stdEditor.GetVerb(Index)
  end else begin
    case index-stdEditorVerbs of
      0: Result := '&mQuery Editor ...';
      1: Result := '&Add Detail mQuery ...';
      else Result := '';
    end;
  end;
end;

function TmQueryEditor.GetVerbCount: Integer;
begin
  Result:=stdEditorVerbs+2;
end;

procedure TmQueryEditor.ShowWizard;
begin
  dbWizForm:=TdbWizForm.Create( Application);
  try
    dbWizForm.showDataSets:=true;
    dbWizForm.DataBase :=TmQuery(Component).Database;
    dbWizForm.theFormDesigner:=designer;
    if dbWizForm.ShowModal=mrOk then begin
      Designer.Modified;
    end;
  finally
    dbWizForm.free;
  end;
end;

procedure TmQueryEditor.ShowEditor;
Var
   AQuery: TmQuery;
begin
  AQuery := TmQuery(Component);
  if AQuery.DataBase = nil then begin
    ShowMessage ('Assign Database first.');
    exit;
  end;
  if (AQuery <> nil) then begin
    QueryEditDlg:=TQueryEditDlg.Create(Application);
    try
      QueryEditDlg.caption:='Editing mQuery "'+Component.name+'"';
      QueryEditDlg.FMquery:=Tmquery.Create(QueryEditDlg);
       QueryEditDlg.FMquery.DataBase := AQuery.DataBase;
       QueryEditDlg.FMquery.DataSource := AQuery.DataSource;
       QueryEditDlg.DeleteMemo.Lines := AQuery.DeleteSQL;
       QueryEditDlg.InsertMemo.Lines := AQuery.InsertSQL;
       QueryEditDlg.ModifyMemo.Lines := AQuery.ModifySQL;
       QueryEditDlg.SelectMemo.Lines := AQuery.SQL;
       if QueryEditDlg.ShowModal = mrOK then
       begin
         AQuery.DataBase.DataBaseName:=QueryEditDlg.FMquery.DataBase.DataBaseName;
         AQuery.SQL:=QueryEditDlg.SelectMemo.Lines;
         AQuery.DeleteSQL:=QueryEditDlg.DeleteMemo.Lines;
         AQuery.InsertSQL:=QueryEditDlg.InsertMemo.Lines;
         AQuery.ModifySQL:=QueryEditDlg.ModifyMemo.Lines;
         Designer.Modified;
       end;
    finally
       QueryEditDlg.FMquery.Destroy;
       QueryEditDlg.Free;
    end;
  end;
end;

{$ELSE}
implementation
{$ENDIF}
end.

na dziendobry delphi sie przyczepiło do tej linii:

constructor TmQueryEditor.Create(AComponent: TComponent; ADesigner: IFormDesigner);

pzdrawiam
Przemek

0

w pliku MODBC.INC

dodaj linijke dla wersji D3 {$DEFINE QUERYEDITOR}

czyli :
{$IFDEF VER100}
{$DEFINE KNOWNCOMPILER}
{$DEFINE QUERYEDITOR} <-------------------------dodane
{$DEFINE DELPHI3}
{$ENDIF}

i w pliku mqueryex.pas zamien
IFormDesigner na TFormDesigner

i chyba powinno dzialac - jak tak to nie wysylaj mi kartki tylko kopsnij browar skoro z 3miasta jestes :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1