home *** CD-ROM | disk | FTP | other *** search
- REM Description: Insert custom-sized header or footer on current page.
- REM Filename: custhedr.wmc
- REM Created by Steve Wylie - 11/15/93
-
- ' This macro has to create frame styles for the current page. Otherwise, subsequent
- ' pages that have the same header or footer will not display properly. This is also
- ' why the macro has to display a message warning users to apply the frame style to the
- ' other pages that may already exist.
-
- REM There will be 9 default sizes
- DIM sizes$(10)
-
- sizes$(1) = "1.250" + CHR$(34)
- sizes$(2) = "1.333" + CHR$(34)
- sizes$(3) = "1.500" + CHR$(34)
- sizes$(4) = "1.667" + CHR$(34)
- sizes$(5) = "1.750" + CHR$(34)
- sizes$(6) = "2.000" + CHR$(34)
- sizes$(7) = "2.250" + CHR$(34)
- sizes$(8) = "2.333" + CHR$(34)
- sizes$(9) = "2.500" + CHR$(34)
- sizes$(10) = "Other"
-
- REM Can't run if no document open
- IF GetDocName$() = "" THEN
- MESSAGE "Please create a new document or open an existing document first."
- STOP
- ENDIF
-
- REM Get the current frame number so we can get back later
- frameID% = GetFrame(0, 0, 0)
-
- REM Must be a page frame
- frameType% = GetTextFrameType()
- WHILE frameType% <> 1 AND frameType% <> 2
- ParentFrame
- frameType% = GetTextFrameType()
- WEND
-
- REM Get the size and position of the header or footer from the user.
-
- index% = 3
- BEGIN DIALOG Dialog1 114, 160, "Custom Header / Footer"
- TEXT 4, 4, 40, 8, "&Size:"
- LISTBOX 4, 14, 60, 80, sizes$, index%
- TEXT 4, 100, 80, 8, "&Other Size (in inches):"
- TEXTBOX 4, 110, 80, 12, otherSize$
- TEXT 4, 126, 60, 8, "Position:"
- OPTIONGROUP footer%
- OPTIONBUTTON 4, 136, 50, 10, "&Header"
- OPTIONBUTTON 4, 146, 50, 10, "&Footer"
- OKBUTTON 70, 4, 40, 14
- CANCELBUTTON 70, 20, 40, 14
- END DIALOG
-
- ret% = Dialog(Dialog1)
-
- IF ret% = 2 THEN STOP
-
- IF index% = 10 THEN
- size% = TO_DP(otherSize$, 0)
- sizes$(index%) = otherSize$
- IF size% <= 0 THEN
- BEEP
- STOP
- ENDIF
- ELSE
- size% = TO_DP(sizes$(index%), 0)
- ENDIF
-
- GetFrameMargins l%, r%, t%, b%
- GetCurrentFrameStyle oldStyle$, local%
-
- REM Devise new frame style name from top and bottom margins.
- IF footer% THEN
- b% = size%
- newStyle$ = "P " + LEFT$(From_DP$(t%, 0), 4) + " " + LEFT$(sizes$(index%), 4)
- ELSE
- t% = size%
- newStyle$ = "P " + LEFT$(sizes$(index%), 4) + " " + LEFT$(From_DP$(b%, 0), 4)
- ENDIF
-
- REM Freeze the screen, so that the activity isn't distracting.
- rem freeze% = ViewFreezeScreen(1)
-
- REM If the frame style already exists, apply it. Otherwise, create it from the settings.
- IF ExistFrameStyle(newStyle$) THEN
- FrameApplyFrameStyle newStyle$
- ELSE
- REM Create the new frame style and modify it. (If local is TRUE, then we want to use the current settings.)
- FrameCreateFrameStyle newStyle$, oldStyle$, local%
- DefineFrameStyle newStyle$, 0
- DefineFrameStyleMargins , , t%, b%
- EndDefineFrameStyle
- FrameApplyFrameStyle newStyle$
- ENDIF
-
- REM Now add the header or footer
- IF footer% THEN
- REM If we can't insert a footer, there must already be one, so just make it the correct size.
- IF InsertFooter( , 0) = -1 THEN
- EditGoto 6, , ,
- FrameSize , , , size%
- ENDIF
- ELSE
- IF InsertHeader( , 0) = -1 THEN
- EditGoto 5, , ,
- FrameSize , , , size%
- ENDIF
- ENDIF
-
- REM Restore the screen
- freeze% = ViewFreezeScreen(0)
- IF footer% THEN
- typeStr$ = "footer"
- ELSE
- typeStr$ = "header"
- ENDIF
- msg$ = "The new " + typeStr$ + " may overlap text on other pages in this document. To correct this problem, "
- msg$ = msg$ + "apply the " + CHR$(13) + CHR$(34) + newStyle$ + CHR$(34) + " frame style to the page."
- ret% = MESSAGEBOX(msg$, "Note", 64)
-
-
- ***** WARNING *****
- This is a WSWin macro file.
- Subsequent data is binary information and should not be modified.