Beiträge von Workshop Alex

    I am working on a solution that dynamically adds database tables to the form. The user selects a table, the table gets it's fields listed in the object inspector and from there the user can drag and drop the database fields.

    But now I need a simple solution to delete these tables again from the form. Thus, the related band must be removed and the related form fields must be deleted. And although it's not easy to find the form fields linked to the table, this is still easy to do.

    My problem is that I need some solution to determine which table the user wants to delete. I can show a popup menu when the user right-clicks in the object inspector on some band header, but how do I know which band the user clicked on? Where doesn't seem to be a method for this. And the bands themselves don't seem to have any events either.

    I would prefer that I don't need to present a separate dialog where I need to list the tables the user can delete...

    I found the problem already. The report area has a DataField property that needs to contain the name of the table alias.
    But I also need to set the MasterDatasource of the ReportEngine to point to the same WPFDatasource for it all to work or else the report preview just won't work correctly.

    My real problem will arrive when the user wants to add multiple report areas to their form. The several tables that they can choose from have no master-detail links and there's no need for this either. It's not likely that a user will do this, though.
    But the user might be working on a delivery form with two tables. One table containing articles that need to be delivered, a second one a list of articles that have been delivered already. Two tables, thus two report areas. So also two report engines???

    It's an annoyance, really. The user can dynamically add new tables to the form and every new table will add a new band to the WPForms object inspector. I can then drag & drop fields from this object inspector on my form. But when I drop them in a report area and then show a print preview, no data is shown. (And yes, the table has plenty of data.)

    Since I need to create several controls to support this all dynamically, I just wonder if somewhere a link has been forgotten.

    I think it's more just a matter of preferences. If you e.g. look at the Dataset-based actions from Borland, you'll notice that every action is actually it's own class. As a result, they can all have some additional action-related events and properties. By just using a single base class for everything, they all must be very similar to each other. The action lack the finer tweaking that would have existed if they all had been separate actions.

    And of course I consider the ID:integer solution to identify the action to be extremely cryptic. It means I actually have to identify an action by the name that it is given if I want to check the code. At least the use of an enumerated type would have been a lot clearer at least. Something like:

    Code
    type
      TActionID = (WPFC_NEW, WPFC_OPEN, WPFC_CLOSE, ...);
      TActionIDSet = set of TActionID;

    Now, that would provide a bit more useful functionality because Delphi will display enumerated types like this very easily. And by using constants of type TActionIDSet you can even define groups of actions that are related to each other. Or use a single TActionIDSet variable to globally enable or disable all actions. If an action is in this set, it would be disabled, for example.

    Anyway, I personally don't think the use of an integer ID isn't a pretty solution.

    I have redesigned my project a bit. The multiple navigators on the form looked great and promising but I had too many technical problems getting it all contained within a Graphic component that needed to hide itself while printing.

    As an alternative, I have chosen to just add the navigator to a toolbar, combined with buttons to add and delete tables to the form and also a dropdown control to select the table that I want the navigator to control. As a result, I don't need to create a custom graphic anymore.

    To control this all, I have a special list component that contains a special class that links together a TDataset with a TDataSource, a TWPFDataSource, a TWPFObjectInspectorBand and finally a WPFObjectInspector. By using this control I can simply add new tables and automatically add a band to the inspector and make sure the form can addess the dataset fields. Also allows the table to deleted again, cleaning everything up again.

    But now I need this control to be saved and loaded together with the form. Basically just so it saves and loads all information about the tables that have been selected. The control can stream itself to any stream but am now just wondering about the best method to save and load it together with the form.
    The FormDesigner class does have events that are called after loading and before saving but these don't allow me to append the data to the form data. It would have been nice if there was an event that gets called to allow the user to load and save some custom data to the file.

    I now have to search for a nicer, alternative solution.

    Okay, another minor issue. I want to create a simple report and in this report the user can add a field from some table that is added to the system. This field happens to be a lookup field. Which means it is a persistant field with properties LookUpDataset, KeyFields, LookUpKeyFields and LookUpResultField set up to link to a second table. I had hoped that the form would recognise this field as a lookup field and thus offer the proper layout immediately. Or at least show the lookup data when I change the edit control into a dropdown control.

    Unfortunately it doesn't recognise the field as a lookup field so I don't get a nice list of values. This means I need to add more code to just get it to work, or perhaps modify the source.

    >> I don't like it either. But the inherited "name" property requires the name to be empty or unique - and creates an ugly exception otherwise. <<

    Then again, it would have been a lot nicer if this property had used a SetName method to set the name. Right now, things are just a bit too confusing, because the class now has two properties with the same name, and one of them cannot be accessed anymore. Personally, I would have preferred it if the Name property wasn't overridden. If you wanted to add a custom name to the class, you could have used a different name for it.

    It's not a real big issue for me but I expected some simple behaviour here. I had overridden the SetName method in my custom graphic and it took me half a day to just discover why it didn't change the name of the graphic. The reason being of course that the name property that SetName refers to uses a property that's now hidden by the new Name property.

    In general, the name property for components is pretty useful since you can search in your component list for any component with a given name. But with WPForms this functionality is broken because there is no way to access this hidden name property.

    I also seem to have problems when I start the 'Create Report' action, because this action seems to close the graphic control, then creates two copies of it again and finally deletes one of these copies again. Seems a bit complex in my opinion, but worse... The data in my custom property (assigned to FProperties) just are lost...

    I must say that it's a very complex task to add even a single custom graphic.

    I just wonder why a choice has been made to just create a single TWPFAction with some hard-to-remember ID number that defines which action will be executed. Wouldn't it be easier to define one TWPFBaseAction class and then create all other actions as inherited actions from this base class? That way, it would be a lot easier to have an overview of all those actions.

    Or maybe just replace the ID of integer type with an ID of some enumeration type. I just don't understand why it had to be solved in such a complex way...

    To my big suprise the property 'Name' is overridden in the TWPFGGraphic class and this just breaks up my complete code. Let me explain why...

    I have a form on which I drop several of these graphics. I have an additional stringlist where the names for these graphics are stored. These names are entered by the user in runtime because there will also be bands and other controls that will link to just this name. So I have code like this:


    The TableGraphicList object is my list of graphics. DisplayException will log and display the exception without reraising the exception. Basically, I let the user enter a name for the control until he has entered a valid name. (IsValidIdent is a Delphi function, btw.)

    The magic in my class is that in the SetName method that I've overridden, I add the name to a list and do some further processing with this name. (E.g. adding to a dropdown box, writing the name to a log, things like that.)

    However, since the inherited 'Name' property is hidden by the new 'Name' property, this just doesn't work. I could of course work around this by adding my own, new 'Name' property and assign some methods to it to use the inherited name property but personally, I feel this a bit bad design.

    Was there any need to override the Name property in WPForms? It's a really annoying thing that took me half a day to discover, and I only discovered it because I have checked the source.

    I have created a custom TWPFCustomGraphicObject class similar to the labelprinter demo with it's custom button. Basically, this will drop a DB Navigator on the form that is linked to some database table. This single control is thus a container for several child controls.
    When the control is added to the form in runtime, it will also add the table fields to a band in the object inspector so a user could just drop this control on his form and then select the fields from this table. The navigator will allow the user to walk through the table to select the appropiate record.

    This solution has been chosen because the user will, in general, drop about half a dozen of these controls on his form, each linked to a different table. One for salespersons, one for customers, one for articles, etc.

    The problem, however, is that when the report is printed then these navigators should not be printed! So how do I prevent them from being printed in either the preview or the true print-out?

    Hi, I am using WPForms2 and I need the following situation to work:

    I have a custom TWPFCustomGraphicObject class with a button on it. This class also contains a few in-memory database tables (TdxMemData from DevExpress) that are empty by default. The purpose is that a user clicks on the button and a data-entry form will pop up where she can enter all kinds of information. When the form is closed, this data is then displayed on the form.

    Well, it all works reasonable well but I need a way to save and load these forms to file AFTER she has entered data. This data needs to be stored with the form. But I can'tt discover where I can hook into the save/load mechanism of WPForms to include my stream of data into the whole stream of data.

    Of course an option would be to do the saving in my own code, using my own save/load actions but I don't like that option right now. I feel that would be like defining my own file format while WPForms already has a good file format.

    Hi, I am using Delphi 5, recently acquired WPForms 2 and started reading the manual and tried to do the very first steps as described in this document. Unfortunately, it just doesn't work as described.

    The example is simple. Drip an imagelist, a WPActionList, a controlbar, a mainmenu and a WPFormWizard on the form, set the properties and double-click the wizard to generate 89 actions.
    Unfortunately, I get 0 actions... No access violations or whatever. It even adds a menuitem to the mainmenu yet it does NOT create any actions...

    Of course I can just ignore this and add them manually but isn't this supposed to work correctly?

    I have an image in my application that needs to be inserted during the mailmerge stage. The image is dynamically created and stored in a TGraphic object and changes with every merge.

    I am using the OnMailMergeGetText to fill the data and assume I have to use the Contents.CurrentObject.CreateImage to create the image in the field yet I don't know what the first parameter must be. The second one is my graphic, but the first?...
    Or am I using the wrong approach here?

    I have an RTF file which contains a header and footer. Both header and footer contain fields that need to be mail-merged with some data but whenever I call "WPRichText.MergeText" it will just merge the text in the main body, but not in the header and footer.

    Let me explain more precisely what I am doing, though. First, I start with a Word document which I save as .RTF by using the OLE automation interface of Word. This becomes a copy of the original document and the basis for the merge document.
    In this original document, the user has provided space for the merge fields by using something like <#Fieldname> in the original document. I thus use:
    WPRichText.ReplaceTokens( '<#', '>' );
    This will convert those user-defined fields into WPTools fields. I then do a few more calculations before the MergeText function gets called.

    In the resulting document, the fields in the main body have received the proper values. Unfortunately, the headers and footers still contain the texts <#Fieldname> so it appears ReplaceTokens doesn't work on those.

    So, what am I missing here?