Welcome! Log In Create A New Profile

Advanced

Templates

Posted by Mark 
Mark
Templates
May 16, 2008 03:58PM
Hi,

I wonder if anyone can help? I am using Windev 11 and have created a window template
that I intend to reuse regularly, it has a few controls on it, and some local procedures.

I have created a new window from this template but was disappointed to find that I could not overload the local procedures carried through from the template in my new window.

Is there a way I can achieve this or is it a case of no can do?

Thanks
Louis Verbraak
Re: Templates
May 16, 2008 05:05PM
Hello Mark,

As far I know you can't overload procedures. I've one procedure in my new windows which I did not place in my template. I call this procedure indirectly:

// Indirect omdat de profiler deze routine niet herkend in de template.
lsProcedure="gwpZoektabelInlezen"
ExecuteProcess(lsProcedure,trtProcédure)

Hopefully WD13?

THT,
Pedro Santana Viera
Re: Templates
May 16, 2008 05:17PM
I had the same problem with 'heritage' in Windev 11 (awaited WD12). My solution was to put the code of the procedures in buttons and use ExecuteProcess(BTN_SAVE,trtClick) (by example) in the template. The buttons code is inherited and I can change the behaviour in whatever window I need. If the code is a function I use a global variable in the template and modify the value in the button code. And voila inherited procedures and functions. (I know, not too pretty, but...)

HTH

Pedro Santana Viera
DerekT
Re: Templates
May 16, 2008 05:31PM
Mark

Overloading is only available for the Window (by default) and the controls placed on the window (by selection)
Overloading cannot be applied to procedures.

There are a number of ways to overcome this restriction as per the previous posts.

Generally speaking window local procedures would have a well defined use and would not, unless governed by a case statement, have more than one function.
What is it that you are trying to achieve.

DerekT
Carlo Hermus
Re: Templates
May 17, 2008 05:12PM
Hi,

What are you all meaning with overloading?

I am creating templates with local procedures and I can run them fine in the new windows created with these templates.

Kind regards,

Carlo
DerekT
Re: Templates
May 17, 2008 07:51PM
Carlos

Overloading is the addition of code in controls of a window that is based on a Template

Right click on a control and select 'Overload the control' -- the Yellow square on the control turns to blue.

In the code editor of the control you will see that the code segments have been duplicated.
The Gray background are ReadOnly and contain the code that was entered when the Template was created.
The White backgroiund allows you to enter additional code (Overload) that will be run before or after the template code -- dependent on which side of the 'ExecuteAncestor' you place it.
Removal of the 'ExecuteAncestor' operator will stop the Template code from running.

This is available on the Window and all controls but NOT for Local Procedures.

HTH

DerekT
Mark
Re: Templates
May 20, 2008 12:25PM
Louis,

Thanks very much for your reply, hopefully WD13!

Mark
Mark
Re: Templates
May 20, 2008 12:33PM
Derek,

Thanks for your interest, basically I'm trying to create a template which I can use for building standard type maintenance windows, so I hoped to create some 'shell' type local procedures where I could put bits of code for example a procedure that prior to saving a record I could do some validation checks in. Hope that makes sense!

Mark
DerekT
Re: Templates
May 20, 2008 03:05PM
Mark

An alternative approach is to create a standard window with all common controls and procedures in place.
Substitute filenames with text values.
Save this for example as "MyTemplate1"

When you need a window based on this "Template"!!!!! open MyTemplate1 select File\Save As... from the menu, enter a meaningful name and accept the 'Add to project' prompt.

Use find and replace to update the text filenanes with the real filename.
You then have a standard window with all your generic code and controls which you can edit as you please.

This I guess is the preWDTemplate method but I still use it a lot.

HTH

DerekT
Pedro Santana Viera
Re: Templates
May 20, 2008 05:30PM
not at all, Mark, I'm using this method exactly for this behaviour and I'm very happy with it.

kind regards,
Pedro Santana Viera

Pedro Santana Viera
Re: Oops (kind of embarrasing) n/t
May 20, 2008 05:32PM

kind regards
Mark
Re: Templates
May 21, 2008 02:17PM
Derek,

Thanks very much for your suggestion, I will give your solution a go and see how I get on.

Mark
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: