Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Designer / Re: Bugs in Example Projects window
« Last post by dsiders on Today at 09:39:00 pm »
TListViewFilterEdit  ? Probably another very good component with no documentation.
...

* Can it handle multiple columns in the list view ? 
* How to add an item ?  Seems its a call to ~.items.add(Item:T); And that item is fgl thingo. I use Pascal because its strongly typed, if I want something that can be any old type depending on the day of the week, I'd use Python.
* How to specify and apply the filter ?
* Can you filter for, eg "Words together" plus another ?
* Will it work with Owner Data ?
* Why does it have no mention in the chm help files ?
* Why is it Red on in the table that appears, eg on https://wiki.freepascal.org/TEdit ?
* Why is there no Example Project showing how to use TListViewFilterEdit ?
Quote

There is documentation, but it is not included in the release files nor is it integrated into the LHelp help system. It can be found on the documentation preview at: https://dsiders.gitlab.io/lazdocsnext/lazcontrols/listviewfilteredit/tlistviewfilteredit.html.
2
So where is your lazarus code?

Code: Pascal  [Select][+][-]
  1. procedure TMiniMaxAPI.Button2Click(Sender: TObject);
  2.  
  3. var
  4.   HTTPClient: TFPHTTPClient;
  5.   Params: string = '{"client_id": "****", "client_secret": "****", "grant_type": "password", "username": "*****", "password": "*****", "scope": "minimax.rs"}';
  6.   MiniMaxResponse: TStringStream;
  7.   PostURL: string;
  8.   nParamsLength: integer;
  9.   sParamsLength: string;
  10.  
  11. begin
  12.   PostURL := '';
  13.   PostURL := PostURL + 'https://moj.minimax.rs/RS/AUT/OAuth20/Token';
  14.   nParamsLength:= length(PostURL);
  15.   Str(nParamsLength, sParamsLength);
  16.   MiniMaxResponse := TStringStream.Create;
  17.   if Length(EditCode.Text) > 0 then
  18.   begin
  19.     //ParamList.Create;
  20.     HTTPClient := TFPHTTPClient.Create(nil);
  21.     HTTPClient.AllowRedirect := True;
  22.     HTTPClient.AddHeader('Content-type','application/x-www-form-urlencoded');
  23.     HTTPClient.AddHeader('Accept', 'application/json');
  24.     HTTPClient.RequestBody := TRawByteStringStream.Create(Params);
  25.     HTTPClient.AddHeader('Content-Length','0');
  26.     try
  27.       HTTPClient.Post(PostURL, MiniMaxResponse);
  28.       MemoLogin.Text:=MiniMaxResponse.DataString;
  29.     finally
  30.       HTTPClient.RequestBody.Free;
  31.       HTTPClient.Free;
  32.       MiniMaxResponse.Free;
  33.     end;
  34.   end
  35. end;
3
Databases / Re: DBGrid remove red rectangle selection
« Last post by dsiders on Today at 09:29:27 pm »
Hello, is it possible to remove the red rectangle from the active selection?

The focus rectangle gets drawn when DefaultDrawing is enabled. You can turn DefaultDrawing off and provide you own OnDraw* handlers.

Or you can change FocusColor to a color more pleasing to you.
4
Designer / Re: Bugs in Example Projects window
« Last post by JuhaManninen on Today at 09:19:19 pm »
I did experiments with ListViewFilterEdit in the Examples window. It cannot be applied there easily. The current SearchEdit is tightly integrated to the actual search engine, and it supports many keywords at once.

I applied the patch with some additions. The TextHint looks good although I would like to have the initial focus in the filter.
You could add small SpeedButton to the right side of the edit for clearing the filter. It should have the same icon as other filters, a funnel with a red cross (btnfiltercancel).
5
Networking and Web Programming / Re: OAUTH2 authorization port to Lazarus
« Last post by Thaddy on Today at 09:17:44 pm »
OAUTH2 is already supported through the Google API bindings in the standard distribution of FreePascal and also through some MS bindings.
6
Networking and Web Programming / Re: OAUTH2 authorization port to Lazarus
« Last post by marcov on Today at 09:10:47 pm »
So where is your lazarus code?
7
Networking and Web Programming / OAUTH2 authorization port to Lazarus
« Last post by ksabolc on Today at 09:07:38 pm »
Hello !

I'm struggling with OAUTH2 authorization. I can't port it from PHP to Lazarus.
In PHP it works fine, i am getting the authorization token fine, but I can't achive it from Lazarus. Tried with fphttpclient but without succes, always getting a '{"error":"invalid_request"}' error. Probably missing some header or not formed well the request body ???
Any suggestions ?

