* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
RichMemo / Re: Add of spell check to richmemo component
« Last post by Raf20076 on Today at 10:39:08 am »
I can see that this is based on https://sourceforge.net/projects/nhunspelldelphi/

It's a good direction to develop spellchecking component but I have noticed error in working. For example when I use polish dictionary pl-dict it shows Portuguese (Portugal) should be Polish(Poland)and there are no polish letters like łąśćżźę etc intead of there are blank spaces for example  jabłko (apple) it shows jab ko.

I have found also this https://sourceforge.net/projects/hunspell-delphi/?source=directory

http://www.delphicode.co.uk/delphi-spell-check/

Thanks
2
Beginners / Re: Overwrite curent line
« Last post by ASerge on Today at 09:49:12 am »
I cheching configuration on laptops and everyone laptop saving his configuration on one file in network (buffer directory 'C:\Users\Public\print\check') with name matherboard name. My program geting this file and saving in another file 'C:\Users\Public\print\checkall\all.csv' . If buffer file name exist in 'C:\Users\Public\print\checkall\all.csv' like text, i want to replace information in curent line on 'C:\Users\Public\print\checkall\all.csv' with a new information from (buffer directory 'C:\Users\Public\print\check') , because the laptop configuration may be a diferent (ram, hdd, odd).
In your code, only one random file is processed (the last one in the enumeration). But you need everything. And, although this is not said, I suppose that if there is no source information, then it needs to be added. Then better something like this:
Code: Pascal  [Select]
  1. procedure AddOrReplaceInList(InList: TStringList; const ContainsPart: string;
  2.   NewLines: TStringList);
  3. var
  4.   IndexOfStart: Integer;
  5.   i: Integer;
  6. begin
  7.   IndexOfStart := -1;
  8.   for i := InList.Count - 1 downto 0 do
  9.     if Pos(ContainsPart, InList[i]) > 0 then
  10.     begin
  11.       IndexOfStart := i;
  12.       InList.Delete(i);
  13.     end;
  14.   if IndexOfStart < 0 then
  15.     IndexOfStart := InList.Count;
  16.   for i := NewLines.Count - 1 downto 0 do
  17.     InList.Insert(IndexOfStart, NewLines[i]);
  18. end;
  19.  
  20. procedure AppendNewInfo(const FromDir: string; const InFile: string);
  21. var
  22.   NewFiles: TStringList;
  23.   AllData: TStringList;
  24.   AppenedLines: TStringList;
  25.   FullFileName, NameOnly: string;
  26. begin
  27.   NewFiles := FileUtil.FindAllFiles(FromDir, '', False, 0);
  28.   try
  29.     if NewFiles.Count = 0 then
  30.       Exit;
  31.     AllData := TStringList.Create;
  32.     try
  33.       AllData.LoadFromFile(InFile);
  34.       AppenedLines := TStringList.Create;
  35.       try
  36.         for FullFileName in NewFiles do
  37.         begin
  38.           AppenedLines.LoadFromFile(FullFileName);
  39.           NameOnly := ExtractFileName(FullFileName);
  40.           AddOrReplaceInList(AllData, NameOnly, AppenedLines);
  41.         end;
  42.       finally
  43.         AppenedLines.Free;
  44.       end;
  45.       AllData.SaveToFile(InFile);
  46.     finally
  47.       AllData.Free;
  48.     end;
  49.     for FullFileName in NewFiles do
  50.       DeleteFile(FullFileName);
  51.   finally
  52.     NewFiles.Free;
  53.   end;
  54. end;
  55. //...
  56. AppendNewInfo('C:\Users\Public\print\check', 'C:\Users\Public\print\checkall\all.csv');
3
TAChart / Re: 3D on TAChart
« Last post by mtanner on Today at 09:39:03 am »
I thought this item looked just what I want - to call gnuplot from my program and retrieve the chart produced. But I cannot get it to work.

Installed gnuplot. Tested it worked with a simple "plot sin(x)".

Created a test Lazarus program using the code above. (Also assigned the SCRIPT to a TMemo so I could check the script being created.)

