Thanks to the similarity of IntraWeb components to standard Delphi VCL components, the The core feature of the program is its ability to show a second page. I know than many of you here use Intraweb with NexusDb. My question is not related to NexusDb. What i need is to know how to show to the. Again I found the solution shortly after asking the question here.
|Published (Last):||8 March 2004|
|PDF File Size:||15.26 Mb|
|ePub File Size:||17.59 Mb|
|Price:||Free* [*Free Regsitration Required]|
When you build an IntraWeb application, a number of components are available. For example, if you look at the IW Standard page of Delphi’s Component Palette, you’ll see an impressive list of core components, from the obvious button, check box, radio button, edit box, list box, memo, and infraweb on to the intriguing tree view, menu, timer, grid, and link components.
OT: how to show a pdf with Intraweb ? – NexusDB Newsgroups
I won’t list each component and describe its use with an example—I’d rather use some of the components in a few demos and underline the architecture of IntraWeb rather than specific details.
I’ve built an example called IWTree showcasing the menu and tree view components of IntraWeb but also featuring the creation of a component at run time. This handy component makes available in a dynamic menu the content of a standard Delphi menu, by referring its AttachedMenu property to a TMenu component:.
If the menu items handle the OnClick event in the code, they become links at run time.
Building IntraWeb Applications
Here is the code for a couple of event handlers:. Thanks to the similarity of IntraWeb components to standard Delphi VCL components, the code is easy to read and understand. The menu has two submenus, which are slightly more complex. The second submenu, Tree Contents, shows a list of the first tree nodes of the main level along with the number of direct subnodes. What’s interesting, though, is that the information is displayed in a memo component created at run time see again Figure For example, this program’s menu with alTop alignment, the tree view has alClient alignment, and the dynamic memo is created with alBottom alignment.
As an alternative, you can use anchors again working as in the VCL: You can create bottom-right buttons, or components in the middle of the page, with all four anchors set. See the following demos for examples of this technique. All the programs you have built so far have had a single page. Now let’s create an IntraWeb application with a second page. As you’ll see, even in this case, IntraWeb development resembles standard Delphi or Kylix development, and is different than most other Internet development libraries.
This example will also serve as an excuse to delve into some of the source code automatically generated by the IntraWeb application wizard. Let’s start from the beginning. This powerful component allows you to place within an HTML grid both text and other components. In the example, the grid content is determined at startup in the OnCreate event handler of the main form:.
The effect of this code is shown in Figure In addition to the output, there are a few interesting things to notice.
Even if the program calls the Show method, it can be considered like a ShowModal call, because IntraWeb considers visible pages as a stack. The last page displayed is on the top of the stack and is displayed in the browser.
By closing this page hiding or destroying ityou re-display the previous page. In the program, the secondary pages closes itself by calling the Release method, which as in the VCL is the proper way to dispose of a currently executing form. You can also hide the secondary form and then display it again, to avoid re-creating it each time particularly if doing so implies losing the user’s editing operations.
In the program I added a Close button to the main form. It should not call Releasebut rather should invoke the WebApplication object’s Terminate method, passing the output message, as in WebApplication. The demo uses an alternative call: Now that you have seen how to create an IntraWeb application with two forms, let’s briefly examine how IntraWeb creates the main form.
The relevant code, generated by the IntraWeb wizard as you create a new program, is in the project file:.
This is different from Delphi’s standard project file, because it calls a global function instead of applying a method to a global object representing the application. The effect, though, infraweb quite similar. The two parameters are the classes of intfaweb main form and of the IntraWeb controller, which handle sessions and other features as you’ll see in a intraqeb.
The form has a graphical component with the classic Delphi Athena image. This is accomplished by loading a bitmap into the an IWImage component: The extra feature provided by IntraWeb and exploited by the program is that a user can click on the image with the mouse to modify the image by launching server-side code. In this program, the effect is to draw small green circles. The painting operation takes place on the bitmap canvas. If you’ve done any web programming, you know that session management is a complex issue.
IntraWeb provides predefined session management and simplifies the way you work with sessions. If you need session data for a specific form, all you have to do is add a field to that form. The IntraWeb forms and their components have an instance for each user session. As a contrast, I’ve also declared a global unit variable called GlobalCountwhich is shared by all the instances or sessions of the application.
To increase your control over session data and let multiple forms share it, you can customize the TUserSession class that the IntraWeb Application Wizard places in the ServerController unit.
In the IWSession example, I’ve customized the class as follows:. In an application’s code, the session object can be referenced by accessing the Data field of the RWebApplication global variable, used to access the current user’s session. It gives you access to the session intraewb in a thread-safe way: This variable can be used outside of a form or control which are natively session-basedwhich is why it is primarily used inside data modules, global routines, and non-IntraWeb classes.
Because most of this code is generated for you, after adding data to the TUserSession class you simply use it through the UserSession function, as in the following code extracted from the IWSession example.
When you click a button, the program increases several counters one global and two session-specific and shows their values in labels:. Notice that the program uses Windows’ InterlockedIncrement call to avoid concurrent access to the global shared variable by multiple threads. The program has also a check box that activates a timer. Odd as it sounds, in an IntraWeb application, timers work intaweb the same as in Windows.
Up to now, you have built stand-alone IntraWeb applications. When you create an IntraWeb application in a library to be deployed on IIS or Apache, you are basically in the same situation.
The bridge between the two worlds is the IWPageProducer component. This component hooks to a WebBroker action like any other page producer component and has a special event you can use to create and return an IntraWeb form:. With intrawsb single line of code plus the addition of an IWModuleController component in the web modulethe WebBroker application can embed an IntraWeb page, as the CgiIntra program does. A component of this type must exist in every project for IntraWeb to work properly.
This issue has been fixed and is a shiw update. Because this is a Page mode CGI application, it has no session management. Moreover, the shoq of the components in a page is not automatically updated by writing event handlers, as in a standard IntraWeb program. To accomplish ibtraweb same effect you need to write specific code to handle further parameters of the HTTP request. It should be clear even from this simple example that Page mode does less for you than Application mode, but it’s more flexible.
The CgiIntra program features another interesting technology available in IntraWeb: That topic isn’t really related, because HTML layouts work also in Application mode—but I’ve happened to use these two techniques in a single example.
In the programs built so far, the resulting page is the mapping intrweb a series of components placed at design time sbow a form, in which you can use properties to modify the resulting HTML. But what if you want to embed a data-entry form within a complex HTML page? The alternative approach is represented by the use of IntraWeb’s layout managers. As you can see in Figure The HTML editor will be improved in a coming upgrade, and a few quirks will be fixed. The components are marked only with a special tag based on curly braces, as in the following of the example:.
Thus the form becomes only a component holder, because the size and position of the form’s components are ignored. Home Programming Mastering Delphi 7. This handy component makes available in a dynamic menu the content of a standard Delphi menu, by referring its AttachedMenu property to a TMenu component: TMenuItem end object About1: Here is the code for a couple of event handlers: TObject ; var i: Integer; begin for i: Count – 1 do IWTreeView1.
The IWTree example features a menu, a tree view, and the dynamic creation of a memo component.