Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Call HTML Editor?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00468412
Message ID:
00468458
Vues:
12
>>Here's a tricky one. I have HTML code stored in a memo field. I want to give the user the option of using their associated HTML editor on the file. How do I find it/call it? I tried simply running the associated app with .html and of course IE started up.
>
>Use ShellExecute() with the "edit" verb. There are ShellExecute examples in the Microsoft KB, and here on the UT as well. Though I don't recall that the examples specifically use the "edit" verb, it shouldn't be difficult to hack at it.
>
>Of course, George and Ed will be along shortly to show you how to do it using the Windows Scripting Host. :-)

< g >I WSH.:-P The WshShell Object's Run method (unfortunately) doesn't support the Edit parameter. It simply runs the associated applications. However...Let's assume that there is no editor associated with the file. Why not let the user select it. The following is a modification of my Run_RunWith function that here is the files section. I've modified to support a user defined operation.
* FUNCTION: Run_RunWith
* Author: George Tasker
* Date: January 28, 1999 - 8:59 AM
* Purpose: Runs the program associated
* with a file (opening the progrom). If
* no association, brings up the "Open With..."
* dialog
* Modified January 25, 2001 - 10:25 AM
* Added additional optional parameter to control the operation verb

LPARAMETERS pcFilename, pnWindowState, pcOp
*
* pcFilename is the file to run and open
*
* pnWindowState (optional) is the way the window
* is displayed (default it SW_SHOWNORMAL 9)
*
* pcOp (optional) the operation to execute (open, edit, or print)
* Return value is the instance handle or error
* code

LOCAL lcFilename, lnWindowState, lnargs,;
  lnresult, lcparms, lcop, lcpath, lcbuffer,;
  lnsize, lcrundll
lnargs = PCOUNT()
IF lnargs >= 2
  IF VARTYPE(lnWindowState) = 'N'
    lnWindowState = pnWindowState
  ELSE
    lnWindowState = 9 && SW_SHOWNORMAL
  ENDIF
ELSE
  lnWindowState = 9 && SW_SHOWNORMAL
ENDIF
IF lnargs = 3
  lcop = pcOp
ELSE
  lcop = 'open'
ENDIF
lcFilename = pcFilename
lcparms = ""
lcpath = JUSTPATH(lcFilename)
DECLARE INTEGER ShellExecute IN Shell32;
  INTEGER hWnd, STRING @lpOperation,;
  STRING @lpFile, STRING @lpParameters,;
  STRING @lpDirectory, INTEGER nShowCmd
lnresult = ShellExecute(0, @lcop, @lcFilename,;
  @lcparms, @lcpath, lnWindowState)
IF lnresult < 33  && Error occurred
  IF lnresult = 31 && No file associated
    DECLARE INTEGER GetSystemDirectory IN Win32API;
      STRING @lpBuffer, INTEGER nSize
    lnsize = 260
    lcbuffer = SPACE(lnsize)
    lnsize = GetSystemDirectory(@lcbuffer, lnsize)
    IF lnsize > 0
      lcbuffer = LEFT(lcbuffer, lnsize)
      lcrundll = "RUNDLL32.EXE"
      lcparms = "shell32.dll,OpenAs_RunDLL "
      lnresult = ShellExecute(0, @lcop, lcrundll,;
        lcparms + lcFilename, lcbuffer, lnWindowState)
    ENDIF
  ENDIF
ENDIF
RETURN lnresult
I haven't tested it on a file without an associated editor, so...
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform