Jump to content

ewong

Members
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

0 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio
  1. ewong

    changing inherited control

    In hindsight and as an anecdotal instance of losing the plot, I just realized I could have just setup a popup menu and be done with it. ;/ That said, I have learnt a bit more so that wasn't a total waste. 😜 Edmund
  2. ewong

    changing inherited control

    In hindsight, I think that's what's making me confused. That said, I've found an indirect way in accordance to [3]. TCustDBGrid = class(TDBGrid) protected procedure MouseDown(Sender: TObject; Button: TMouseButton; ShiftState: TShiftState; X, Y: Integer); end; TForm1 = class(TForm) ... recentinfo: TDBGrid; .. protected procedure FindComponentClass(Reader: TReader; const ClassName: string; var ComponentClass: TComponentClass); Procedure ReadState(Reader: TReader); override end; procedure TCustDBGrid.MouseDown(Sender: TObject; Button: TMouseButton; ShiftState: TShiftState; X, Y: Integer); begin if (name = 'recentinfo') and (button = mbRight) then begin ShowMessage('testing'); end else inherited; end; procedure TForm1.FindComponentClass(Reader: TReader; const ClassName: string; var ComponentClass: TComponentClass); var i : integer; s : string; ts : TComponent; begin if ComponentClass = TDBGrid then begin ComponentClass := TCustDBGrid; end end; procedure TForm1.ReadState(Reader: TReader); begin Reader.OnFindComponentClass := FindComponentClass; inherited; end; The above 'hack' worked. At first I had tried to find the associated ComponentClass' instance name; only to have it dawn on me that it's just finding the component class. It hadn't instantiated the component yet so no instance exists. Then I just gave up and had all the DBGrids to be changed to TCustDBGrid on the fly and then use the TCustDBGrid mousedown dispatcher to run when the right instance is referenced. Thanks! Edmund
  3. ewong

    changing inherited control

    Delphi complains that it can't find "TCustDBGrid". So what I have is: TCustDBGrid = class(TDBGrid) protected procedure MouseDown(Sender: TObject; Button: TMouseButton; ShiftState: TShiftState; X, Y :integer); end; TForm1 = class(TForm) .. recentinfo: TDBGrid; .. end; implementation procedure TCustDBGrid.MouseDown(Sender: TObject; Button: TMouseButton; ShiftState: TShiftState; X, Y: integer); begin if button = mbRight then showmessage("testing"); end; From [1], I tried: constructor TForm1.create; begin recentinfo.onMouseDown = MouseDown; end; This didn't work as it's complaining that there's not enough parameters. Then I tried (as mentioned above) changing in the dfm text to change "recentinfo: TDBGrid;" into "recentinfo: TCustDBGrid". Since the definition of TCustDBGrid is in the same unit as the tform, I figured it would work. I'm guessing it's wrong thinking this way as what I'm doing is in essence using a visible component which uses a different set of rules than simple "TpointX = class(TPoint)" type of definition. If I just click on the grid, and create an event handler for "OnMouseDown", as mentioned in [2], it doesn't work as it fires only if I click on the headers. Then I came across [3] and while I think it should work, I haven't yet found out how to find out whether the componentclass' instance is what I wanted. Tbh, it would've been just simpler had I made this custom dbgrid as a package and be done with it; but I feel there has to be a way other than the package route. Thanks Edmund [1] - http://www.delphigroups.info/2/2f/507785.html [2] - http://www.delphigroups.info/2/4a/305663.html [3] - https://stackoverflow.com/questions/4685863/replacing-a-component-class-in-delphi/4686920#4686920
  4. ewong

    changing inherited control

    It's because I did use OnMouseDown but it was being ignored and I found out from [http://www.delphigroups.info/2/4a/305663.html] that it only works with the column headers. Thus my current issue.
  5. ewong

    changing inherited control

    Hi Dany, The first option isn't going to work as that'll affect other dbgrids. So I guess I'll need to use the second option even though it's a bit overkill for just this. I'm very surprised that even with TCustDBGrid defined within the same unit as the form, the dfm processing can't see that. Thanks Ed
  6. ewong

    changing inherited control

    Hi, I have added a DBGrid control on a form, and after fiddling with it, I realized I needed to override the MouseDown event. So I added a new Custom control and following the idea of http://www.delphigroups.info/2/f8/90624.html I thought changing the Text from MyGrid: TDBGrid to MyGrid: TCustDBGrid would work; but Delphi complains. If I click on ignore, it deletes the db control. If I have included the following code in the same unit as the form: TCustomDBGrid = class(TDBGrid) protected procedure MouseDown(Button: TMouseButton; ShiftState: TShiftState; X, Y: integer); end; Then if I change the DFM of the MyGrid from: MyGrid: TDBGrid; To: MyGrid: TCustDBGrid; It should work; but it doesn't, so I'm guessing I'm getting something wrong. What's the right way of doing this? Thanks Ed
  7. ewong

    Determining why Delphi App Hangs

    I took up @Dalija Prasnikar's idea of threads and while the UI isn't hanging, there's a bunch of dependency control issues. Like in the thread when I disable the controls, I realized that I can't (by design) navigate a grid which depends on a dataset which had disablecontrol set. I'm now wondering if it makes sense two have two datasets. One which is linked to a grid, the other not linked to any control so that the thread can use that non-linked dataset leaving the grid-linked dataset available for use. But as it stands, it's a definite improvement but like all things I don't understand (threads), I'll need to read up on it. Again, Thanks for the help!! Very much appreciate it.
  8. ewong

    Determining why Delphi App Hangs

    Thanks for that suggestion. I'll keep that in mind for the smaller apps. Edmund
  9. ewong

    Determining why Delphi App Hangs

    That I believe I am since I'm not using threads or anything. I think I'll try using threads and see how things go. Thanks for the idea! Edmund
  10. Hi, I have an application which goes through a dataset (a 13k+ entry table) and grabs info and adds it into a dictionary for further use. Due to the length of the table, I had also created an extra form which is basically just a progress bar. When I run the app, the progress bar's position increases. The problem is when I click on something else within the form. The application immediately hangs (Application Not Responding). The application is still running though. After some time, the progress form closes and the data is displayed. I had thought it was a painting issue; but even adding progressform.repaint to the end of the (while not dataset1.eof do) loop, the application hangs. Is there a way to find out what part of the code is hanging or why it's hanging? Thanks Ed
  11. ewong

    TMemo and unicode

    Hi Remy! That's both short and sweet! This is much better than the code I had. Edmund
  12. ewong

    TMemo and unicode

    Hi, I'm using Delphi 10.3.3 and I have two Memo fields on a form and a button. I copy and paste a RFC2047 utf8 text to the left memo field. Then I press the button, and the resulting unicode text should be on the right memo field; but I get gibberish. procedure TForm1.convertbuttonclick(Sender: TObject); var use_st, s, s2 : string; b, q : boolean; begin s := Memo1.lines[0]; use_st := '?='; if pos('=?utf-8?', lowercase(s)) > 0 then begin s2 := stringreplace(s, '=?utf-8?', '', [rfReplaceAll, rfIgnoreCase]); if pos('b?', lowercase(s2)) > 0 then begin s2 := stringreplace(s2, 'b?', '', [rfReplaceAll, rfIgnoreCase]); b := True; use_st := '=?='; end else if pos('q?', lowercase(s2)) > 0 then begin s2 := stringreplace(s2, 'q?', '', [rfReplaceAll, rfIgnoreCase]); q := True; end; end else s2 := s; if pos(use_st, s2) > 0 then s2 := stringreplace(s2, use_st, '', [rfReplaceAll, rfIgnoreCase]); if q then s3 := idDecoderQuotedPrintable1.decodestring(s2) else if b then s3 := idDecoderMime1.decodeString(s2) else s3 := s2; memo2.lines.clear; memo2.lines.add(s3); end; Say I copy and paste "=?UTF-8?B?5aaC5L2V6K6TIGFydC1tYXRlIOaIkOeCug==?=" to the first memo. I press the button, and I get some string of which only I see "art-mate'. Can someone point out what I'm missing? Thanks Ed
  13. ewong

    community.embarcadero.com's forums

    As someone on that thread said, that's brutal. Very brutal to the amount of information on those forums. While I am very dismayed at Embarcadero's practice of killing/removing vital helpful information, I'm not surprised. The forum, while not as useful as the newsgroups, at least provided some avenue of help/information. Thanks Remy for the info. At least I'm glad I can still see quite a few old regulars on the newsgroup. Perhaps Joanne might even appear here?
  14. ewong

    TDBGrid's SelectedRows count

    I was wondering what the arrow and dot meant. That clears up that question. Thanks!
  15. ewong

    TDBGrid's SelectedRows count

    That explains what I'm seeing. Thanks! I got the OnDataChange idea from Stackoverflow. Ed
×