#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11

    [Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source


    Ok, I can call a ListBox in some procedures but not others. For example, in FormCreate I can call it, but in another procedure I get ""[Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source code". Does that error mean I can't call it or it just wont give me code completion? and why is it happening?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Hamburg, DE
    Posts
    71
    Rep Power
    14
    You do know that the other members here aren't psychic, right?

    Post your source so we can see what the problem is
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11
    example:
    Code:
    unit Unit1;
    
    interface
    
    uses
    	Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    	Dialogs, StdCtrls;
    
    type
    	TForm1 = class(TForm)
    		Button1: TButton;
    		lbIEURL: TListBox;
    		procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
    	public
    		{ Public declarations }
    	end;
    
    var
    	Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure clear();
    begin
    lbIEURL.clear; // error
    end;
    
    function GetUrlFromIE (Handle: THandle; List: TStringList): boolean; stdcall;
    var
    	hWndIE, hWndIEChild : HWND;
    	Buffer : array[0..255] of Char;
    begin
    	//get the window caption
    	SendMessage(Handle, WM_GETTEXT, 255, integer(@Buffer[0]));
    	//look for the Internet Explorer window with "Buffer" caption
    	hWndIE := FindWindow('IEFrame', Buffer);
    	if hWndIE > 0 then
    begin
    		//try to get a handle to IE's toolbar container
    		hWndIEChild := FindWindowEx(hWndIE, 0, 'WorkerW', nil);
    		if hWndIEChild > 0 then
    		begin
    			//get a handle to address bar
    			hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ReBarWindow32', nil);
    			if hWndIEChild > 0 then
    			begin
    				//finally, locate combo box and add its text to the list
    				hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ComboBoxEx32', nil);
    				if hWndIEChild > 0 then
    				begin
    					SendMessage(hWndIEChild, WM_GETTEXT, 255, integer(@Buffer));
    					//List.AddObject(Buffer,TObject(hWndIE));
    					List.Add(Buffer)
    				end;
    			end;
    		end;
    	end;
    	//continue enumeration
    	Result :=True;
    end; (*GetUrlFromIE*)
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     clear();  //if I put lbIEURL.clear here, it'd work
     EnumWindows(@GetUrlFromIE, LParam(lbIEURL.Items));
    end;
    
    end.
    and the error
    Code:
    [Error] Unit1.pas(29): Undeclared identifier: 'lbIEURL'
    [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Well, clear() is not a method of TForm1, so it can't access any of its components.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    46
    Rep Power
    11
    In procedure clear() change teh code to:
    Form1.lbIEURL.clear; //should work

    Good Luck!!

    Nitin
    Last edited by Scorpions4ever; July 21st, 2004 at 07:19 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11
    not sure if I got that right, tried a couple different ways of implementing what you said, but I still get errors. Code:
    Code:
    unit Unit1;
    
    interface
    
    uses
    	Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    	Dialogs, StdCtrls;
    
    type
    	TForm1 = class(TForm)
    		Button1: TButton;
    		lbIEURL: TListBox;
    		procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
    	public
    		{ Public declarations }
    	end;
    
    var
    	Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.clear;
    begin
    lbIEURL.clear; // error
    end;
    
    function GetUrlFromIE (Handle: THandle; List: TStringList): boolean; stdcall;
    var
    	hWndIE, hWndIEChild : HWND;
    	Buffer : array[0..255] of Char;
    begin
    	//get the window caption
    	SendMessage(Handle, WM_GETTEXT, 255, integer(@Buffer[0]));
    	//look for the Internet Explorer window with "Buffer" caption
    	hWndIE := FindWindow('IEFrame', Buffer);
    	if hWndIE > 0 then
    begin
    		//try to get a handle to IE's toolbar container
    		hWndIEChild := FindWindowEx(hWndIE, 0, 'WorkerW', nil);
    		if hWndIEChild > 0 then
    		begin
    			//get a handle to address bar
    			hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ReBarWindow32', nil);
    			if hWndIEChild > 0 then
    			begin
    				//finally, locate combo box and add its text to the list
    				hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ComboBoxEx32', nil);
    				if hWndIEChild > 0 then
    				begin
    					SendMessage(hWndIEChild, WM_GETTEXT, 255, integer(@Buffer));
    					//List.AddObject(Buffer,TObject(hWndIE));
    					List.Add(Buffer)
    				end;
    			end;
    		end;
    	end;
    	//continue enumeration
    	Result :=True;
    end; (*GetUrlFromIE*)
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     clear;  //if I put lbIEURL.clear here, it'd work
     EnumWindows(@GetUrlFromIE, LParam(lbIEURL.Items));
    end;
    
    end.
    and the errors:
    Code:
    [Error] Unit1.pas(27): Undeclared identifier: 'clear'
    [Error] Unit1.pas(29): Undeclared identifier: 'lbIEURL'
    [Error] Unit1.pas(68): Undeclared identifier: 'clear'
    [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    46
    Rep Power
    11
    It shoudl either be :
    procedure clear()
    begin
    Form1.lbIEURL.clear; //should work
    end;

    OR

    declare a procedure in your private
    procedure clear();

    then you should have
    procedure TForm1.clear();
    begin
    lbIEURL.clear;
    end;

    Good Luck
    Last edited by Scorpions4ever; July 21st, 2004 at 07:19 PM.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11
    Works like a charm, thanks a lot everyone!

IMN logo majestic logo threadwatch logo seochat tools logo