Jump to content

programmerdelphi2k

Members
  • Content Count

    1406
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by programmerdelphi2k

  1. programmerdelphi2k

    Trouble installing Ios SDK

    did you try as Admin? did you try create the first folder: ".......\SDKs\iPhoneSimulator16.4.sdk" using your common win-user? did uou try use "Update Local File cache" button?
  2. programmerdelphi2k

    Assign KeyDown function to btnClick

    you can call the event as: ComponentXXXX.EventNameXXXX( ... params ) -> like do the Form definitions! Button1.OnClick(Self);
  3. programmerdelphi2k

    Assign KeyDown function to btnClick

  4. programmerdelphi2k

    Assign KeyDown function to btnClick

    maybe some like this help you? same that your Edit/Memo-controls is focused, this works! // a easy way... procedure TForm1.Button1Click(Sender: TObject); begin Label1.Caption := 'message button1'; end; procedure TForm1.Button2Click(Sender: TObject); begin Label1.Caption := 'message button2'; end; procedure TForm1.FormCreate(Sender: TObject); begin Form1.KeyPreview := true; // <---- to OnKeyDown,etc... end; procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = vk_return { and other verifications... } then Button1.Click; end;
  5. programmerdelphi2k

    I need the console window to stay open

    "ReadLN" dont? or https://stackoverflow.com/questions/2591774/how-to-create-a-console-application-that-does-not-terminate
  6. programmerdelphi2k

    I'm missing some nuance..

    nevermind... I forgot that BDE dont propagate the "session name" automatically!
  7. programmerdelphi2k

    Query result to dynamic array

    look, same that you "disable it or hide it" or use "ATable.Datasource := nil" etc... , the record still scrolling in background (memory)
  8. programmerdelphi2k

    Query result to dynamic array

    no! no! no! Eistein who knows?
  9. programmerdelphi2k

    Query result to dynamic array

    @PenelopeSkye if you are using the Dataset (ATable or your dataset xxx) in your Form/Datamodule that is " the same" dataset using in "while not ATable.EOF....", then, you will have a "side effect" in your screen: record rolling your dbgrid or any other component or memory (if you dont use any other component binded in your datasource! how to solve it? use a "new" dataset (TEMPORARY to any other actions, like: catch the values, print, etc...) to your SQL actions! aNewTable := TFDQuery.Create; ..... ANewTable.Open( '..... sql.....' ); when end, free it: FreeAndNil(ANewTable); summary: dont use the same dataset to "scroll your records"! that way, you dont need "close" and "open" your "read dataset = used in your forms, for example"!
  10. programmerdelphi2k

    Query result to dynamic array

    ... or directly in your code. procedure TForm1.Button1Click(Sender: TObject); var LText : string; begin EmployeeTable.Close; EmployeeTable.Open('Select * from employee'); EmployeeTable.First; // LText := ''; // while not EmployeeTable.Eof do begin LText := LText + slinebreak + EmployeeTable.FieldByName('FIRST_NAME').AsString { + ... other fields values }; // EmployeeTable.Next; end; // if not LText.IsEmpty then Memo1.Text := LText.Remove(0, 2); end;
  11. programmerdelphi2k

    Query result to dynamic array

    @PenelopeSkye try some like this: just note that my function it's not really generic ok? it's just a simple sample! type TMyRecordWithValues = record FEmpNo: integer; FEmpFirstName: string; FEmpBirthday: TDate; end; function MyListOfValuesInMyTableByFields(const ATable: TFDQuery; const ASQL: string; out AError: string): TArray<TMyRecordWithValues>; var LTableIsActive : boolean; LOldSQL : string; LMyRecordWithValues: TMyRecordWithValues; begin result := []; // if (ATable = nil) or (ASQL.IsEmpty) then exit; // LTableIsActive := ATable.Active; // if need use old statement... else, remove this 2 lines and vars definitions! LOldSQL := ATable.SQL.Text; // if LTableIsActive then ATable.Close; // free any resource... if necessary! // try try ATable.Open(ASQL); ATable.First; // while not ATable.Eof do begin LMyRecordWithValues.FEmpNo := ATable.FieldByName('EMP_NO').AsInteger; LMyRecordWithValues.FEmpFirstName := ATable.FieldByName('FIRST_NAME').AsString; LMyRecordWithValues.FEmpBirthday := ATable.FieldByName('HIRE_DATE').AsDateTime; // result := result + [LMyRecordWithValues]; // ATable.Next; end; except on E: Exception do begin result := []; AError := E.Message; end; end; finally ATable.Close; // if LTableIsActive then ATable.Open(LOldSQL); end; end; procedure TForm1.Button1Click(Sender: TObject); var LText : string; LError: string; begin for var R in MyListOfValuesInMyTableByFields(EmployeeTable, 'select * from employee', LError) do LText := LText + slinebreak + R.FEmpNo.ToString + ', ' + R.FEmpFirstName + ', ' + DateToStr(R.FEmpBirthday); // if not LError.IsEmpty then Memo1.Text := LError else if not LText.IsEmpty then Memo1.Text := LText.Remove(0, 2); end;
  12. programmerdelphi2k

    Justification for Header different to resto column in TListView?

    https://learn.microsoft.com/en-US/windows/win32/api/commctrl/ns-commctrl-lvcolumna?redirectedfrom=MSDN Alignment of the column header and the subitem text in the column. The alignment of the leftmost column is always LVCFMT_LEFT; it cannot be changed. This member can be a combination of the following values. Note that not all combinations are valid.
  13. programmerdelphi2k

    Justification for Header different to resto column in TListView?

    procedure TForm1.Button1Click(Sender: TObject); var MyListColumn: TListColumn; MyListItem : TListItem; begin ListView1.Columns.Clear; ListView1.ViewStyle := TViewStyle.vsReport; // MyListColumn := ListView1.Columns.Add; // 0 MyListColumn.Width := 150; MyListColumn.Alignment := TAlignment.taLeftJustify; // alignment of the leftmost column is always LVCFMT_LEFT MyListColumn.Caption := 'LeftJustify'; MyListColumn.Width := 0; // a "hack" // MyListColumn := ListView1.Columns.Add; // 1 MyListColumn.Width := 150; MyListColumn.Alignment := TAlignment.taCenter; MyListColumn.Caption := 'CenterJustify'; // MyListColumn := ListView1.Columns.Add; // 2 MyListColumn.Width := 150; MyListColumn.Alignment := TAlignment.taRightJustify; MyListColumn.Caption := 'RightJustify'; // MyListColumn := ListView1.Columns.Add; // 3 MyListColumn.Width := 150; MyListColumn.Alignment := TAlignment.taCenter; MyListColumn.Caption := 'CenterJustify'; // // 4 columns: 0, 1, 2, 3: MyListItem := ListView1.Items.Add; MyListItem.Caption := 'Item1'; // Column 0 MyListItem.SubItems.Text := 'SubItem1'; // Column 1 MyListItem.SubItems.Add('SubItem1.1'); // Column 2 MyListItem.SubItems.Add('SubItem1.1.1'); // Column 3 end;
  14. programmerdelphi2k

    TValueListEditor how to catch exception when key exist?

    ...was what it said!
  15. programmerdelphi2k

    TValueListEditor how to catch exception when key exist?

    procedure TForm1.Button1Click(Sender: TObject); var LRow: Integer; begin ValueListEditor1.KeyOptions := [keyUnique]; // quickly... { if not ValueListEditor1.Strings.Text.Contains('key1=') then // function TValueListStrings.KeyIsValid(const Key: string; RaiseError: Boolean = True): Boolean; ValueListEditor1.InsertRow('key1', 'hello', true); } // if (keyUnique in ValueListEditor1.KeyOptions) and ValueListEditor1.FindRow('key1', LRow) then begin if (LRow = -1) then ValueListEditor1.InsertRow('key1', 'hello', true) end else ValueListEditor1.InsertRow('key1', 'hello', true); // Memo1.Text := ValueListEditor1.Strings.Text; end;
  16. programmerdelphi2k

    Delphi says "x is not a valid integer value"

    if TryStrToInt('hello', LResult) and (LResult >0) then ShowMessage(' it,s good for us :) ');
  17. programmerdelphi2k

    Capture Ctrl-Click on a TButton?

    if the "Button" is focused, you can use its events togheter with mouse-click too but "GetKeyState(VK_CONTROL) < 0"; is better, of course! var LText: string; procedure TForm1.Button1Click(Sender: TObject); begin caption := LText + ' OnClick - 2º'; end; procedure TForm1.Button1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin LText := Key.ToString; // Ctrl = 17 end; procedure TForm1.Button1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin LText := 'no key pressed'; end; procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin caption := LText + ' OnMouseDown - 1º'; end;
  18. programmerdelphi2k

    Delphi says "x is not a valid integer value"

    The excence of the alternative functions in question is the same! Val(S, Value, E); What distinguishes the two is just how the return is reported to the user: returns a boolean; the other an integer; however, the "out" parameter has the same function: capture the value, a value "pre-defined" by the user, and use it: either through a variable informed by the user, or through the return of the function. they are two flavors of the same fruit! // none error at all, just "is valid or not?" var LResult: integer; begin if StrToIntDef('hello', 0) = 0 then ShowMessage('bye bye'); // LResult := StrToIntDef('hello', 0); // if (LResult = 0) then ShowMessage('bye bye'); // // if TryStrToInt('hello', LResult) then { ... }; // if (LResult = 0) then ShowMessage('bye bye');
  19. programmerdelphi2k

    Capture Ctrl-Click on a TButton?

    nevermind ... sorry
  20. programmerdelphi2k

    Delphi says "x is not a valid integer value"

    yahooo!!!!
  21. programmerdelphi2k

    Delphi 11 Community edtion

    @Nigel Thomas
  22. programmerdelphi2k

    C to Pascal

    show your code... then, I'll know.
  23. programmerdelphi2k

    Delphi says "x is not a valid integer value"

    @Remy Lebeau right! but "StrToxxxxxxDEF(....)" it's more flexible (it dont needs a "var" to receive "out param...") var v: integer; // mandatory to TryStrToxxxx(...) begin TryStrToInt('x', v); // more conservadore (* function TryStrToInt(const S: string; out Value: Integer): Boolean; var E: Integer; begin Val(S, Value, E); Result := E = 0; // exchanging 6 for half a dozen end; *) // StrToIntDef('x', 0); // more flexible (* function StrToIntDef(const S: string; Default: Integer): Integer; var E: Integer; begin Val(S, Result, E); if E <> 0 then Result := Default; // exchanging 6 for half a dozen end; *) // at end, if works it's good too!
  24. programmerdelphi2k

    Delphi says "x is not a valid integer value"

    your CPU it's very fast... there is a delay time... it's ok! 😂 ...1, 2, 3, 5, 8... ops! starting again... bip! bip!
×