! *********************************************** ! ** (c) Interactive Software Services Ltd and ** ! ** Lahey Computer Systems Inc. 1997-2011 ** ! ** ----------------------------------------- ** ! ** This demonstration program source may be ** ! ** modified for training and for product ** ! ** familiarisation. ** ! ** ----------------------------------------- ** ! ** Purpose : Combined window/dialog example ** ! *********************************************** ! ! This program shows how a window and dialog can be combined into ! a single entity providing the user interface facilities of both ! windows (e.g. a main menu) and dialogs (e.g. enterable fields). ! In this particular example, the two are combined to implement ! a rudimentary text editor. ! ! The example also demonstrates the use of a resizable dialog. ! The multi-line string field which occupies the whole of the ! IDD_MAIN dialog is enabled in the resource file as resizable. ! See the "Resizable Field" option in the "Dialog Properties" ! dialog in the resource editor. ! PROGRAM COMBINE ! USE WINTERACTER IMPLICIT NONE ! ! Resource identifiers, as set via the resource editor ! INTEGER, PARAMETER :: IDM_MAIN = 30001 INTEGER, PARAMETER :: ID_FILE_NEW = 40002 INTEGER, PARAMETER :: ID_FILE_OPEN = 40003 INTEGER, PARAMETER :: ID_FILE_SAVE = 40004 INTEGER, PARAMETER :: ID_FILE_EXIT = 40005 INTEGER, PARAMETER :: ID_HELP_ABOUT = 40007 INTEGER, PARAMETER :: IDD_MAIN = 101 INTEGER, PARAMETER :: IDD_ABOUT = 102 INTEGER, PARAMETER :: IDF_STRING1 = 1001 ! TYPE(WIN_MESSAGE) :: MESSAGE INTEGER :: ITYPE INTEGER :: IPOS CHARACTER(LEN=260) :: FILENAME = '' CHARACTER(LEN=65534) :: TEXT ! ! Initialise Winteracter ! CALL WInitialise() ! ! Open combined root window and modeless dialog. ! Dialog will be shown as part of opening window. ! Initial dialog values are defined in the resource. ! CALL WindowOpen(FLAGS = SysMenuOn+MinButton+StatusBar, & MENUID = IDM_MAIN, & DIALOGID = IDD_MAIN, & TITLE = 'Combined Window and Dialog') ! ! Main message loop ! DO CALL WMessage(ITYPE, MESSAGE) SELECT CASE (ITYPE) CASE (MenuSelect) ! ! Menu item selected ! Exact action depends on option chosen ! SELECT CASE (MESSAGE%VALUE1) ! ! Clear data ! CASE (ID_FILE_NEW) CALL WDialogPutString(IDF_STRING1,'') ! ! Load text file ! CASE (ID_FILE_OPEN) CALL WSelectFile('Text Files (*.txt)|*.txt|', & LoadDialog+MustExist+DirChange+AppendExt,& FILENAME, & 'Select File To Load') IF (WInfoDialog(ExitButtonCommon) == CommonOK) THEN IPOS = 1 OPEN (20,FILE=FILENAME) DO WHILE (IPOS <= 65534) READ (20,'(A)',ERR=100,END=100) TEXT(IPOS:) IPOS = LEN_TRIM(TEXT) IF (IPOS < 65533) THEN TEXT(IPOS+1:IPOS+2) = ACHAR(13)//ACHAR(10) IPOS = IPOS + 3 ELSE EXIT END IF END DO 100 CLOSE (20) CALL WDialogPutString(IDF_STRING1,TEXT) END IF ! ! Save text file ! CASE (ID_FILE_SAVE) CALL WSelectFile('Text Files (*.txt)|*.txt|', & SaveDialog+PromptOn+DirChange+AppendExt, & FILENAME, & 'Select File To Save') IF (WInfoDialog(ExitButtonCommon) == CommonOK) THEN OPEN (20,FILE=FILENAME) CALL WDialogGetString(IDF_STRING1,TEXT) WRITE (20,'(A)') TRIM(TEXT) CLOSE (20) END IF ! ! Exit demo ! CASE (ID_FILE_EXIT) EXIT ! ! Display about box ! CASE (ID_HELP_ABOUT) CALL WDialogLoad(IDD_ABOUT) CALL WDialogShow(ITYPE=Modal) CALL WDialogUnload() CALL WDialogSelect(IDD_MAIN) END SELECT CASE (CloseRequest) ! ! Request to close window, exit demo ! EXIT END SELECT END DO ! CALL WindowClose() STOP END PROGRAM COMBINE