Link to home
Start Free TrialLog in
Avatar of prasiddutta
prasidduttaFlag for India

asked on

Error message in Windows Vista

Respected Expert,
I download a Borland Delphi source code from planet source. In XP it's run very fine. No problem.
But in Vista it give error. Plz give me a solution...
I attach project file.
Link: http://www.slingfile.com/file/WTVrZezWUF
Avatar of Geert G
Geert G
Flag of Belgium image

what error, what line of code gives the error ?

you will need to be a lot more specific

this is the second similar question you opened
after trying to delete the old one

why ?
Avatar of prasiddutta

ASKER

Error appear when I compile!
I take two screenshot

error-1.jpg
error-2.jpg
Geert_Gruwez: Yes u r right! But there have few error to understand experts. Thus I re-post with proper description.
Error appear when I compile!
this is an error while you run the application, not in compile time

Hit ok, hit F7, and look where the app stops, then post that surrounding code.
if the cpu window is open close that and use the run menu to show execution point
indeed,
help is only possible with a good description of the problem

it's like going to a garage and asking the mechanic "please fix my car"
without explaining the problem
Sir, It's better if you handle in your hand. After clicking Ok I press F7. Cursor going to "BarLabel16.Left:=114;"

wow,
bad code man

it is unclear to me as why you don't get a lot of errors in this app
you are using global variables objects in different pieces of code

just the passform has this in the interface declaration:
var
  DelphiReg: TRegistry;
  Password, TrayIcon, Language: string;

this should be removed and changed
see follow up snippet



var
  PassForm: TPassForm;
  DelphiReg: TRegistry;
  Password, TrayIcon, Language: string;
 
implementation
 
uses MainUnit;
 
{$R *.dfm}
 
procedure TPassForm.CancelButtonClick(Sender: TObject);
begin
  Application.Terminate;
end;
 
procedure TPassForm.FormShow(Sender: TObject);
begin
  DelphiReg := TRegistry.Create;
  DelphiReg.RootKey := HKEY_CLASSES_ROOT;
  if DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False) then
   begin
    if DelphiReg.ValueExists('P') then Password := DelphiReg.ReadString('P');
    if DelphiReg.ValueExists('T') then TrayIcon := '1' else TrayIcon := '0';
    if DelphiReg.ValueExists('L') then Language := DelphiReg.ReadString('L') else Language := 'E';
   end;
  DelphiReg.Destroy;
  if Language = 'E' then
   begin
    PassForm.Caption := 'Password';
    PassLabel.Caption := 'Enter password:';
    OKButton.Caption := 'OK';
    CancelButton.Caption := 'Cancel';
   end;
  if Language = 'MC' then
   begin
    PassForm.Caption := 'Øèôðà';
    PassLabel.Caption := 'Âíåñåòå øèôðà:';
    OKButton.Caption := 'Äîáðî';
    CancelButton.Caption := 'Îòêàæè';
   end;
  if Language = 'ML' then
   begin
    PassForm.Caption := 'Sifra';
    PassLabel.Caption := 'Vnesete sifra:';
    OKButton.Caption := 'Dobro';
    CancelButton.Caption := 'Otkazi';
   end;
end;
 
procedure TPassForm.OKButtonClick(Sender: TObject);
begin
  if PassEdit.Text = Password then
   begin
    Password := '';
    if TrayIcon = '0' then PassTimer.Enabled := True;
    if TrayIcon = '1' then PassTimer2.Enabled := True;
   end
  else
   begin
    if Language = 'E' then MessageDlg('Wrong password!', mtWarning, [mbOK], IDOK);
    if Language = 'MC' then MessageDlg('Ïîãðåøíà øèôðà!', mtWarning, [mbOK], IDOK);
    if Language = 'ML' then MessageDlg('Pogresna sifra!', mtWarning, [mbOK], IDOK);
   end;
   PassEdit.Clear;
   PassEdit.SetFocus;
end;
 
procedure TPassForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Password = '' then MainForm.Show else Application.Terminate;
end;
 
procedure TPassForm.PassEditKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then OKButton.Click;
end;
 
procedure TPassForm.PassTimerTimer(Sender: TObject);
begin
  DelphiReg := TRegistry.Create;
  DelphiReg.RootKey := HKEY_CLASSES_ROOT;
  DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False);
  PassForm.Hide;
  MainForm.Show;
  PassTimer.Enabled := False;
  DelphiReg.Destroy;
end;
 
procedure TPassForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var Spot: TPoint;
begin
  {If you forget password just click there - Form top left corner (1, 1)}
  Spot.X := 1;
  Spot.Y := 1;
  if (X = Spot.X) and (Y = Spot.Y) then
   begin
    DelphiReg := TRegistry.Create;
    DelphiReg.RootKey := HKEY_CLASSES_ROOT;
    DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False);
    PassEdit.Text := DelphiReg.ReadString('P');
    DelphiReg.Destroy;
   end;
