Hi,
You can add

ShowMessage('procedure name begin');

and

ShowMessage('procedure name end');

at the begin and at the end of the procedures to know where the error occurs.

Then you can add "ShowMessage" inside the procedure to show the values.
So you can see what's wrong.

Have you tried with another background image (ou file format) ?
Which version of My Visual Database are you using ?

Regards,
jihem

Hi,

When I need to do a task in the background I launch external programs (done with MVD or another devtool) and I use a timer to get the ackknowledges  or the datas.
See the sample below.

My RSS downloader (PODCASTOR) works like that : http://codyssea.com/index.php/2017/08/20/podcastor

Regards,
jihem

var
  AgentGUID:Integer;
  AgentTimr:TTimer;
  AgentTBck:TTimer;
  AgentName:TStringList;
  AgentCBck:TStringList;

procedure AgentStart();
begin
  AgentGUID:=0;
  AgentName:=TStringList.Create();
  AgentCBck:=TStringList.Create();

  AgentTimr:=TTimer.Create(nil);
  AgentTimr.OnTimer:=@AgentOnTimer;
  AgentTimr.Interval:=2000;

  AgentTBck:=TTimer.Create(nil);
  AgentTBck.Interval:=100;
end;

procedure AgentOnTimer();
var
  Indx:Integer;
  GUID:String;
begin
  Indx:=AgentName.Count;
  If Indx>0 Then         
  Begin
    while Indx>0 do
    begin
      Dec(Indx);
      GUID:=Format('%s.txt',[AgentName[Indx]]);
      If FileExists(GUID) Then
      Begin
        AgentTBck.OnTimer:=AgentCBck[Indx];
        AgentTBck.Enabled:=True;
        AgentName.Delete(Indx);
        AgentCBck.Delete(Indx);
        DeleteFile(GUID);
        Indx:=0;
      End;
    end;
    Beep(1000,500);
  End
  Else
    AgentTimr.Enabled:=False;
end;

procedure AgentAcknowledge();
begin
  AgentTBck.Enabled:=False;
end;

procedure AgentStop();
begin
  AgentTimr.Enabled:=False;
  AgentTBck.Enabled:=False;
  AgentTimr.Free;
  AgentTBck.Free;
  AgentName.Free;
  AgentCBck.Free;
end;

procedure AgentTaskRun(Args:String;CallBack:Pointer);
var
  GUID:String;
begin
  Inc(AgentGUID);
  GUID:=IntToHex(AgentGUID,8);
  AgentName.Add(GUID);
  Args:=GUID+' '+Args;
  GUID:=Format('%s.txt',[GUID]);
  AgentCBck.Add(VarToStr(CallBack));

  if FileExists(GUID) then
  begin
    DeleteFile(GUID);
  end;
  OpenFile(Args,'agent.products\Windows\agent.exe');
  If AgentTimr.Enabled=False Then           
  begin
    AgentTimr.Enabled:=True;
  end;
end;

{ - - - }

procedure OnAF;
begin
    AgentAcknowledge;
    Form1.Button1.Caption:='Off';
    ShowMessage('Done.');
end;

procedure Form1_OnClose (Sender: TObject; Action: string);
begin
    AgentStop();
end;

procedure Form1_OnShow (Sender: TObject; Action: string);
begin
  AgentStart();
end;

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
    AgentTaskRun('XXX',@OnAF);
    Form1.Button1.Caption:='On';
end;

begin
  Form1.mniFile.Visible := False;
  Form1.mniOptions.Visible := False;
  Form1.mniSettings.Visible := False;
  Form1.mniReport.Visible := False;
  Form1.mniAbout.Visible := False;
end.

Hi,
I use this on Windows 10 on a lot of computers (and I nether got this issue !?).
The floating point error involve the calculus. Try to replace

Picture.LoadFromFile(GetBackgroundImage());

by

Picture.LoadFromFile('filepath to a test picture');

. Check the values : Picture.Width and Picture.Height.

The error may be linked to :
- a registry access deny
- a forbiden filepath to the picture
- an unsupported picture file (by LoadFromFile)
- a corrupted picture file (with wrong size values)
- an unsupported screen resolution

