The map won't load anymore on the megademo.exe.
The problem start when i put: GMMap1.Active := True;
Thanks for the help.
try this
var
FMapLoaded: boolean;
procedure TMainForm.GMMapAfterPageLoaded(Sender: TObject;
First: Boolean);
begin
inherited;
if First and not FMapLoaded then
begin
GMMap.DoMap;
FMapLoaded := True;
end;
end;
To solve this problem, you must to change the method TGMMap.DocumentComplete from GMMapVCL unit with this
before
if (pDisp = CurDispatch) then
after
if not FDocLoaded and (pDisp = CurDispatch) then
Related
can you please help me with this issue? See description below.
#author Xavier Martinez (cadetill)
#version 1.5.4
Projekt MegaDemo
After clicking on button Search Direction nothing is happening.
Program cycles in unit GMDirection in procedure Execute:
ExecuteScript('GetDirections', Params);
repeat
TGMGenFunc.ProcessMessages;
until (GetIntegerField(DirectionsForm, DirectionsFormResponse) = 1);
GetRetournedData;!
I temporary solved this problem in GMMap.pas unit
function TGMObjects.ExecuteScript(NameFunct, Params: string): Boolean;
begin
Result := False;
Map.FDocLoaded := true; <<- new line
if (csDesigning in ComponentState) or not Assigned(FMap) or
not Map.Active or not Map.FDocLoaded then Exit;
Result := FMap.ExecuteScript(NameFunct, Params);
end;
I would like to do something like this:
(I want to conserve the functions public so I can access them from other procedures/functions).
The functions are on the same form (frmSequenciador) - I didn't post it for it is huge in its integrity..
function geradorDeVetores():TIntArray;
var
contador: Integer;
vetor: array [1..numMax] of integer;
begin
Randomize;
for contador:=1 to numMax do
begin
if contador = 1 then
vetor[contador]=float_round_down(Random*10);
else vetor[contador]:= ***frmSequenciador.evitaRepeticao(contador, vetor)***;
end;
end;
function evitaRepeticao(pos: integer; vetor:TIntArray):integer;
var
numigual: boolean;
temporario, cont: integer;
begin
numigual:=true;
temporario:= float_round_down(Random*10);
for cont:=1 to pos-1 do
if temporario <> vetor[cont] numigual:=false else numigual:=true;
if numigual=false then evitaRepeticao():=temporario else evitaRepeticao():=***frmSequenciador.evitaRepeticao(pos, vetor)***;
end;
It was a simple matter of removing the frmSequenciador prefix of the functions as Ken White stated.
What I wanted to know is: if two functions are inside the same form unit (thx Jerry), do we need a prefix to call each other?
It seems not. Thanks all!
I am using loadfromdataset function of TGMMarker object in GMLib, but I can't get the IconField to work.
I have a BLOB field with a png image to use as a Icon. I load the very same image file directly from the
folder with no problems, but when I try to do it with the IconField argument it gives error.
Here's the code
inherited;
GMMap1.Active := True;
GMMarker1.LoadFromDataSet(Dscameras.DataSet,'Latitude','Longitude',
'Descrição','Distintivo');
Gives this error :"Erro de Script" "Constante de cadeia não finalizada"
The minimum code is:
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientDataSet1.LoadFromFile('markers.xml');
GMMap1.Active := True;
end;
procedure TForm1.GMMap1AfterPageLoaded(Sender: TObject; First: Boolean);
begin
if First then
begin
GMMap1.DoMap;
GMMarker1.LoadFromDataSet(ClientDataSet1, 'lat', 'lng', 'title');
GMMarker1.ZoomToPoints;
end;
end;
I want to assign a value to a variable when exception occurs.
exception
when excep1 then
var = true;
when excep2 then
var = true;
end;
I want to do something like, Is it possible?
exception
var = true;
when excep1 then
-- do something
when excep2 then
-- do something
end;
Re-raising as Odi suggested would definitely work. You get the same effect by doing things a little differently.
begin
var := true;
... your code that can cause exceptions...
var := false; --var set to false unless an exception was encountered
exception
when exception1 then
...
when exception2 then
...
end;
You could do this with a sub-block, first set the value and then re-raise the exception to handle it:
begin
begin
-- do something
exception
when others then
var = true;
raise; -- re-raise the current exception for further exception handling
end;
exception
when excep1 then
-- do something
when excep2 then
-- do something
end;
Another way is to put it in another procedure, e.g.:
declare
procedure common_exception_routine is
begin
var = true;
end common_exception_routine;
begin
...
exception
when excep1 then
common_exception_routine;
when excep2 then
common_exception_routine;
end;
I'm using Delphi and WebBrowser componenet to navigate a html page . the page have a Combobox . is there any way to call the OnChange event ?
The ComboBox is like this :
<select name="comboname" onchange="Some Javascript codes">
Also , i have used this code :
function TFrmMain.SetComboboxValue(WB: TEmbeddedWB;
SelectName, ItemName: string): Boolean;
var
iForms, iFormItems, iSelectItems: Word;
FormItem: OleVariant;
begin
Result := false;
for iForms := 0 to WB.OleObject.Document.Forms.length - 1 do
begin
FormItem := WB.OleObject.Document.Forms.item(iForms);
for iFormItems := 0 to FormItem.length - 1 do
begin
if (FormItem.item(iFormItems). type = 'select-one') and SameText
(FormItem.item(iFormItems).Name, SelectName) then
begin
for iSelectItems := 0 to FormItem.item(iFormItems).Options.length - 1 do
begin
if SameText(FormItem.item(iFormItems).Options.item(iSelectItems)
.Text, ItemName) then
begin
FormItem.item(iFormItems).SelectedIndex := iSelectItems;
Result := true;
Break;
end;
end;
end;
end;
end;
end;
But it change the value only.
to execute the onchange event you can use the execScript method
check this sample
uses
MSHTML;
var
Doc: IHTMLDocument2;
HTMLWindow: IHTMLWindow2;
begin
Doc := WebBrowser1.Document as IHTMLDocument2;
if not Assigned(Doc) then
Exit;
HTMLWindow := Doc.parentWindow;
if not Assigned(HTMLWindow) then
Exit;
HTMLWindow.execScript('yourfunctioname()', 'JavaScript');
end;
for more info check this excellent article
How to call JavaScript functions in a TWebBrowser from Delphi
Inspired by the response. NET have been using the structures below:
FrameSet Document Elements Item Name Value Change ;
EWB.OleObject.Document.Frames.Item('mainFrame').Document.Forms.Item('invoiceForm').Elements.Item('inputname').Value:= '123456';
or
FrameSet Document Elements Items Lenth;
EWB.OleObject.Document.Forms.Item('invoiceForm').Elements.Length;