The working PHP code is:

Code: PHP  [Select][+][-]
  1. <?php
  2. $params = array(
  3.     'client_id'=> '****',
  4.     'client_secret'=> '****',
  5.     'grant_type'=> 'password',
  6.     'username'=> '****',
  7.     'password'=> '****',
  8.     'scope' => 'minimax.rs');
  9.  
  10. $request = array(
  11.     'http' => array(
  12.         'method'=> 'POST',
  13.         'header'=> array(
  14.             'Content-type: application/x-www-form-urlencoded',
  15.             ),
  16.         'content'=> http_build_query($params),
  17.         'timeout'=> 10
  18.         )
  19.     );
  20.  
  21. print_r($params);
  22. echo "<br>";
  23. echo "<br>";
  24. print_r($request);
  25. echo "<br>";
  26. echo "<br>";
  27. echo "<br>";
  28. echo "<br>";
  29.  
  30. if (!$response = file_get_contents('https://moj.minimax.rs/RS/aut/oauth20/token', false, stream_context_create($request))) {        
  31.     die('auth error');
  32. }
  33.  
  34. $token = json_decode($response);
  35.  
  36. print_r($response);
  37. echo "<br>";
  38. echo "<br>";
  39.  
  40. $request = array(
  41.     'http' => array(
  42.         'method'=> 'GET',
  43.         'header'=> 'Authorization: Bearer ' . $token->access_token,
  44.         'timeout'=> 10
  45.         )
  46.     );
  47. if (!$response = file_get_contents('https://moj.minimax.rs/RS/api/api/currentuser/orgs', false, stream_context_create($request))) {
  48.     die('orgs error');
  49. }
  50.  $orgs = json_decode($response, true); print_r($orgs);
  51. ?>
8
TAChart / Re: ChartPane caption
« Last post by kapibara on Today at 08:25:33 pm »
Great. Now there needs to be some space within the pane, to make room for a caption.

I'm thinking that the height of the graph should be decresed, keeping the size of the pane intact. Then we have a space between the top of the pane and the top of the graph.

But the caption height is in pixels and the pane size is calculated by good old ConfigureAxisTransformation upon pane creation. Also, when panes are resized, the routine DragToolMoveDivider recalculates top and bottom so the captions also need to be repositioned. I'm aware of the GraphToAxis and AxisToGraph methods but not sure how to go about this task in the best way?

Below is code from the project attached to our last ChartPane thread, https://forum.lazarus.freepascal.org/index.php/topic,58368.msg445244.html#msg445244

Code: Pascal  [Select][+][-]
  1. procedure TChartBox.ConfigureAxisTransformation(var AChartPane: TChartPane);
  2. var
  3.   paneIndex: Integer;
  4.   neighborPane: TChartPane;
  5.   dividerPane: TChartPane;
  6. begin
  7.   if PaneCount = 1 then
  8.   begin
  9.     // A pane has already been added, i.e. Count is 1 for the first pane.
  10.     // The pane with index 0 does not contain a divider line.
  11.     AChartPane.AutoScaleAxisTransform.MinValue := HALF_GAP;
  12.     AChartPane.AutoScaleAxisTransform.MaxValue := DEFAULT_PANE_SIZE - HALF_GAP - CAPTION_SIZE;
  13.     exit;
  14.   end;
  15.  
  16.   paneIndex := Panes.IndexOf(AChartPane);
  17.   // The pane has been added at the top of the pane stack. (Top of Chart)
  18.   if paneIndex = PaneCount-1 then
  19.   begin
  20.     neighborPane := GetChartPane(paneIndex-1);
  21.     AChartPane.AutoScaleAxisTransform.MinValue :=
  22.       neighborPane.AutoScaleAxisTransform.MaxValue + 2*HALF_GAP;
  23.  
  24.     AChartPane.AutoScaleAxisTransform.MaxValue :=
  25.       AChartPane.AutoScaleAxisTransform.MinValue + DEFAULT_PANE_SIZE
  26.       - 2*HALF_GAP - CAPTION_SIZE;
  27.  
  28.     // The divider line will be added in the current pane at the bottom.
  29.     dividerPane := AChartPane;
  30.   end else
  31.   // The pane has been added at the bottom of the pane stack. (Bottom of Chart)
  32.   if paneIndex = 0 then
  33.   begin
  34.     neighborPane := GetChartPane(paneIndex+1);
  35.     AChartPane.AutoScaleAxisTransform.MaxValue :=
  36.       neighborPane.AutoScaleAxisTransform.MinValue - 2*HALF_GAP - CAPTION_SIZE;
  37.  
  38.     AChartPane.AutoScaleAxisTransform.MinValue :=
  39.       AChartPane.AutoScaleAxisTransform.MaxValue - DEFAULT_PANE_SIZE + 2*HALF_GAP;
  40.     // The divider line will be added at the bottom of the neighbor pane.
  41.     dividerPane := neighborPane;
  42.   end else
  43.     exit;
  44.  
  45.   // Set up the divider line...
  46.   dividerPane.Divider := TConstantline.Create(FChart);
  47.   dividerPane.Divider.Legend.Visible := false;
  48.   dividerPane.Divider.Position := dividerPane.AutoScaleAxisTransform.MinValue - HALF_GAP;
  49.   FChart.AddSeries(dividerPane.Divider);
  50. end;
  51.  
  52.  