end;
 
procedure TPassForm.PassTimer2Timer(Sender: TObject);
begin
  DelphiReg := TRegistry.Create;
  DelphiReg.RootKey := HKEY_CLASSES_ROOT;
  DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False);
  PassTimer2.Enabled := False;
  DelphiReg.DeleteValue('T');
  MainForm.ApplyButton.Click;
  PassForm.Hide;
  DelphiReg.Destroy;
end;
 
end.

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I remove paasform, language unit from project. Still same problem. Need actual help please.
var
  PassForm: TPassForm;
  DelphiReg: TRegistry;
  Password, TrayIcon, Language: string;
 
implementation
 
uses MainUnit;
 
{$R *.dfm}
 
procedure TPassForm.CancelButtonClick(Sender: TObject);
begin
  Application.Terminate;
end;
 
procedure TPassForm.FormShow(Sender: TObject);
begin
  DelphiReg := TRegistry.Create;
  DelphiReg.RootKey := HKEY_CLASSES_ROOT;
  if DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False) then
   begin
    if DelphiReg.ValueExists('P') then Password := DelphiReg.ReadString('P');
    if DelphiReg.ValueExists('T') then TrayIcon := '1' else TrayIcon := '0';
    if DelphiReg.ValueExists('L') then Language := DelphiReg.ReadString('L') else Language := 'E';
   end;
  DelphiReg.Destroy;
  if Language = 'E' then
   begin
    PassForm.Caption := 'Password';
    PassLabel.Caption := 'Enter password:';
    OKButton.Caption := 'OK';
    CancelButton.Caption := 'Cancel';
   end;
  if Language = 'MC' then
   begin
    PassForm.Caption := 'Øèôðà';
    PassLabel.Caption := 'Âíåñåòå øèôðà:';
    OKButton.Caption := 'Äîáðî';
    CancelButton.Caption := 'Îòêàæè';
   end;
  if Language = 'ML' then
   begin
    PassForm.Caption := 'Sifra';
    PassLabel.Caption := 'Vnesete sifra:';
    OKButton.Caption := 'Dobro';
    CancelButton.Caption := 'Otkazi';
   end;
end;
 
procedure TPassForm.OKButtonClick(Sender: TObject);
begin
  if PassEdit.Text = Password then
   begin
    Password := '';
    if TrayIcon = '0' then PassTimer.Enabled := True;
    if TrayIcon = '1' then PassTimer2.Enabled := True;
   end
  else
   begin
    if Language = 'E' then MessageDlg('Wrong password!', mtWarning, [mbOK], IDOK);
    if Language = 'MC' then MessageDlg('Ïîãðåøíà øèôðà!', mtWarning, [mbOK], IDOK);
    if Language = 'ML' then MessageDlg('Pogresna sifra!', mtWarning, [mbOK], IDOK);
   end;
   PassEdit.Clear;
   PassEdit.SetFocus;
end;
 
procedure TPassForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Password = '' then MainForm.Show else Application.Terminate;
end;
 
procedure TPassForm.PassEditKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then OKButton.Click;
end;
 
procedure TPassForm.PassTimerTimer(Sender: TObject);
begin
  DelphiReg := TRegistry.Create;
  DelphiReg.RootKey := HKEY_CLASSES_ROOT;
  DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False);
  PassForm.Hide;
  MainForm.Show;
  PassTimer.Enabled := False;
  DelphiReg.Destroy;
end;
 
procedure TPassForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var Spot: TPoint;
begin
  {If you forget password just click there - Form top left corner (1, 1)}
  Spot.X := 1;
  Spot.Y := 1;
  if (X = Spot.X) and (Y = Spot.Y) then
   begin
    DelphiReg := TRegistry.Create;
    DelphiReg.RootKey := HKEY_CLASSES_ROOT;
    DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False);
    PassEdit.Text := DelphiReg.ReadString('P');
    DelphiReg.Destroy;
   end;
end;
 
procedure TPassForm.PassTimer2Timer(Sender: TObject);
begin
  DelphiReg := TRegistry.Create;
  DelphiReg.RootKey := HKEY_CLASSES_ROOT;
  DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False);
  PassTimer2.Enabled := False;
  DelphiReg.DeleteValue('T');
  MainForm.ApplyButton.Click;
  PassForm.Hide;
  DelphiReg.Destroy;
end;
 
end.

Open in new window

you should follow all the recommendations in all the pieces of code

otherwise you have a possibility of 400% of getting an error

and this is the worst one ...

var
  DelphiReg: TRegistry;
 
this would be more in the direction of what i suggest :

the rest is up to you
type
  TPassForm = class(TForm)
    // removed
  
  private
    fLanguage: string;
    fPassword: string;
    fTrayIcon: string;
  protected
  
  public
    protected Language: string read fLanguage;
  end;
  
 
var
  PassForm: TPassForm;
 
implementation
 
{$R *.dfm}
 
