Jump to content

Ian Branch

Members
  • Content Count

    1272
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Ian Branch

  1. Hi Team, D10.4.1, Win 10, 32bit App. I need to open a sub form, StockPositionForm, from the MainForm, non modal as it is used in conjunction with other forms in the App. At the same time I need to prevent StockPositionForm being reopened again from the MainForm whilst StockPositionForm is already open. StockPositionForm is currently opened with.. procedure TMainForm.StockPosition1Click(Sender: TObject); begin // TStockPositionForm.Create(Self).Show; // end; Thoughts/suggestions, polite :-), appreciated. Regards & TIA, Ian
  2. Ian Branch

    Prevent a sub form being reopened..

    Ahhhh. Excellent! Works perfectly. Thank you. Regards, Ian
  3. Ian Branch

    Project always opens with .dpr file..

    I have it. For some reason Tools|Options|IDE|Save project desktop when closing, was not checked. Don't know when that happened, this project has seemingly always been this way. Oh well. All sorted now. Thanks Uwe for the pointer. Regards, Ian
  4. Ian Branch

    Project always opens with .dpr file..

    HI Uwe, I have never knowingly changed them. All my other projects open at the Mainform. What should I specifically look at/for? Yes, the Mainform is auto-created in the dpr. Application.MainFormOnTaskbar := True; Application.CreateForm(TMainForm, MainForm); Application.Run; Regards, Ian
  5. Ian Branch

    {$IFNDEF for Defined(????

    HI Team, Hope you all had an enjoyable Xmas day as befits your Faith & Family. I know and have used {$IF Defined(xxxx) or Defined(YYYYY)} ..... ..... {$ENDIF} Is there a {$IFN.. hidden in Delphi somewhere?? i.e.... {$IFN Defined(XXXXXX) or Defeined(YYYYY)} ..... ..... {$ENDIF} I have multiple projects sharing common files and in some case it would be shorter to write {$IFN.... conditionals then {$IF.... conditionals. Regards & TIA, Ian
  6. Ian Branch

    SMS via my phone..

    Hi Team, I have been asked if it is possible to send an sms from their Delphi App on their PC via a phone attached to the PC? Doesn't matter if it is Android or Apple, the Customer will supply the phone/phone account. Thoughts, suggestions, recommendations?? Regards & TIA, Ian
  7. Ian Branch

    SMS via my phone..

    He's a Phone repairer so it will be what I figure out. :-)
  8. Ian Branch

    SMS via my phone..

    Hi David, Probably, but I haven't specifically looked into that route. The Customer already has his own Phones/#s and wants to put them to use. Ian
  9. Ian Branch

    Turn off title on a TImage??

    Hi Team, D10.4.1. If I can, where/how do I turn off/blank the title of a TImage. I can't find a .Caption or .Title property, or similar, and it doesn't make sense that you can't so where/how?? Regards & TIA, Ian
  10. Ian Branch

    Turn off title on a TImage??

    Solved. I am going to take myself out the back and beat myself over the head soundly with a piece of 2 x 4. The 'Caption' I was trying to get rid of was actually in the image. :-( Colour me red. :-( Thanks for your input. I will just slink away now.... Regards, Ian
  11. Ian Branch

    Turn off title on a TImage??

    Hi Pat, Didn't make any difference. This is what I am seeing on the form.. The image name there is shown. Above the TImage is a Panel, overlaid on the Image are buttons. Ian
  12. Hi Team, D10.4.1, Win 10 64bit. Suddenly my palette doesn't want to show anything. Any thoughts/suggestions? TIA, Ian
  13. Ian Branch

    TDBGrid - dgTitleClick

    Can anybody tell me when, Delphi version, TDBGrid.Options - dgTitleClick was introduced? Regards & TIA, Ian
  14. Ian Branch

    TDBGrid - dgTitleClick

    Thanks Lajos, I got sent this earlier.. " Delphi 2010 and greater: needs dgTitleClick true (grid options) for this to run: frmItems.DBGrid1TitleClick dgTitleHotTrack : Specifies that list items are highlighted when the mouse passes over them. (highlights the title cell.. maybe other cells in that column too). dgTitleClick & dgTitleHotTrack default to true on new forms. " So I have worked on that basis. Regards, Ian
  15. Hi Team D10.4.1. I have an OnChange DataSet event in a DataModule. The the DataModule is used by multiple apps but only a few of them need the OnChangeEvent procedure. ATT I have this construct.. procedure dsJTDataChange(Sender: TObject; Field: TField); begin {$IF Defined(MyApp1) or Defined(MyApp2)} // ... ... {$ENDIF} end; This is all working fine but I was wondering, is there any way to condition out the actual procedure in total? Something like.. {$IF Defined(MyApp1) or Defined(MyApp2y)} procedure dsJTDataChange(Sender: TObject; Field: TField); begin // .... .... end; {$ENDIF} Of course I would need to apply the same conditional to the procedure definition in the class. {$IF Defined(MyApp1) or Defined(MyApp2)} procedure dsJTDataChange(Sender: TObject; Field: TField); {$ENDIF} the obvious problem is that if that is done then Delphi loses visibility of the dsJT OnDataChange event. i.e. MyApp3, MyApp4, etc. Is there any way around this?? Regards & TIA, Ian
  16. Ian Branch

    Make a complete DataSet event conditional??

    I too like Atilla's term, unfortunately, I don't ride horses. ;-) So, I ended up reviewing the suggestions here and did some more research. Being lazy and not wishing to rewrite anything, I ended up with the following constructs... In the Datamodule class definition I added these.. // Local procedures defined for redirection to JTs & dsJTs at Run Time if Apps are App1 or App2. {$IF Defined(App1) or Defined(App2)} procedure MydsJTDataChange(Sender: TObject; Field: TField); procedure MyJTAfterEdit(DataSet: TDataSet); procedure MyJTBeforePost(DataSet: TDataSet); procedure MyJTAfterPost(DataSet: TDataSet); procedure MyJTNewRecord(DataSet: TDataSet); {$ENDIF} These were of course a simple rename of the existing procedures. Then in the Datamodule's Create Event I added the following.. // // Assigning JTs & dsJTs events to local procedures at run time. {$IF Defined(App1) or Defined(App2)} dsJT.OnDataChange := MydsJTDataChange; JT.AfterEdit := MyJTAfterEdit; JT.BeforePost := MyJTBeforePost; JT.AfterPost := MyJTAfterPost; JT.OnNewRecord := MyJTNewRecord; {$ENDIF} // Then of course I renamed the original procedures to My.. and wrapped them in the basic.. {$IF Defined(App1) or Defined(App2)} .... {$ENDIF} This may or may not meet everybody's expectations/preferences, but, it keeps the code where I have become used to where it is over the years and I have no issue with maintaining {$IF... }/{$ENDIF} constructs. Again, I have learnt something new. A good day. Thank you all again for your input. Regards, Ian
  17. Hi Team, I needed a routine that would tell me if either of two dates from a database table were valid before being tested for other characteristics. I came up with the following.. function AreValidDates(const DateString1, DateString2: string): Boolean; var DT: TDateTime; // unused date time value begin // Result := TryStrToDate(DateString1, DT); // if Result then Result := TryStrToDate(DateString2, DT); // end; The Function is called by "if AreValidDates(MyTable.FieldByName('Date1').AsString, MyTable.FieldByName('Date2').AsString) then..." The function is used in many places in my Apps. Is there a better/more efficient way to do this? Regards & TIA, Ian
  18. Ian Branch

    Are Valid Dates?

    Hi Team, Just to close this one off. I revisited all the various Date data entry points, 7 different dates in all, and confirmed they can only be either Null or a valid date. Then using my new Helper knowledge I created the following Helper based on Kas' suggestion.. { TQueryHelper } // Parameters are FieldNames in this case function TQueryHelper.AreDBDatesNull(const DateString1, DateString2: string): Boolean; begin // Result := (not FieldByName(DateString1).IsNull) and (not FieldByName(DateString2).IsNull); // end; // // Implemented by.. if MyQuery.AreDBDatesNull('Date1', 'Date2') then ..... Simpler, and testing the data fields directly rather than 'converting' them. Thank you all for your input & contributions. Have a Great 2021. Regards, Ian
  19. Ian Branch

    Are Valid Dates?

    Hi Thomas, Thank you for your input. They are stored as Dates. My original code at the start of this thread was simply where I ended up after considering some alternatives. I have now implemented the Helper per Kas' suggestion. Something new I have learnt today. 🙂 I will have a look in dzLib, I have it here. Ian
  20. Ian Branch

    Are Valid Dates?

    Now that's neat. I did have a look at that link but my knowledge depth wasn't up to it and I got confused. 😞 I can follow your example though and can see how it could be extended/used in other areas. Regards & Tks, Ian
  21. Ian Branch

    Are Valid Dates?

    Hi Kas, Now that's an intriguing idea. Perhaps not for this case but I would be interested in how it is done. Can you point me to appropriate material? A Tutorial or similar.. Regards & TIA, Ian
  22. Ian Branch

    Are Valid Dates?

    As you suggest, one solution is not necessarily the answer for all circumstances. I had considered various options and this was what I considered an appropriate solution. 😉 I had two considerations.. 1. Are either of the date fields NULL; and 2. If they weren't, are they properly constituted date(s). This mechanism gave me coverage for both. It is a little of 'Belts & Braces' as the date entries are via TDateTimePickers. From here, if all good, various 'validity/comparison' checks are done, if they fail the User is sent back to correct the date(s) as appropriate. Thank you for your input. Regards, Ian
  23. Ian Branch

    {$IFNDEF for Defined(????

    Yup. My error was in the {$IFDEF.... rather than having {$IF..... This is all good now. // {$IF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow))} ShowMessage('{$IF...'); {$ENDIF} // {$IF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow)) and not(defined(Users))} ShowMessage('{$IF...'); {$ENDIF} // Tks for the pointers, this works as expected now. The first shows, the second doesn't. Regards, Ian
  24. Ian Branch

    {$IFNDEF for Defined(????

    OK. So I have missed some nuance... I have the following test code with Users defined... {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFNDEF Hello || Bellow || Yellow || Users} ShowMessage('{$IFNDEF...'); {$ENDIF} And I have Complete Boolean Evaluation set to True. Yet I get both messages... This works.. {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFDEF not(defined(Hello)) or not(defined(Bellow)) or not(defined(Yellow)) or not(defined(Users))} ShowMessage('{$IFNDEF...'); {$ENDIF} Although my mind says it should be Hello not defined AND Bellow not defined AND Yellow not defined AND Users not defined. i.e. none of the defines are defined... If I now make it... // {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFDEF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow)) and not(defined(Users))} ShowMessage('{$IFNDEF...'); {$ENDIF} // And I have Complete Boolean Evaluation set to False. On that basis, I should get both messages with.. // {$IFDEF Users} ShowMessage('{$IFDEF...'); {$ENDIF} // {$IFDEF not(defined(Hello)) and not(defined(Bellow)) and not(defined(Yellow))} ShowMessage('{$IFNDEF...'); {$ENDIF} // But no, only the first one. Interesting stuff.
  25. Ian Branch

    {$IFNDEF for Defined(????

    Thank you gentlemen for both your solutions. Much appreciated. FPiette - I didn't realize a NOT could be applied that way. emailx45 - Sneaky, and another thing I have learnt. A day where nothing is learnt is a day wasted... Regards & All the best for 2021. Ian
×