A display window was the essential part the Windows CE text browser. The code for this part also included the windows class registration and initialization, as well as the messaging callback API's, therefore forming the skeleton of the whole application.
The development process started with writing the skeletal windows application code, which was derived from the sample Hello World program. Command bar was created at the window creation stage. Also included besides the paint and destroy message modules was the functionality for the window to be resized. Initially, the program consisted of a main window that would display a given text at the painting stage using the DrawText command. What set it apart from the hello world code was its ability to do the word wrapping. Also the background and the text colors could be specified in the source code. During this stage the program code was compiled by the Windows CE Platform Builder and transferred to the target system to be initially tested.
The second stage was adding a menu capability in the command bar. First implementation was tried by editing the resource file in text format, but it was soon noticed that designing the menu was much easier using the visual tools provided by the Platform Builder. Included in the menu were selections for Opening a web page, Closing, and Exiting application. Also Cut, Copy and Paste editing choices were provided by the menu, but they were never implemented in the lifetime of this project. After the development of the menu resources, the actual menu was added to the display at the main window creation module using CommandBar_InsertMenubar command. User initiated menu events were sent to the main command message handling module and then dispatched to related subroutines, depending on the lower word of the wParam parameter of the WM_COMMAND message.
The third stage was adding the capability to scroll the displayed text up and down. However implementation of the scroll bar required creation of a child window for the text to be displayed. The main window would form the frame containing the command bar along with the menu buttons. The child, or the client window as we call it, was registered at the same time as the main frame, and initialized at the DoCreateMain stage. From then on, the WM_PAINT and WM_VSCROLL messages were handled by the client window. The scroll bar was added at the window creation stage. The scroll bar messaging was handled by the DoVScrollClient subroutine. The text scrolling was ingeniously implemented by subtracting the scroll bar position from the client rectangle's top side, within the DoPaintClient routine. The text was read from the file generated by Yannick's Parser program, using the ReadFile statement within ReadWebPage subroutine. Then the scroll bar's size was adjusted by measuring the total length of the text in terms of number of lines using the FindTextLength function.
The last stage was to add an edit window where the user could enter the URL of the web page to be displayed. At the first implementation, the edit window showed up. However during further development, it was seen that user input and output using an edit window was a pretty hard programming task to undertake, and could not be finished within three days remaining of the project deadline. A better way to get the user input for URL would be to use a Dialog Box that would spring up whenever the user chose the Open option from the menu. The parts of the code for the edit window was commented out from the project, and the Dialog Box was easily implemented using the DialogBox statement. Windows messages for the dialog box would be handled by the OpenDlgProc statement.
Thus the Graphical User Interface Application for the Windows CE Web Browser project came to an end. During incorporation of the other parts of the project into the main architecture, we came across several bugs. For example the scroll bar would not correctly resize after a second web page was opened, or sometimes would not show up at all. That bug was eventually corrected. The repainting after a second web page download doesn't still work that efficientl. There are also still two inconveniences in the program: if the Cancel button is pressed in the URL Dialog Box when no webpage is showing, we get a brief internet connection error, but the program still functions well afterwards. And none of the menu selections except Open and Exit are designed to function, they are just there to prove that multiple selections can be put on the menu bar.
Here is the source
code for the WinGUI application, if you are interested. Just click
on the links below:
|
|
|
|
Murat Guler - Spring '00