INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

COM and Automation

How to use the Internet Explorer's preview to view a report by mgagnon
Posted: 26 Apr 03 (Edited 16 Jun 03)


*Constants for ExecWB first parameter
#DEFINE OLECMDID_OPEN 1
#DEFINE OLECMDID_NEW 2
#DEFINE OLECMDID_SAVE 3
#DEFINE OLECMDID_SAVEAS 4
#DEFINE OLECMDID_SAVECOPYAS 5
#DEFINE OLECMDID_PRINT 6
#DEFINE OLECMDID_PRINTPREVIEW 7
#DEFINE OLECMDID_PAGESETUP 8
#DEFINE OLECMDID_SPELL 9
#DEFINE OLECMDID_PROPERTIES 10
#DEFINE OLECMDID_CUT 11
#DEFINE OLECMDID_COPY 12
#DEFINE OLECMDID_PASTE 13
#DEFINE OLECMDID_PASTESPECIAL 14
#DEFINE OLECMDID_UNDO 15
#DEFINE OLECMDID_REDO 16
#DEFINE OLECMDID_SELECTALL 17
#DEFINE OLECMDID_CLEARSELECTION 18
#DEFINE OLECMDID_ZOOM 19
#DEFINE OLECMDID_GETZOOMRANGE 20
#DEFINE OLECMDID_UPDATECOMMANDS 21
#DEFINE OLECMDID_REFRESH 22
#DEFINE OLECMDID_STOP 23
#DEFINE OLECMDID_HIDETOOLBARS 24
#DEFINE OLECMDID_SETPROGRESSMAX 25
#DEFINE OLECMDID_SETPROGRESSPOS 26
#DEFINE OLECMDID_SETPROGRESSTEXT 27
#DEFINE OLECMDID_SETTITLE 28
#DEFINE OLECMDID_SETDOWNLOADSTATE 29
#DEFINE OLECMDID_STOPDOWNLOAD 30

*Constants for ExecWB second parameter
#DEFINE OLECMDEXECOPT_DODEFAULT 0
#DEFINE OLECMDEXECOPT_PROMPTUSER 1
#DEFINE LECMDEXECOPT_DONTPROMPTUSER 2
#DEFINE OLECMDEXECOPT_SHOWHELP 3

*Constants for QueryStatusWB return values
#DEFINE OLECMDF_SUPPORTED 1 &&Command is supported by this object.
#DEFINE OLECMDF_ENABLED 2 &&Command is available and enabled.
#DEFINE OLECMDF_LATCHED 4 &&Command is an on-off toggle and is currently on.
#DEFINE OLECMDF_NINCHED 8 &&Reserved for future use.

*Constants for ShowWindow second paramter
#DEFINE SW_NORMAL    1
#DEFINE SW_MAXIMIZE  3
#DEFINE SW_MINIMIZE  6

*Constants for SendMessage second parameter
#DEFINE WM_GETICON 0x7F
#DEFINE WM_SETICON 0x80

*Constants for SendMessage third parameter
#DEFINE ICON_SMALL 0
#DEFINE ICON_BIG 1

DECLARE Long FindWindow in Win32API String, String
DECLARE Long BringWindowToTop in Win32API Long
DECLARE Long ShowWindow in Win32API Long, Long
DECLARE INTEGER SetWindowText IN user32 INTEGER hWnd, STRING lpString
DECLARE INTEGER ExtractIcon IN shell32 INTEGER hInst, STRING  lpszExeFileName, INTEGER lpiIcon
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd, INTEGER Msg, INTEGER wParam, INTEGER lParam

Public oBrowser
Local sTempPath, lnHWND, lcTitle, lnIcon

PUSH Key

ON KEY LABEL ALT+X Cancel && Just in case we get stuck in Do Loop

CREATE CURSOR myCursor (name c(20),address c(20))
INSERT INTO myCursor (name, address) VALUES ("Mike","123")
INSERT INTO myCursor (name, address) VALUES ("Paul","321")
INSERT INTO myCursor (name, address) VALUES ("John","345")
INSERT INTO myCursor (name, address) VALUES ("Ringo","567")
INSERT INTO myCursor (name, address) VALUES ("Georges","987")
GO top
sTempPath = ADDBS(SYS(2023))
IF !FILE(sTempPath + "someSheet.htm")
    SET TEXTMERGE TO memvar lcHTML noshow
    SET TEXTMERGE on
    \\<HTML><BODY><TABLE>
    SCAN
     \<tr>
      FOr lnField = 1 to AFIELDS(laFields)
         \\<td><<EVALUATE(FIELD(m.lnField))>><td>
      ENDFOR
      \</tr>
    ENDSCAN
    \</table></body></html>
    SET TEXTMERGE OFF
    SET TEXTMERGE TO
    STRTOFILE(lcHTML,sTempPath + "someSheet.htm")
ENDIF

oBrowser=CREATEOBJECT("internetexplorer.application")
oBrowser.navigate(sTempPath+"someSheet.htm")

DO WHILE oBrowser.QueryStatusWB(OLECMDID_PRINTPREVIEW) != (OLECMDF_SUPPORTED + OLECMDF_ENABLED)
    DOEVENTS
ENDDO
oBrowser.ExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_PROMPTUSER)

lcTitle = "Print Preview"
lnHWND = 0
DO WHILE lnHWND = 0 &&Seems to take ExecWB a second to create the window so we wait
    DOEVENTS
    lnHWND = FindWindow(null,lcTitle)
enddo
lnIcon =    ExtractIcon (0,HOME()+"GRAPHICS\ICONS\WRITING\NOTE11.ICO",0)  && I am assuming this icon exists on your system
SetWindowText(lnHWND, "FISCAL STATISTICS REPORT")
SendMessage(lnHWND, WM_SETICON, ICON_SMALL, lnIcon)
*!* SendMessage(lnHWND, WM_SETICON, ICON_BIG, lnIcon)
BringWindowToTop(lnHWND)
ShowWindow(lnHWND, SW_MAXIMIZE)
CLEAR DLLS "FindWindow", "BringWindowToTop", "ShowWindow", "SetWindowText", "ExtractIcon", "SendMessage"
POP KEY All


A special thanks to Mike Lewis and slighthaze for the extra code.
Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close