Code: Pascal  [Select][+][-]
  1. procedure TChartBox.DragToolMoveDivider(ASender: TDataPointDragTool;
  2.   var AGraphPoint: TDoublePoint);
  3. var
  4.   ser: TConstantLine;
  5.   paneIndex: Integer;
  6.   lowerPos, upperPos: Double;
  7.   pane_above_divider, pane_below_divider: TChartPane;
  8. begin
  9.   if not (TDataPointTool(ASender).Series is TConstantLine) then exit;
  10.  
  11.   ser := TConstantLine(TDataPointDragTool(ASender).Series);
  12.  
  13.   // Get the PaneIndex of the pane with the divider clicked.
  14.   paneIndex := GetPaneIndexOfDivider(ser);
  15.  
  16.   // Calculates the lowest allowed upper edge of the pane below the divider
  17.   pane_below_divider := GetChartPane(paneIndex-1);
  18.   lowerPos := pane_below_divider.AutoScaleAxisTransform.MinValue - HALF_GAP + MIN_PANE_SIZE;
  19.  
  20.   // Calculates the highest allowed lower edge of the pane above the divider
  21.   pane_above_divider := GetChartPane(paneIndex);
  22.   upperPos := pane_above_divider.AutoScaleAxisTransform.MaxValue + HALF_GAP - MIN_PANE_SIZE;
  23.    
  24.   // Ensures that the dragged data value is in the allowed range between
  25.   // lowerPos and upperPos.
  26.   AGraphPoint.Y := EnsureRange(AGraphPoint.Y, lowerPos, upperPos);
  27.    
  28.   // Adjusts axes of both panes using the values collected
  29.   // from calculations above
  30.   pane_above_divider.AutoScaleAxisTransform.MinValue := AGraphPoint.Y + HALF_GAP;
  31.   pane_below_divider.AutoScaleAxisTransform.MaxValue := AGraphPoint.Y - HALF_GAP;
  32. end;
  33.  
9
Databases / Re: SQL - IBX - "returning" - primary key
« Last post by rvk on Today at 07:15:59 pm »
Returning should work fine but we need to see more code.
Besides the actual INSERT sql (which contains the returning) we also need to see what component is used and if open is used or execsql.

Everything else is just guesswork.
At least TIBSQL supports returning (not sure about TIBQuery at the moment).
10
Databases / Re: SQL - IBX - "returning" - primary key
« Last post by korba812 on Today at 07:07:52 pm »
I used this along with MDO (another fork of IBX). Try adding the return parameter:
Code: SQL  [Select][+][-]
  1. INSERT INTO tbtrades
  2.     (zukonto, STATUS_ ,POSITION_ ,FK_KONTRAKT,NAME_,COMM ,ERGEBNIS,ENTRY_PRICE,ENTRY_DATE,EXIT_DATE,ENTRY_TIME,EXIT_TIME,STOP,WORST,TARGET,BEST,PL,MARGIN) VALUES  (:zuKonto,:STATUS_,:POSITION_ ,:FK_KONTRAKT,:NAME_,:COMM ,:ERGEBNIS,:ENTRY_PRICE,:ENTRY_DATE,:EXIT_DATE,:ENTRY_TIME,:EXIT_TIME,:STOP,:WORST,:TARGET,:BEST,:PL,:MARGIN)
  3.      returning id_trade INTO :somevarname;'
then try to read from the parameters as I showed earlier:
Code: Pascal  [Select][+][-]
  1. idEintrag:=IBQuery_TradeInDB.QInsert.ParamByName('somevarname').AsInteger;
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018