190 likes | 326 Views
Creating a Dialog-Based Comet Windows Program. Brian Levantine. Tools you’ll need. Ultra Edit – Programmer’s Text Editor Microsoft Visual Studio .NET (VS) – Resource Editor/DLL Compiler Visual Studio Project Generator – DPBuild.Exe COSD – Comet Symbolic Debugger. Ultra Edit – Text Editor.
E N D
Creating a Dialog-Based Comet Windows Program Brian Levantine
Tools you’ll need • Ultra Edit – Programmer’s Text Editor • Microsoft Visual Studio .NET (VS) – Resource Editor/DLL Compiler • Visual Studio Project Generator – DPBuild.Exe • COSD – Comet Symbolic Debugger
Ultra Edit – Text Editor • Configurable tools • Syntax highlighting • Auto-indent • File compare • Error location • Cheap!
COSD – Symbolic Debugger • Symbolic • Steps through code • Breakpoints • View/Modify variables • Debug messages • Background partitions
MS Visual Studio .NET • Editing resources • Generating Dynamic Link Library • Robust help (if you use it) • We are NOT programming in C++, C#, or VB
VS Project Generator – DPBuild.Exe • Generates a ready-to-use Visual Studio Project • Allows the user to specify the project filename and folder • Will create the project folder if it doesn’t already exist
The components of a Comet Windows program • VS (Visual Studio) Project files • Usually located in a folder directly below IB source files • Generates a binary DLL file containing resources that will be loaded and used by a IB program - <ProjectName>.dll • Generates a text “include” file that should be included in any IB source file that references resources within the DLL - <ProjectName>.inc • IB Source files • Include file generated by VS – must be registered in Comet QDIR • Generated Comet .OBJ file
What is a Resource? • A Resource is a discard-able non-program object that can be individually loaded from a DLL or EXE file for use by a program. When the program is done with the resource it can discard it from memory to conserver space. Some common resources are: • Dialog boxes • Bitmaps • Icons • Menus
What is a DLL? • A DLL (Dynamic Link Library) is a file that contains compiled binary information consisting of program code and or program resources • A DLL can (and usually does) contain many resources for use by any program that requires them. For Comet programs, a single DLL may contain all of the Dialog boxes for an entire application or for a single module.
Why use Dialogs and DLLs? • A dialog box provides the simplest and fastest way to write code for and load a form. With few exceptions dialogs can provide all of the features necessary for a good user experience. • A DLL provides a convenient mechanism for storing many dialogs in a single file. The file can then be downloaded to a CometAnywhere client to display any forms at maximum speed.
What are Controls? • A Control is a child window, usually placed into a dialog box, that has a specific appearance and pre-defined behaviors. Some common controls are: • Edit - ListView • Radio Button - TreeView • Checkbox - Textbox • Pushbutton - Picture • Listbox - Tab
Building your first Dialog • Be sure all of the aforementioned tools have been properly installed on your system before beginning this exercise • Don’t be intimidated by the VS IDE (Integrated Development Environment). It’s easy to start again if you mess up. • Don’t be afraid to experiment • Be patient with me. If you haven’t yet figured it out, I don’t know it all!
Step 1 – Create your project • Run DPBuild.Exe • Specify the 8 character project filename and the project folder location • Note that the specified location will have the <ProjectName> appended to it so that the resulting project folder will have the same name as the project. • The generated project will expect it’s folder to be located one level below your IB source folder. The two output files: <ProjectName>.dll and <ProjectName>.inc will be copied up to the parent folder. Once a project has been created it is possible to manually modify the output location. • Press the “Generate” button to build your new project. • Answer “Yes” to the “launch the project now?” question
Step 2 – Create a dialog • Choose “Resource View” from the “View” menu or press Ctrl+Shift+E. • In the “Resource View” window right click on the icon identified as <ProjectName>.rc and choose “Add Resource”. • In the “Add Resource” window choose “Dialog” and press the “New” button. • Choose “Properties Window” from the “View” menu or press F4. • Set “Visible” property to True. • Click to the right of ID and give the new dialog a new identifier name: IDD_<ProjectName>. • Click to the right of the “Caption” property and enter a new dialog title and press tab.
Step 3 – Add a Static text control • Choose “Toolbox” from the “View” menu or press Ctrl+Alt+X. • In the “Toolbox” window select and drag a Static Text control onto the new dialog. • In the “Properties” window click to the right of the “Caption” property and enter some text and press tab.
Step 4 – Compile your project • Choose “Build <ProjectName>” from the “Build” menu or press Alt+F7 • You should now find two new files in the project’s parent folder. • <ProjectName>.dll is the compiled output file containing your dialog. • <ProjectName>.inc is a text file that contains all of the symbolic constants used in the DLL in Internet Basic format (Set statements).
Step 5 – Register the include file with Comet • Double click to open the <ProjectName>.inc file in UltraEdit. • Start Comet if it is not already running. • Make sure the folder containing <ProjectName>.inc is already accessed by Comet. If not then stop and use Comet to create (if required) and access the QDIR. • Click on the “Register File” toolbar icon to register (add to QDIR) the file for access by Comet.
Step 6 – Create IB source file • Copy DlgTemp.Ibs from the DLG folder or HowTo1.Ibs from the HowTo folder into your program source folder and rename it to a filename other than <ProjectName>.ibs. Choosing a name other than <ProjectName>.ibs will prevent a conflict with the compiler’s intermediate filename. • Open the file with UltraEdit and register the file with Comet.
Step 7 – Modify the IB source to execute your new dialog • Change include filename to <ProjectName>.inc. • Change DLL name to <ProjectName>.dll. • Change dialog ID to IDD_<ProjectName> • Compile the IB source. • Run the program.