When I click the plot button I can see the gnuplot console window flash up then disappear. Too quick to read, but doing it repeatedly I can just about make out that it's showing a single line, an error message which I think says it cannot open the image file.

How can I make the gnuplot window not close, so I can read the messages more reliably?

Is this code still current - there seem to be more than one gnuplot...  exe files in the current gnuplot distribution, am I using the right one?

I didn't understand why the GetTempFileName has a first parameter of ".", which just gives an invalid filename. So I changed it to a specifix directory, or to null.
4
General / SendInput() being ignored
« Last post by pinkVeil on Today at 08:58:49 am »
I am trying to simulate input using SendInput() function from WinAPI. It seem to be working fine when I hard code a couple of inputs and send them. But when I add INPUTs at run time and send them via the same function, nothing happens.

I add INPUTs at run time by adding them into a TList and then reading that list into an array of INPUTs, that array will then be given as one of the parameters to SendInput();

The weird thing is, is that SendInput() returns the correct Int value (the amount of successful inputs that were put into input streams), which means that evens are being inserted into input streams. But as I said, nothing seems to happen.

I'm new to WinAPI and I'm a Delphi rookie, so I'm stuck and asking for help.


Here are some code snippets that might be useful to you:
This is the OnTimer function that is being called over and over again to grab events from my TList of INPUTs and send them to input streams.
Code: Pascal  [Select]
  1. procedure TMainForm.AutoPressTimer(Sender: TObject);
  2. var
  3.   i,j,k: longInt;
  4.   action: TAutoAction;
  5.   amountOfInputsContiguos: longInt;
  6.   tempInputBufferArray: array of INPUT;
  7.   tempInput: ^INPUT;
  8. begin
  9.   if (isWaitingActionTimer) then
  10.   begin
  11.     exit;
  12.   end;
  13.   // execute all inputs in actionList
  14.   //showMessage('Amount of auto actions: ' + IntToStr(autoActions.Count));
  15.   tempInputBuffer.Clear;
  16.  
  17.   amountOfInputsContiguos := 0;
  18.   for i:=0 to autoActions.Count-1 do
  19.   begin
  20.     action := autoActions.Items[i];
  21.     tempInputBuffer.Add(@action.inputAction);
  22.     Inc(amountOfInputsContiguos);
  23.  
  24.     if (action.waitTimer.Interval <> 0) then // they are not contiguos, let's sendInput whatever's in the buffer
  25.     begin
  26.       //
  27.       setLength(tempInputBufferArray, amountOfInputsContiguos);
  28.       for j:=0 to amountOfInputsContiguos-1 do
  29.       begin
  30.         tempInput := tempInputBuffer[j];
  31.         tempInputBufferArray[j] := tempInput^;
  32.       end;
  33.  
  34.       SendInput(amountOfInputsContiguos, @tempInputBufferArray, sizeof(INPUT));
  35.       amountOfInputsContiguos := 0;
  36.       zeroMemory(tempInputBufferArray, amountOfInputsContiguos);
  37.       tempInputBuffer.Clear;
  38.  
  39.       action.waitTimer.Enabled:=true;
  40.       isWaitingActionTimer := true;
  41.       exit;
  42.     end
  43.     else
  44.     begin
  45.       // they are contiguios just put it in the queue
  46.  
  47.     end;
  48.   end;
  49.  
  50.   // finish off remaining input if there are any
  51.   if (amountOfInputsContiguos <> 0) then
  52.   begin
  53.     setLength(tempInputBufferArray, amountOfInputsContiguos);
  54.     for j:=0 to amountOfInputsContiguos-1 do
  55.     begin
  56.       tempInput := tempInputBuffer[j];
  57.       tempInputBufferArray[j] := tempInput^;
  58.     end;
  59.  
  60.     SendInput(amountOfInputsContiguos, @tempInputBufferArray, sizeof(INPUT));
  61.     amountOfInputsContiguos := 0;
  62.     zeroMemory(tempInputBufferArray, amountOfInputsContiguos);
  63.     tempInputBuffer.Clear;
  64.   end;
  65. end;
  66.  

