![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 7 of 7 total |
![]() |
Mon, Feb 5 2018 4:15 AM | Permanent Link |
Paul Coshott | Hi All,
I have a form where the user can create TPanel's within a TScrollPanel. If the user double clicks the caption bar, I need an event to run, that changes the caption bars background colour, so the user can see which TPanel is selected. I can link up the event, but I'm not sure how to reference the control. The following code with the CaptionBarDblClick event procedure does not work. How should I do this? One other question : is it not possible to register when the user single clicks the caption bar? Cheers, Paul ------------------------------------------------------------------------------------------------------------------ procedure TfSchedule.panelDayCaptionBarDblClick(Sender: TObject); begin with Sender as TPanel do begin CaptionBar.Background.Fill.Color := clRed; end; end; procedure TfSchedule.Button7Click(Sender: TObject); begin ScrollPanel1.BeginUpdate; try with TPanel.Create(ScrollPanel1) do begin Layout.Position := lpTopLeft; Layout.Stretch := lsBottom; Layout.Consumption := lcRight; Background.Fill.Color := clLightSkyBlue; CaptionBar.Height := 25; CaptionBar.Background.Fill.Color := clElevateGray; CaptionBar.Caption := 'Panel ' + IntToStr(ScrollPanel1.ControlCount); CaptionBar.AllowClose := False; CaptionBar.AllowMinimize := False; CaptionBar.AllowMove := False; Width := 300; OnCaptionBarDblClick := panelDayCaptionBarDblClick; end; finally ScrollPanel1.EndUpdate; end; end; |
Mon, Feb 5 2018 5:15 AM | Permanent Link |
Matthew Jones | Paul Coshott wrote:
> The following code with the CaptionBarDblClick event procedure does not work. How should I do this? It looks like it should work to me - and I've done a lot of this sort of adding a panel and wiring up the events. Two things I'd do here, and one is to use my "DebugReport" function which outputs the text to a memo so I can see what is happening. The memo is right aligned to the form and normally hidden but can be shown by double-clicking on a secret place (and actually only if you have set a value in storage, but that's getting fancy). Anyway, it is just the age old "printf" debugging, but may tell you what is happening. Is the event called at all? The other option is to use the browser debugging tools, and put breakpoints on the code to see what happens. I often find it reveals all sorts of interesting things about why my assumptions were wrong. And of course finally, just a simple sanity check - drop on a panel, add the event and check it works as you expect when not done in code. -- Matthew Jones |
Mon, Feb 5 2018 8:02 AM | Permanent Link |
Paul Coshott | "Matthew Jones" wrote:
> It looks like it should work to me - and I've done a lot of this sort of adding a panel and wiring up the events. Hi Matthew, Thanks for the reply. It's actually not even compiling. If I have: with Sender as TPanel do begin the error I get is: [Error] Templates.wbs (143,15): Expected do but instead found as If I try: with Sender do begin CaptionBar.Background.Fill.Color := clRed; the error is : [Error] Templates.wbs (144,5): The referenced variable, parameter, or function CaptionBar does not exist Any ideas? Thanks, Paul |
Mon, Feb 5 2018 8:49 AM | Permanent Link |
Uli Becker | Pau,
with Sender do begin CaptionBar.Background.Fill.Color := clRed; Use with TPanel(Sender) do begin ... Uli |
Mon, Feb 5 2018 8:56 AM | Permanent Link |
Matthew Jones | Uli Becker wrote:
> Use > > with TPanel(Sender) do begin Or better yet, ditch that horrible "with", and use: TPanel(Sender).CaptionBar.Background.Fill.Color := clRed; If I'm doing multiple operations on it, I assign to a local variable and use that. This has the advantage that the Chrome debugger shows me the values etc. Perhaps EWB creates a suitable temporary when you use "with", but it won't be the name you would choose and recognise, and it is still horrible. 8-) -- Matthew Jones |
Mon, Feb 5 2018 2:08 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Matthew,
<< If I'm doing multiple operations on it, I assign to a local variable and use that. This has the advantage that the Chrome debugger shows me the values etc. Perhaps EWB creates a suitable temporary when you use "with", but it won't be the name you would choose and recognise, and it is still horrible. 8-) >> It does, but only with its internal runtime. For the browser, it leaves the with handling up to the V8 engine. Tim Young Elevate Software www.elevatesoft.com |
Mon, Feb 5 2018 9:26 PM | Permanent Link |
Paul Coshott | Awesome, thanks guys.
Cheers, Paul |
This web page was last updated on Thursday, March 30, 2023 at 10:19 AM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |