Board index » delphi » Weird problem with 'with' 'try'...'finally'
Luu Tran
![]() Delphi Developer |
Sat, 30 Sep 2000 03:00:00 GMT
|
Luu Tran
![]() Delphi Developer |
Sat, 30 Sep 2000 03:00:00 GMT
Weird problem with 'with' 'try'...'finally'Hi I have a component derived from TCustomComboBox that saves state info in with TRegistry.Create do When the component is freed, I get 'component has no parent window' error. reg:=TRegistry.Create; And it was fine. Why? -- luu Please remove the underscore _ in my address when replying by email |
ullr..
![]() Delphi Developer |
Sat, 30 Sep 2000 03:00:00 GMT
Re:Weird problem with 'with' 'try'...'finally'In article <6gv1qo$...@bgtnsc02.worldnet.att.net>, Quote
the logic is not the way you think it is, so that you're actually freeing something else in the first version. (Like if there's another "with" inside this one that could cause this sort of confusion). David C. Ullrich -----== Posted via Deja News, The Leader in Internet Discussion ==----- |
Andrew James Bednar
![]() Delphi Developer |
Sun, 08 Oct 2000 03:00:00 GMT
Re:Weird problem with 'with' 'try'...'finally'QuoteLuu Tran <luu_t...@geocities.com> wrote: : the registry. I do something like this on destroy : with TRegistry.Create do you have to assign a TRegistry variable. what you've got : reg:=TRegistry.Create; : And it was fine. Why? : -- luu -- |
Rudy Velthui
![]() Delphi Developer |
Sun, 08 Oct 2000 03:00:00 GMT
Re:Weird problem with 'with' 'try'...'finally'Andrew James Bednarz schrieb in Nachricht Quote>Luu Tran <luu_t...@geocities.com> wrote: Quote>This doesn't make sense. TRegistry.Create returns a pointer to a doesn't. It's contrary to what you'd expect from a with statement. The TRegistry object returned by create is the current object of the with statement. So theoretically, it should work. It should be completely equivalent to the following: Quote>: reg:=TRegistry.Create; |
Mitch Wolber
![]() Delphi Developer |
Mon, 09 Oct 2000 03:00:00 GMT
Re:Weird problem with 'with' 'try'...'finally'I've found that the With statement isn't all that reliable and I can't I suppose I'd need to look at the compiled code to see where the Mitch Wolberg, QuoteRudy Velthuis wrote: |
Werner Lehman
![]() Delphi Developer |
Mon, 09 Oct 2000 03:00:00 GMT
Re:Weird problem with 'with' 'try'...'finally'Quote> you have to assign a TRegistry variable. what you've got need the variable only once, I don't use a local variable at all. No memory leaks or other disadvantages because of try/finally . Regards, W.L. |
ullr..
![]() Delphi Developer |
Tue, 10 Oct 2000 03:00:00 GMT
Re:Weird problem with 'with' 'try'...'finally'In article <353F4E1C.5198A...@dnvr.uswest.net>, Quote
in fact the with statement works just fine - if you have code where with doesn't do what you expect it's because of errors in your code (ie bits in your code that don't do what you think they do, or scope problems). There are plenty of errors it's easy to make with with - for example with AnObject do AMethod; where AMethod is not actually a method of AnObject. If the form Or you can go wrong with nested with's, where both Or there _could_ be actual problems with with, but David C. Ullrich -----== Posted via Deja News, The Leader in Internet Discussion ==----- |
1. Weird problem with 'Write'?
2. Howto sort '+', '-', '*', '/',... with Delphi3
4. IndexDefs.Add('Help','Please',[ixD2WorksGreat, ixD3Errors])
5. 'stripping'/'Compressing' EXEs
6. ''%'' wildcard and case sensitivity
7. looking for the 'Windows'- or 'Message'-units
8. IBX5.03: IBTable.Locate('FieldName','Já',[loCaseInsensitive]) - Charset ISO8859-1