Let me know if this helps you.

Regards,
jihem

4

(5 replies, posted in Script)

Hi,
Sorry to annoy you again :-/

It's not exactly a crop (even if it tastes like it). It hides the whole image except the rectangle area (most of the space is useless).
I would like to display the 'cropped' part on the entire area of the image field (zoomed).

Thanks
jihem

5

(5 replies, posted in Script)

Thanks for the answer (to hide unused part).

Is there a way to crop a part from the image ?

6

(5 replies, posted in Script)

Hi,
Is there a (simple) way to show only a part of the image in the image field instead of all the image ?
(based on x,y coordinates with width and height of the part to display)
Regards,
jihem

7

(2 replies, posted in Talks about all)

Thanks a lot !!!
Best wishes :-)

8

(2 replies, posted in Script)

Hi,
Thanks for the advice. I will have a look on it.
Regards,
jihem

9

(2 replies, posted in Script)

You can do a lot of tricks with DynamicWrapperX :-)


Click the link to download a 32bit lua dll here :
https://freefr.dl.sourceforge.net/proje … w4_lib.zip

About DynamicWrapperX :
http://www.script-coding.com/dynwrapx_eng.html

function dll:variant;
    var DW:variant;
begin
    DW := CreateOleObject('DynamicWrapperX');
    DW.Register('lua53.dll', 'luaL_newstate', 'r=l');
    DW.Register('lua53.dll', 'luaL_openlibs', 'i=l');
    DW.Register('lua53.dll', 'luaL_loadstring', 'i=ls');
    DW.Register('lua53.dll', 'lua_callk', 'i=luull');
    DW.Register('lua53.dll', 'lua_close', 'i=l');
    result := dw;
    DW := nil;
end;

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
    l:LongInt;
begin
    l:=dll.luaL_newstate();
    dll.luaL_openlibs(l);
    dll.luaL_loadstring(l,'file = io.open("test.txt", "a");file:write("hello")');
    dll.lua_callk(l, 0, 0, 0, 0);
    dll.lua_close(l);

end;

begin
  Form1.mniFile.Visible := False;
  Form1.mniOptions.Visible := False;
  Form1.mniSettings.Visible := False;
  Form1.mniReport.Visible := False;
  Form1.mniAbout.Visible := False;
end.

@vovka3003

Thanks a lot!!! I was looking for a way to call dll since months.

Большое спасибо!!! Я искал способ позвонить в DLL с месяцев. (google translate)

11

(5 replies, posted in General)

Hi,
There is a sample of encrypted sqlite database on the forum ('Full DB Encryption'). I don't remember where but you can search. To use it, you have to replace the sqlite3.dll with the one provided. There are specific commands to set a password and to connect. The topic has a MVD sample with code (very easy to set up). You only have to add this in your script :