procedure TPassForm.CancelButtonClick(Sender: TObject);
begin
  Application.Terminate;
end;
 
procedure TPassForm.FormShow(Sender: TObject);
var DelphiReg: TRegistry;
begin
  DelphiReg := TRegistry.Create;
  try
    DelphiReg.RootKey := HKEY_CLASSES_ROOT;
    if DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False) then
    begin
      if DelphiReg.ValueExists('P') then fPassword := DelphiReg.ReadString('P');
      if DelphiReg.ValueExists('T') then fTrayIcon := '1' else fTrayIcon := '0';
      if DelphiReg.ValueExists('L') then fLanguage := DelphiReg.ReadString('L') else fLanguage := 'E';
    end else ShowMessage('No Wordpad !');
  finally
    DelphiReg.Free;
  end;
  if fLanguage = 'E' then
  begin
    Caption := 'Password';
    PassLabel.Caption := 'Enter password:';
    OKButton.Caption := 'OK';
    CancelButton.Caption := 'Cancel';
  end;
  if fLanguage = 'MC' then
  begin
    Caption := 'Øèôðà';
    PassLabel.Caption := 'Âíåñåòå øèôðà:';
    OKButton.Caption := 'Äîáðî';
    CancelButton.Caption := 'Îòêàæè';
  end;
  if fLanguage = 'ML' then
  begin
    Caption := 'Sifra';
    PassLabel.Caption := 'Vnesete sifra:';
    OKButton.Caption := 'Dobro';
    CancelButton.Caption := 'Otkazi';
  end;
end;
 
procedure TPassForm.OKButtonClick(Sender: TObject);
begin
  if PassEdit.Text = fPassword then
  begin
    fPassword := '';
    if fTrayIcon = '0' then PassTimer.Enabled := True;
    if fTrayIcon = '1' then PassTimer2.Enabled := True;
  end
    else
  begin
    if fLanguage = 'E' then MessageDlg('Wrong password!', mtWarning, [mbOK], IDOK);
    if fLanguage = 'MC' then MessageDlg('Ïîãðåøíà øèôðà!', mtWarning, [mbOK], IDOK);
    if fLanguage = 'ML' then MessageDlg('Pogresna sifra!', mtWarning, [mbOK], IDOK);
  end;
  PassEdit.Clear;
  PassEdit.SetFocus;
end;
 
procedure TPassForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if fPassword <> '' then 
    Application.Terminate
  else 
    Application.MainForm.Show;
end;
 
procedure TPassForm.PassEditKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then OKButton.Click;
end;
 
procedure TPassForm.PassTimerTimer(Sender: TObject);
begin
  PassTimer.Enabled := False; // move this to top otherwise you may get circular calls
  Hide;
  Application.MainForm.Show;
end;
 
procedure TPassForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var 
  Spot: TPoint;
  DelphiReg: TRegistry;
begin
  {If you forget password just click there - Form top left corner (1, 1)}
  Spot.X := 1;
  Spot.Y := 1;
  if (X = Spot.X) and (Y = Spot.Y) then
  begin
    DelphiReg := TRegistry.Create;
    try
      DelphiReg.RootKey := HKEY_CLASSES_ROOT;
      if DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False) then 
        PassEdit.Text := DelphiReg.ReadString('P')
      else 
        ShowMessage('No Wordpad !');
    finally
      DelphiReg.Free;
    end;
  end;
end;
 
procedure TPassForm.PassTimer2Timer(Sender: TObject);
var DelphiReg: TRegistry;
begin
  PassTimer2.Enabled := False;
  DelphiReg := TRegistry.Create;
  try
    DelphiReg.RootKey := HKEY_CLASSES_ROOT;
    if DelphiReg.OpenKey('Wordpad.Document.1\CLSID', False) then 
      DelphiReg.DeleteValue('T');
  finally
    DelphiReg.Free;
  end;
  Hide;
  TButton(Application.MainForm.FindComponent('ApplyButton')).Click;
end;
 
end.

Open in new window

Please think about MainForm. I removed PassForm & Language unit from project.
Just tell me what I do? What need to change?
You can also download from : http://www.slingfile.com/file/WTVrZezWUF
(virus free site)
look at the differences using a tool like "beyond compare" from www.scootersoftware.com

read my suggestions and follow them.

if you are new to delphi, read some of these :
http://delphi.veerle-en-geert.be/ebooks.htm
Okay, I'll try.
Can you modify that project (remove pass form and lang)? And upload here. It's the best. Then I easily find out my problem!
do you have any experience in programming in delphi ?
Yes! But problem in English.
Geert_Gruwez: I try what you say but problem persits. Although I'm not an expert in Delphi.
this site is not a site where you get a whole workover of your project
i will give advice but not remake your whole project

you downloaded this project from a site, just find a other similar project for vista and download that

or open a project at getacoder.com and pay for the conversion
Already I pay here to meet experts!
Thanks for your valuable comment.