|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
[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
|
|||
|
|||
|
You do know that the other members here aren't psychic, right?
Post your source so we can see what the problem is ![]() |
|
#3
|
|||
|
|||
|
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' |
|
#4
|
||||
|
||||
|
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 Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month |
|
#5
|
|||
|
|||
|
In procedure clear() change teh code to:
Form1.lbIEURL.clear; //should work Good Luck!! Nitin Last edited by Scorpions4ever : July 21st, 2004 at 08:19 PM. |
|
#6
|
|||
|
|||
|
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' |
|
#7
|
|||
|
|||
|
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 08:19 PM. |
|
#8
|
|||
|
|||
|
Works like a charm, thanks a lot everyone!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > [Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|