begin
    // SQLExecute('PRAGMA rekey=''password';');
    SQLExecute('PRAGMA key = ''password';');
end.


Regards,
jihem

12

(2 replies, posted in General)

MessageBox(Text,Caption,Flags)

The 2nd param (Caption) is the title of the MessageBox.

MessageBox('My message','Title',MB_OK);

Hi,
I use this before using a string in an SQL statement :

function SQLStr(sStr:string):string;
begin
  Result:=Trim(ReplaceStr(sStr,'''',''''''));
end;

Regards,
jihem

14

(6 replies, posted in General)

Hi,
For thoses having the same problem, you can replace MySQL with MariaDB without any change in your MVD project.
The MariaDB licence is less restrictive.
https://mariadb.com/kb/en/library/licensing-faq
Regards,
jihem

Hi,
- Create a new project
- Set Form1 (width:640, height:480),
- Add an Image (Image1),
- Set Image1 (Left:0, Top:0, Width:640, Height:480, Anchors:All, Additional\Center: True)
- Add a script file and put the following code inside (to replace the sample included),
- Add Events (OnClose, OnResize and OnShow) on Form1
- Run...

Or simply download the sample project : http://codyssea.com/downloads/019.zip.

In hope this helps,
Regards,
jihem

var
  FormRatio,PictureRatio:real;
  Picture:TPicture;

procedure Form1_OnResize (Sender: TObject);
var
  width,
  height:integer;
begin
  if PictureRatio>0 then
  begin
    FormRatio:=Form1.Width/Form1.Height;
    if (PictureRatio>FormRatio) then
    begin            
      width:=Round(Form1.Height*PictureRatio);
      Form1.Image1.Width:=width;
      Form1.Image1.left:=Round((Form1.Width-width)/2);
    end;

    if (PictureRatio<FormRatio) then
    begin
      height:=Round(Form1.Width/PictureRatio);
      Form1.Image1.Height:=height;
      Form1.Image1.top:=Round((Form1.Height-height)/2);
    end;
  end;
end;

procedure Form1_OnClose (Sender: TObject; Action: string);
begin
  Picture.Free;
end;

procedure Form1_OnShow (Sender: TObject; Action: string);
begin
  Picture:=TPicture.Create();
  Picture.LoadFromFile(GetBackgroundImage());
  PictureRatio:=Picture.Width/Picture.Height;
  Form1.Image1.Picture:=Picture;
end;
                
function GetBackgroundImage(): string;
var
  Registry: TRegistry;
begin
  Registry := TRegistry.Create();
  try
    Registry.Access := KEY_READ;
    Registry.RootKey := HKEY_CURRENT_USER;
    Registry.OpenKey('Control Panel\Desktop', False);
    Result := Registry.ReadString('Wallpaper');
  finally
    Registry.Free;
  end;
end;

begin
  Form1.mniFile.Visible := False;
  Form1.mniOptions.Visible := False;
  Form1.mniSettings.Visible := False;
  Form1.mniReport.Visible := False;
  Form1.mniAbout.Visible := False;
end.

16

(3 replies, posted in General)

@jean.brezhonek

Hi,
I think this isn't the answer you were waiting for :-(

May be, you can look for an OpenGL ActiveX (glax, plastica,...) and use it with OLE.

var
  vOLE:Variant;
begin
  vOLE:=CreateOleObject('...');
  vOLE....

I have done this before with another language (windev).
Regards,
jihem

Hi,

Bjarke Viksoe wrote an OLE DB Provider allowing you to query XML documents with SQL : https://www.viksoe.dk/code/xmloledb.htm.
I ended with something like the code below...
I thank you folks for your remarks.
Regards,
jihem

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
  adoConn,
  adoRS:Variant;
  i:integer;
begin
  adoConn:=CreateOleObject('ADODB.Connection');
  adoConn.Open('Provider=XmlOleDb.XML;Location='+ExtractFilePath(Application.ExeName)+'\catalog.xml');
  adoConn.CursorLocation:= 3; //adUseClient;
  adoRS:=adoConn.Execute('SELECT * FROM book,info');
  while (not adoRS.EOF) do
  begin
    for i:=0 to adoRS.Fields.Count-1 do
    begin
      log('adoRS.Fields('+IntToStr(i)+')='+adoRS.Fields(i).Name+' = '+adoRS.Fields(i).Value);
    end;
    adoRS.MoveNext();
  end;
  adoRS.Close();
  adoConn.Close();
end;

Hi,
Thanks for your help.
The provided project and XML file is only a sample to show the bug.
In my app, I download a file (and I have no way to change it). It's more complex : Open Street Map format. You can have a look on the current state of my project : http://codyssea.com/index.php/2017/09/16/maposm-wip.
Regards,
jihem

DriveSoft wrote:

Unfrotunately I can't find the reason of error, but if you run this procedure twice, it's works, strangely )

Hi,
It wasn't the answer I was waiting for... I expected an update which solves this.
Thanks for your help. I will do things twice.
Regards,
jihem

Hi,

I use MSXML2.DSOControl to access data stored in a XML file. Everything works well as far as I don't pass an ADODB.Recorset as parameter to a recursive procedure... If I comment the line 22 all the records are read.

If I remove the comment and I let the program explore the sublevels, it crashs at the end of the first sublevel on the adoRS.MoveNext. The reference to adoRS is lost (even if it was working previously on the test adoRS.EOF).

You can download the sample project : http://codyssea.com/downloads/007.zip.

Any help is welcome, I have no hair left... and can't stop scratching my head.

Regards,
jihem


procedure Dump(iLvl:integer;var adoRS:Variant);
var
  i:integer;
  v:Variant;
begin
  while not adoRS.EOF do
  begin
    for i:=0 to adoRS.Fields.Count-1 do
    begin
      if adoRS.Fields(i).Name<>'$Text' then
      begin
        if adoRS.Fields(i).Type=136 then
        begin
          // Dump(iLvl+1,adoRS.Fields(i).Value); // <-- line #22 ; crash if uncommented
        end
        else // =12
        begin
          log(IntToStr(iLvl)+': adoRS.Fields('+IntToStr(i)+') : '+adoRS.Fields(i).Name+' => '+adoRS.Fields(i).Value);
        end;
      end;
    end;
    adoRS.MoveNext;
  end;
end;

Hi,

Toolbox.pas contains some things I have done to manage :
- INI (store window position...),
- SQL (escape quote...),
- Strings (additional functions to extract text within html/xml node, ...),
...
and which are very usefull. I include it (or part of it) in all my projects (with another one called drivesoft.pas which contains usefull things found on the forum).

The wbGetFile.exe download a file : wbGetFile <url of the document to download> <filename>

The full projet is a rss stream downloader http://codyssea.com/index.php/2017/08/20/podcastor.
I have made wbGetFile to download the files in the background (without blocking the app) because the content of rss stream can be really big...

I use a timer to manage the process with some steps : to check if there is something to download, to launch wdGetFile (with OpenFile), to wait from the completion,... and to loop.

In fact, I use MVD to build the UI of my applications and process the data in background with some exe (made with MVD or other languages because MVD isn't multithread and I/O are blocking). The first version of wdGetFile was made with .Net (but I made another with purebasic to have less dependencies).

And finaly I use InstallCreator to build the install.

Regards,
jihem

Well done. It works.
Thanks a lot :-)

DriveSoft wrote:

please make test project to reproduce this problem.

http://codyssea.com/downloads/LoadFromFileUTF8.zip

http://codyssea.com/downloads/LoadFromFileUTF8.PNG

Your sample works well with unicode but not for UTF8 files.

I think you should add 2 native convert functions: EncodeUTF8 and DecodeUTF8 (like the DecodeUTF8 provided in the podcastor projects) to convert to UTF8 (back and forth). It's not a bug. It's a lack of conversion functions. The Web usualy use UTF8 file format (specially ajax calls).

I found this page for Delphi : http://docwiki.embarcadero.com/RADStudi … sion_UTF-8
Adding DetectUTF8Encoding could be a good idea too.

I don't want to be rude. And I am sorry to insist. I got this issue with several languages and it was always solved by using or including these functions (like I did in the previous sample projects). The only problem is that native functions are much faster than the one I wrote in MVD. So please, would you like to include them?

Be sure, I'm very grateful for your help.
Regards,
jihem

Hi,
It was my first attempt. Works like a charm for unicode files but doesn't decode UTF8 files properly...

"Qui veut vraiment résoudre la crise nord-coréenne ?"
instead of
"Qui veut vraiment résoudre la crise nord-coréenne ?"

Regards,
jihem

Hi Dmitry,
You can download the project here :http://codyssea.com/downloads/podcastor.zip .


You can click "import" button to test. The program download a rss.xml file (UTF8 encoded). It loads the file and decodes it (from UTF8 to unicode) and stores the result in a MVD string. Then some data are extracted from the xml and stored in the sqlite file (import table). The log table stores the content of the call to log function (so you can see the time each step require).


I have added the version which uses the my .Net program to convert UTF8 to Unicode :http://codyssea.com/downloads/podcastor-net.zip .


I'm sad to have to use .Net when everything can be done with MVD but it's realy too slow without.
I hope you could add fast native EncodeToUTF8 and DecodeFromUTF8 functions to MVD.


One of my whishes is to have the ability to call external dll from MVD so we don't have to bother you each time we need something.


Thanks for you help

Regards,
jihem