Consultor Eletrônico



Kbase P100172: A way to program for dual display.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   18/01/2005
Status: Unverified

GOAL:

A way to program for dual display.

FIX:

One way to implement multiple display applications is to allow the users to define the position for any window in the application. This requires providing the user the ability to set the position of any window in the application at any time. This also requires a mechanism to store the user preferences for the window's position once changed.
The following example uses a window, a button, a temp-table and a text file to demonstrate the concepts described above:
1. Create a text file with one line of data storing the window's title, its x-coordinate and its y-coordinate:
"First Window" 0 0.
2. Start The AppBuilder.
3. Create a new window. Name it " FirstWindow". Label it "First Window".
4. Drop a button widget on the window. Name it " SetCurrentCoordinates". Label it "Set Current Coordinates".
5. In the window's definitions section add the code for the TEMP-TABLE that would store the titles and the coordinates of all the application windows:
DEFINE TEMP-TABLE Coordinates NO-UNDO
FIELD WindowTitle AS CHARACTER
FIELD xCoordinate AS INTEGER
FIELD yCoordinate AS INTEGER.
6. In the window's Main Block section, insert the following code that (A) Loads the various windows coordinates into the temp-table and (B) Place the current window in its proper position:
/* Load all the windows coordinates into the temp-table */
INPUT FROM Coordinates.txt.
REPEAT:
CREATE Coordinates.
IMPORT Coordinates.
IF WindowTitle = "" OR WindowTitle = ? THEN LEAVE.
END.
INPUT CLOSE.
/* Place the current window in its position */
FIND FIRST Coordinates WHERE WindowTitle = {&WINDOW-NAME}:TITLE.
IF AVAILABLE (Coordinates) THEN DO:
ASSIGN
{&WINDOW-NAME}:X = xCoordinate
{&WINDOW-NAME}:Y = yCoordinate.
END.
7. Define a CHOOSE event trigger for the "SetCurrentCoordinates" button that: (A) Captures the current window's position coordinates, and (B) Updates the windows coordinates storage file.
DO:

FIND FIRST Coordinates WHERE WindowTitle = {&WINDOW-NAME}:TITLE.
ASSIGN
xCoordinate = {&WINDOW-NAME}:X
yCoordinate = {&WINDOW-NAME}:Y.
OUTPUT TO Coordinates.txt.
FOR EACH Coordinates WHERE WindowTitle <> "" AND WindowTitle <> ?:
EXPORT Coordinates.
END.
OUTPUT CLOSE.
END.
8. Save the window as FirstWindow.w.
9. Run the code. Move the window into a new position. Click the "SetCurrentCoordinates" button. Close the window.
10. Run the window again. Observe that the window is placed now in the position that it was when the "SetCurrentCoordinates" button was clicked.