home *** CD-ROM | disk | FTP | other *** search
- REM Description: Runs the Character Map application
- REM Filename: charmap.wmc
- REM Created by: Steven Wylie - 11/08/93
- REM Updated by: Rich Zuris - 1/19/94
-
- DECLARE FUNCTION FindWindow LIB "user" (classname AS INTEGER, title AS STRING) AS WORD
- DECLARE FUNCTION SetFocus LIB "user" (hwnd AS WORD) AS WORD
- DECLARE FUNCTION GetActiveWindow LIB "user" () AS WORD
- DECLARE FUNCTION WinExec LIB "kernel" (path AS STRING, show AS WORD) AS WORD
- DECLARE FUNCTION SendMessage LIB "user" (hwnd AS WORD, msg AS WORD, wParam AS WORD, lParam AS INTEGER) AS INTEGER
- DECLARE FUNCTION MessageBox LIB "user" (hwnd AS WORD, msg AS STRING, title AS STRING, style AS WORD) AS WORD
- DECLARE FUNCTION OpenClipboard LIB "user" (hwnd AS WORD) AS WORD
- DECLARE FUNCTION EmptyClipboard LIB "user" () AS WORD
- DECLARE FUNCTION CloseClipboard LIB "user" () AS WORD
-
- 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 Can't run in a graphic or table frame
- frameType% = GetFrameType()
- IF frameType% <> 0 THEN
- Message "The current frame must be a text frame."
- STOP
- ENDIF
-
- REM Can't run in frame mode
- ret% = ViewEditMode(1)
- IF ret% = 2 THEN
- ret% = ViewEditMode(2)
- BEEP
- STOP
- ENDIF
-
- REM Store off WSWin active window
- wswin% = W2I(GetActiveWindow())
-
- 'Clear clipboard in order to test later whether content has changed
- IF OpenClipboard(I2W(wswin%)) <> 0 THEN
- ret% = EmptyClipboard()
- ret% = CloseClipboard()
- END IF
-
- REM Load Character Map if not loaded already
- charmap% = W2I(FindWindow(0, "Character Map"))
- IF charmap% = 0 THEN
- err% = WinExec("CHARMAP.EXE", I2W(1))
- IF err% < 0 THEN err% = err% * -1
- IF err% < 33 THEN
- Message("Couldn't run Character Map.")
- STOP
- ENDIF
- charmap% = W2I(FindWindow(0, "Character Map"))
- ENDIF
-
- ret% = SetFocus(I2W(charmap%))
-
- title$ = "Running Character Map..."
- msg$ = "Select the characters you want from the Character Map application and choose the Copy button. "
- msg$ = msg$ + "Press OK to paste the characters into your document."
-
- ret% = MessageBox(I2W(0), msg$, title$, I2W(1))
-
- IF ret% = 2 THEN STOP
-
- ret% = GetClipboardText(newClip$)
- REM If clipboard content hasn't changed, nothing was copied from Charmap.
- IF newClip$ = "" THEN
- title$ = "WSWin 2.0"
- msg$ = "You must use the Copy button on the Character Map window to copy the selected characters to the clipboard. Please run the macro again."
- ret% = MessageBox(I2W(0), msg$, title$, I2W(0))
- SetFocus(I2W(wswin%))
- STOP
- ELSE
- REM Get the current character map font. Note: You may have to change "MSCharMap" to
- REM something else if the INI file section in WIN.INI changes with a later release of
- REM Windows.
-
- REM We have to close Character Map to update the font entry in WIN.INI.
- charmap% = W2I(FindWindow(0, "Character Map"))
- IF charmap% <> 0 THEN
- REM Send it a WMCLOSE message.
- ret% = SendMessage( I2W(charmap%), I2W(16), I2W(0), 0 )
- ENDIF
- GetProfileString "MSCharMap", "Font", "None", fontName$
- IF fontName$ <> "None" THEN
- charmapText$ = "<Ft "+fontName$+">"+newClip$+"<Ft>"
- ELSE
- charmapText$ = newClip$
- ENDIF
- ret% = SetFocus(I2W(wswin%))
- TypeText charmapText$
- ENDIF
-
- ***** WARNING *****
- This is a WSWin macro file.
- Subsequent data is binary information and should not be modified.