Posts by Ricardo Alves Carvalho • 484 points
38 posts
-
2
votes2
answers38
viewsA: How to stretch a form only the width?
You can use the Constraints.Maxwidth and Minwidth property to limit the dimensions.
-
0
votes2
answers64
viewsA: Select returning null values in the database
Try it like this: SELECT S.ID_SALES, S.ID_CLIENT, C.FULL_NAME, S.SDATE, coalesce(S.billed, 'N') BILLED, P.product_description product, I.amount, I.unit_cost, I.unit_cost * I.amount SUBTOTAL,…
-
1
votes1
answer225
viewsA: Is there a way to execute an internal command stored in a . txt (or String) file in Delphi?
I am guessing that each row of the file will be on a Timage named Image1, Image2, etc. I am also assuming that the files are all bitmaps. procedure TFrmAlbum.FormShow(Sender: TObject); var Achar :…
-
0
votes2
answers46
viewsA: I’m having trouble closing a form( in the main form case) when I open a second form
It doesn’t make much sense to close the Main Form while another one is open because the main closure closes the application. So, if I understand correctly, you want the main form to be invisible…
delphianswered Ricardo Alves Carvalho 484 -
1
votes1
answer373
viewsA: Integrating Delphi to Word (enabling Save Word button)
Normally, the save button is only enabled after some change in the document is performed by Word itself (without Automation). To make Word understand that the document can be saved, use the Saved…
-
1
votes2
answers56
viewsA: Uncheck Checkbox With Password Only
I managed to do it with this code, using the Onmousedown and Onkeydown Checkbox events: procedure TForm3.CheckBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);…
-
0
votes2
answers186
viewsA: Create field only in Dataset with default value
You can do in SQL itself: SELECT 'S' AS FLAG_EXEMPLO, CAMPO1, CAMPO2 FROM TABELA;
-
0
votes1
answer249
viewsA: Calculated field is not editable in dbgrid
If it must be typed, the field cannot be computed. It has to be a data field. If the dataset is the result of a query, you can select a fixed value, for example: SELECT 1 AS MULTIPLICADOR... This…
-
0
votes3
answers766
viewsA: How to convert a String to Tnotifyevent in Delphi?
You can do something like create a record to store the name of each procedure: type mrec = record nome: string; proc: procedure(Sender: TObject) of Object; end; ... var s : string; procs: array of…
-
0
votes1
answer102
viewsA: Stopwatch of Idle Time
In Tfrmmain, declare a variable (initialize it with 0): private TempoAntigo: TTime; ... When you receive a new file, update the variable: procedure TFrmMain.TimerAtivTimer(Sender: TObject); begin if…
delphianswered Ricardo Alves Carvalho 484 -
1
votes2
answers375
viewsA: Format Date by Capitalizing the Month
The simplest is to convert the letter after assigning the variable: procedure TForm1.Button1Click(Sender: TObject); var s : string; begin s := FormatDateTime('dd" de "mmmm" de "yyyy', date()); s[7]…
-
2
votes2
answers520
viewsA: How to find all '>' characters of a memo and store in an array using Delphi?
You can do it like this: var i, len: integer; posicoes: array of integer; texto: string; begin texto := 'conteúdo > do > texto'; SetLength(posicoes, 0); //esvaziar array na inicialização for i…
-
3
votes1
answer564
viewsA: Prevent character typing if monetary value is incorrect in Delphi
To work at any position, you need to check the cursor position and selection size: function isValidMoeda(Valor: string): Boolean; begin Result := TRegEx.IsMatch(Valor,…
-
1
votes3
answers3721
viewsA: Wait for Thread to finish to proceed with the code - Delphi
The correct is to even use Syncronize only to update the graphical interface (not to download). I’ve done something similar using Thread’s Onterminate event: In one variable it stored the total…
-
2
votes2
answers169
viewsA: Change Tcontrol Enabled activates click event alone
This is not the default behavior. Possibly, your code is making some recursive call. In this case, you can temporarily disable the event Handler: procedure…
-
1
votes2
answers438
viewsA: How to add event to an inherited form event in Delphi?
You can call Handler the ancestor event: procedure TFClientes.OnCellClick(Column: TColumn); begin inherited; //executa OnCellClick do FModelo1 ... //seu código do FClientes aqui end;…
-
1
votes1
answer348
viewsA: Using Case in Order By with Union
Your order by should provide an expression that can be evaluated for each record. When you use: (case when cod_lado = 'M' then cod_posicao END) DESC, Expression result missing for records cod_lado…
-
0
votes2
answers799
viewsA: Delphi - Grid does not display all fields of the SQL statement
There are several possibilities for the field not to appear. Among them: 1) The field object is invisible, 2) The dataset has field objects, but not that field specifically (Fields editor), 3)…
-
0
votes2
answers1049
viewsA: Add values of different selects
I usually do this with a certain strategy. Easier to show than to explain. Suppose I want to compare sales from different years month to month: select mes, sum(iif(ano = 2017, valor, 0)) Ex2017,…
-
2
votes2
answers1405
viewsA: What is the difference between these Form Delphi creation options?
The difference is that with Application.Createform the created form will be the "Mainform" (main form) if it is not yet defined. There are no other differences with respect to the visibility or use…
-
0
votes2
answers57
viewsA: Do a search for my site in two tables
select name, Description from ( SELECT name, description, 1 order FROM tbl_companies Where Description like 'word%' UNION SELECT name, Description, 2 order FROM tbl_products WHERE Description LIKE…
-
4
votes2
answers757
viewsA: Access the child components of a Tobject
When speaking of the object’s "son", there are two possible interpretations: 1) The object is a Tcomponent and Owner of your children, which can be accessed by the Components property. For example:…
-
0
votes2
answers502
viewsA: Dynamic component name Delphi
I did a test with this code and it worked: procedure TForm2.Button1Click(Sender: TObject); var panel: TPanel; ponteiro: integer; begin for ponteiro := 1 to 5 do begin panel := FindComponent('Pn' +…
delphianswered Ricardo Alves Carvalho 484 -
2
votes1
answer173
viewsQ: Delphi - Executable with different behavior on different machines
I wanted to create a transition effect to a form, so in the event OnShow, I set up the estate AlphaBlend := 0 and, in the OnActivate: for i := 55 to 255 do begin AlphaBlendValue := i; Update;…
-
0
votes2
answers1891
viewsA: How to create form dynamically in Delphi
If "Tformclass" is a class reference, the code can look like this: procedure TLogin.CriarForm(NomeForm: TFormClass); var form: TForm; begin form := NomeForm.Create(Application); try form.ShowModal;…
-
1
votes3
answers667
viewsA: Create objects in Runtime faster
You can set the form Doublebuffered Property to True and still lock the canvas: Canvas.Lock; try ... criação dos componentes ... finnaly Canvas.Unlock; end;
-
0
votes2
answers374
viewsA: Query bringing duplicate items + product code
select codigo_produto_servico from tb_produto_servico where ds_produto_servico in ( select ds_produto_servico from tb_produto_servico group by ds_produto_servico having count(ds_produto_servico)…
-
0
votes1
answer138
viewsA: Firebird 2.5 Query of a trial
By the SQL of your post, I imagine you want to limit to the current year. If this is the case, it is not difficult: SELECT COUNT (*) FROM R_ATENDIMENTOS_TRIMESTRE (:I_ENTIDADE, :I_LOCAL) where…
-
0
votes1
answer352
viewsA: Return values to Dynamic Forms in Delphi
You can have one property in the child that identifies the father, and another in the father that identifies the child(s). Before closing the father, go through the children saying "that they are…
delphianswered Ricardo Alves Carvalho 484 -
1
votes1
answer874
viewsA: Tdbgrid not updating data in Delphi
I have a hunch what might be going on. You are updating the query_books component. Maybe the grid is connected to a Clientdataset and not to query_books. It is common to link database -> query…
-
1
votes3
answers1596
viewsA: How to order records in the query according to another ordination?
If order by does not work with group by, it should work: SELECT * FROM ( SELECT id_gerencial, SUM(valor) AS soma FROM desmembramento WHERE origem = 'M' GROUP BY id_gerencial ) ORDER BY…
-
2
votes4
answers2460
viewsA: How to check for changes in a Clientdataset
You can test the state: if cds.state id dsEditModes then ... or if changes are pending (without applyupdate): if cds.ChangeCount > 0 then ... To test at the close of the form, the ideal is to use…
delphianswered Ricardo Alves Carvalho 484 -
0
votes2
answers1153
viewsA: Add a bmp or jpg figure to a canvas in Delphi
From the comments of the other answer, you want to insert a bitmap in a specific position of a canvas. The question is not how to load the bitmap, correct? If so, just use this command:…
-
0
votes3
answers1000
viewsA: Select with the last record
In Firebird I do so: SELECT FIRST 1 VALOR_UNITARIO FROM ESTOQUE WHERE CODIGO = :CODIGO ORDER BY DATA DESC
-
0
votes3
answers347
viewsA: Form Inheritance created in Runtime
Ramon, I confess I don’t quite understand your need. You want the event of the daughter class not to happen unless called explicitly?
-
0
votes3
answers347
viewsA: Form Inheritance created in Runtime
To use inherited in a daughter class method, calling the parent class method, it must be declared as the virtual directive in the parent class and override in the daughter class.
-
0
votes4
answers83
viewsA: Only join if the above query returns records
I did a test with the instruction below and it worked (I think it’s easy to understand): select * from bairro where id = 1 union select * from bairro where id > 15 and EXISTS (select FIRST 1 *…
-
2
votes2
answers498
viewsA: Check values with 0 included in Count() even if they do not have values
For this kind of problem, I created a procedure that returns the days of a given period: SET TERM ^ ; create or alter procedure DIAS_PERIODO ( INICIO date, FIM date) returns ( DIA date) as begin DIA…