This function populates my TList of INPUTs:
Code: Pascal  [Select]
  1. procedure TAddAutoActionForm.AddActionButtonClick(Sender: TObject);
  2. var
  3.   newInput: INPUT;
  4.   newWaitInterval: LONG;
  5. begin
  6.   if (KeyboardInputInfoBox.Visible) and ((KeyDetectedEdit.Caption = '') or (VKDetectedEdit.Caption = '') or (ScanCodeDetectedEdit.Caption = '')) then
  7.   begin
  8.     //
  9.     Application.MessageBox('Key detection failed! Try again!', 'Error', MB_ICONWARNING or MB_OK);
  10.     exit;
  11.   end;
  12.  
  13.   if (InputSelectionBox.Items[InputSelectionBox.ItemIndex] = 'Keyboard') then
  14.   begin
  15.     //
  16.     newInput.type_ := INPUT_KEYBOARD;
  17.     newInput.ki.dwExtraInfo := 0;
  18.     newInput.ki.dwFlags := KEYEVENTF_SCANCODE or KEYEVENTF_UNICODE;
  19.     if (InputTypeCombo1.Items[InputTypeCombo1.ItemIndex] = 'Release a button') then
  20.     begin
  21.       showMessage('Key up');
  22.       newInput.ki.dwFlags := newInput.ki.dwFlags or KEYEVENTF_KEYUP;
  23.     end
  24.     else
  25.     begin
  26.  
  27.       showMessage('Key down');
  28.     end;
  29.     newInput.ki.time := 0;
  30.     newInput.ki.wScan := StrToInt(ScanCodeDetectedEdit.Caption);
  31.     newInput.ki.wVk := StrToInt(VKDetectedEdit.Caption);
  32.   end
  33.   else
  34.   begin
  35.     //
  36.     newInput.type_ := INPUT_MOUSE;
  37.     newInput.mi.time:=0;
  38.     newInput.mi.dwFlags:=0;
  39.     if (InputTypeCombo.Items[InputTypeCombo.ItemIndex] = 'Release a button') then
  40.     begin
  41.       //
  42.       newInput.mi.dx:=0;
  43.       newInput.mi.dy:=0;
  44.  
  45.       if (InputButtonCombo.Items[InputButtonCombo.ItemIndex] = 'LMB') then
  46.       begin
  47.         showMessage('LMB UP');
  48.         newInput.mi.dwFlags:=MOUSEEVENTF_LEFTUP;
  49.       end
  50.       else if (InputButtonCombo.Items[InputButtonCombo.ItemIndex] = 'RMB') then
  51.       begin
  52.         showMessage('RMB UP');
  53.         newInput.mi.dwFlags:=MOUSEEVENTF_RIGHTUP;
  54.       end
  55.       else
  56.       begin
  57.         showMessage('MMB UP');
  58.         newInput.mi.dwFlags:=MOUSEEVENTF_MIDDLEUP;
  59.       end;
  60.     end
  61.     else if (InputTypeCombo.Items[InputTypeCombo.ItemIndex] = 'Press a button') then
  62.     begin
  63.       //
  64.       newInput.mi.dx:=0;
  65.       newInput.mi.dy:=0;
  66.  
  67.       if (InputButtonCombo.Items[InputButtonCombo.ItemIndex] = 'LMB') then
  68.       begin
  69.         showMessage('LMB DOWN');
  70.         newInput.mi.dwFlags:=MOUSEEVENTF_LEFTDOWN;
  71.       end
  72.       else if (InputButtonCombo.Items[InputButtonCombo.ItemIndex] = 'RMB') then
  73.       begin
  74.         showMessage('RMB DOWN');
  75.         newInput.mi.dwFlags:=MOUSEEVENTF_RIGHTDOWN;
  76.       end
  77.       else
  78.       begin
  79.         showMessage('MMB DOWN');
  80.         newInput.mi.dwFlags:=MOUSEEVENTF_MIDDLEDOWN;
  81.       end;
  82.     end
  83.     else
  84.     begin
  85.       // Move !
  86.       newInput.mi.dx := StrToInt(MovementXEdit.Caption) * (65536 div GetSystemMetrics(SM_CXSCREEN)); //x being coord in pixels
  87.       newInput.mi.dy :=  StrToInt(MovementYEdit.Caption) * (65536 div GetSystemMetrics(SM_CYSCREEN)); //y being coord in pixels
  88.       newInput.mi.dwFlags := MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MOVE;
  89.     end;
  90.   end;
  91.  
  92.   newWaitInterval := StrToInt(DelayEdit.Caption);
  93.  
  94.   autoActions.Add(TAutoAction.Create(newInput, newWaitInterval));
  95. end;
  96.  

If you're really interested in helping me, here's the full project: https://drive.google.com/open?id=0B3BcZ_k2AnDZQ1FYRzlzZVBOS3M
5
Beginners / Re: LoadLibrary + Threads = Crash?
« Last post by ASerge on Today at 08:53:07 am »
Here is a updated version for all, that includes buffer + length and that will work with all platforms:
Code: Pascal  [Select]
  1. //...
  2. function Process(const Buffer: PChar; const Len: Integer; Num1: Integer): Boolean; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  3. begin
  4.     StrLCopy(Buffer, 'Hello World', Len);
  5.     Result := True;    
  6. end;
  7. //...
External data may be incorrect. Behavior, as in WinApi
Code: Pascal  [Select]
  1. uses Windows, SysUtils;
  2.  
  3. function Process(const Buffer: PAnsiChar; SizeIn: Integer; SizeOut: PInteger): Boolean;{$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  4. const
  5.   CSomeData = 'Hello World';
  6. begin
  7.   if Buffer = nil then
  8.   begin
  9.     if (SizeIn <> 0) or not Assigned(SizeOut) then
  10.     begin
  11.       SetLastError(ERROR_INVALID_PARAMETER);
  12.       Exit(False);
  13.     end;
  14.     SizeOut^ := Length(CSomeData) + 1; // Required buffer include last #0
  15.     Exit(True);
  16.   end;
  17.   if SizeIn <= Length(CSomeData) then
  18.   begin
  19.     if Assigned(SizeOut) then
  20.       SizeOut^ := Length(CSomeData) + 1;
  21.     SetLastError(ERROR_INSUFFICIENT_BUFFER);
  22.     Exit(False);
  23.   end;
  24.   if Assigned(SizeOut) then
  25.     SizeOut^ := Length(CSomeData); // On success return only length, without last #0
  26.   StrLCopy(Buffer, CSomeData, Length(CSomeData));
  27.   SetLastError(ERROR_SUCCESS);
  28.   Result := True;
  29. end;
6
Designer / Re: Delphi Forms
« Last post by JuhaManninen on Today at 08:23:42 am »
OK, if I convert a "project" file it does not appear to trickle down
through all of the used units and forms, so I must be doing it wrong.
Ok, maybe it does not recognize the units as part of the project. You have 2 choises then:
1. Add them to the project in Delphi before converting.
2. Select all units at once when using the "Convert Delphi Unit to Lazarus unit ..." feature. The file open dialog has multi-select enabled.

Quote
For example: if I convert one particular DFM file I get a "syntax error",
but it doesn't appear to show me where (and what) the error is!
It does not handle all error situations well. Can you attach the problematic unit for testing?

Quote
I am sure that these are problems from my ignorance, and yes, the
20,000 odd lines of code program is very old, as am I.
People suggested other tools for converting binary form files but the converter can do that piece perfectly well. No need for other tools for that.
7
General / listview move item up or down
« Last post by Ericktux on Today at 07:43:59 am »
hi my friends, I have found this code for move items up or down in listview, But when I move to the beginning or the end shows error, help me please.  :(

Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
  9.   Buttons;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BitBtn1: TBitBtn;
  17.     BitBtn2: TBitBtn;
  18.     ListView1: TListView;
  19.     procedure BitBtn1Click(Sender: TObject);
  20.     procedure BitBtn2Click(Sender: TObject);
  21.     procedure FormCreate(Sender: TObject);
  22.   private
  23.     { private declarations }
  24.   public
  25.     procedure ExchangeItems(lv: TListView; const i, j: Integer);
  26.     { public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. { TForm1 }
  37.  
  38. procedure tform1.ExchangeItems(lv: TListView; const i, j: Integer);
  39. var
  40.   tempLI: TListItem;
  41.   enumerando: integer;
  42. begin
  43. ListView1.MultiSelect:=false;
  44.  
  45.   lv.Items.BeginUpdate;
  46.   try
  47.     tempLI := TListItem.Create(lv.Items);
  48.     tempLI.Assign(lv.Items.Item[i]);
  49.     lv.Items.Item[i].Assign(lv.Items.Item[j]);
  50.     lv.Items.Item[j].Assign(tempLI);
  51.     tempLI.Free;
  52.  
  53.   finally
  54.     lv.Items.EndUpdate
  55.   end;
  56.   lv.Items.Item[j].Selected:= True;
  57.   lv.SetFocus;
  58.   ListView1.MultiSelect:=true;
  59.  
  60.  
  61.         begin // volviendo a enumerar después de borrar
  62.         for enumerando := 0 to ListView1.Items.Count-1 do
  63.         ListView1.Items[enumerando].Caption := IntToStr(enumerando+1);
  64.         end;
  65. end;
  66.  
  67. procedure TForm1.FormCreate(Sender: TObject);
  68. var
  69.   enumerando: integer;
  70. begin
  71.     with Form1.ListView1.Items.Add do
  72.   begin
  73.   Caption:= '';
  74.   SubItems.Add('erick');
  75.   SubItems.Add('caceres');
  76.   SubItems.Add('peña');
  77.   end;
  78.  
  79.     with Form1.ListView1.Items.Add do
  80.   begin
  81.   Caption:= '';
  82.   SubItems.Add('juan');
  83.   SubItems.Add('galvez');
  84.   SubItems.Add('soto');
  85.   end;
  86.  
  87.       with Form1.ListView1.Items.Add do
  88.   begin
  89.   Caption:= '';
  90.   SubItems.Add('luis');
  91.   SubItems.Add('flores');
  92.   SubItems.Add('layme');
  93.   end;
  94.  
  95.     with Form1.ListView1.Items.Add do
  96.   begin
  97.   Caption:= '';
  98.   SubItems.Add('leo');
  99.   SubItems.Add('allca');
  100.   SubItems.Add('gonzales');
  101.   end;
  102.  
  103.         begin // volviendo a enumerar después de borrar
  104.         for enumerando := 0 to ListView1.Items.Count-1 do
  105.         ListView1.Items[enumerando].Caption := IntToStr(enumerando+1);
  106.         end;
  107. end;
  108.  
  109. procedure TForm1.BitBtn1Click(Sender: TObject);  // MOVE ITEM UP
  110. begin
  111.   ExchangeItems(ListView1,ListView1.Selected.Index,ListView1.Selected.Index-1);
  112. end;
  113.  
  114. procedure TForm1.BitBtn2Click(Sender: TObject);  // MOVE ITEM DOWN
  115. begin
  116.   ExchangeItems(ListView1,ListView1.Selected.Index,ListView1.Selected.Index+1);
  117. end;
  118.  
  119. end.



PD: Attached image and project.
8
General / Re: Dotted unit names and fatal errors
« Last post by ASerge on Today at 07:08:50 am »
With no dots, If a unit is not found, the ide shows the line of the resulting error. However with dotted unit names, sometimes the line number is shown, sometimes it not shown. Is it a bug of some sort?
Steps to reproduce?
9
Designer / Re: Delphi Forms
« Last post by ASerge on Today at 06:59:48 am »
Binary DFMs have been deprecated since Delphi 4 in 1998 and are mostly extinct. (near 20 years of technical debt in that project).
Yes, starting from the specified version, Delphi contains the option "New forms as Text" in the settings (Form Designer), which is enabled by default.
Also all versions of Delphi contain the utility "convert.exe", which converts between text and binary forms.
10
Beginners / Re: Error: Identifier not found "try"
« Last post by molly on Today at 05:28:39 am »
Place {$MODE OBJFPC} or {$MODE DELPHI} beneath your program declaration.

The reason is that by default the compiler will compile in MODE FPC, which does not support exceptions.

More on the subject can be read here in the user's guide.

Edit: Or perhaps even better explained, here in the programmers guide.
Pages: [1] 2 3 ... 10

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus