Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
GDI+: converting text strings to images and saving in a graphics file
Minimizing all running applications
Obtaining OS memory performance information
Basic Volume information
How to hot-track menu item selection in top-level form (requires VFP9)
Pocket PC: System Registry Viewer
Setting and retrieving the double-click time for the mouse
Building a tree of subdirectories for a given path using FindFile functions
Closing Windows
GDI+: how to make VFP controls visually shake and shudder
How to check whether the system is 32-bit or 64-bit
Using Video Capture: enumerating installed capture drivers
Drawing a window caption using the DrawCaption routine
Running a regular FoxPro form while main VFP window is minimized
Setting the Window Region for a form
Using LoadLibrary
Using named pipes for interprocess communication
Accessing a CD device (cdaudio) with Multimedia Command Strings
Retrieving the System Time adjustment
Saving HKEY_LOCAL_MACHINE\\Software\\ODBC Registry Entries to an XML file
Creating two-byte hashes for a list of URLs
Pocket PC: creating new database in the Object Store and copying Contacts Database records into it
Simple MAPI: how to pick an email recipient from Outlook Express address book
Converting strings between ANSI and OEM
Yet another modal dialog: now HTML-based

User rating: 9/10 (2 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
The ShowHTMLDialog displays modal dialog that is functionally similar to the dialogs created by MessageBox and TaskDialog functions.


A very attractive feature of this dialog is its HTML-based content. The window title, and whole client part of the dialog are defined strictly in HTML terms. This is like a miniature IE window.
 
#DEFINE URL_MK_LEGACY 0
#DEFINE URL_MK_UNIFORM 1
DO declare
 
LOCAL cDlgDefinitionFile, cUrl, nUrlMoniker, cFeatures,;
    cArguments, cOutput, cDlgReturn
 
* the dialog definition is stored in local HTML file
cDlgDefinitionFile=LOWER(FULLPATH("dlgdefinition.html"))
IF NOT FILE(m.cDlgDefinitionFile)
    DO CreateDlgDefinitionFile WITH m.cDlgDefinitionFile
ENDIF
 
* create URL Moniker from the Url
cUrl=ToUnicode("file://" + m.cDlgDefinitionFile)
nUrlMoniker=0
IF CreateURLMonikerEx(0, cUrl, @nUrlMoniker, URL_MK_UNIFORM) <> 0
    RETURN  && failed
ENDIF
 
* ShowHTMLDialog input parameteres
cFeatures=ToUnicode("dialogWidth:340px;dialogHeight:130px;center:1;")
cArguments=ToUnicode("")
cOutput=REPLICATE(CHR(0), 256)
cDlgReturn=""
 
IF ShowHTMLDialog(_screen.HWnd, m.nUrlMoniker,;
        m.cArguments, m.cFeatures, @cOutput) = 0
    nAddr=buf2dword(SUBSTR(cOutput,9,4))
    IF m.nAddr <> 0
        cDlgReturn=FromUnicode( Mem2Str(nAddr) )
    ENDIF
ENDIF
? cDlgReturn
* end of main
 
PROCEDURE CreateDlgDefinitionFile(cFilename)
    LOCAL cHtml
 
* the HTML code is converted to base64 only because
* it is meant to be properly displayed on this web page;
* otherwise no need to do that
TEXT TO cHtml NOSHOW
PHRpdGxlPlVzaW5nIEhUTUwgRGlhbG9ncyBpbiBWaXN1
YWwgRm94UHJvPC90aXRsZT4NCjxzdHlsZT4NCi5EbGdC
b2R5IHsNCgliYWNrZ3JvdW5kLWNvbG9yOiAjZjVmNWQw
OyANCn0NCi5EbGdNc2cgew0KCWZvbnQtZmFtaWx5OiBT
ZWdvZSBVSSwgQXJpYWw7IA0KCWZvbnQtc2l6ZTogMTFw
dDsgDQoJY29sb3I6ICM2MDMwMzA7IA0KCXBvc2l0aW9u
OiBhYnNvbHV0ZTt0b3A6IDE1cHg7bGVmdDoyMHB4Ow0K
fQ0KLkRsZ0J1dHRvbnMgew0KICAgIHBvc2l0aW9uOiBh
YnNvbHV0ZTt0b3A6IDgwcHg7bGVmdDogMTYwcHg7DQp9
DQouRGxnQnRuIHsgDQoJZm9udC1mYW1pbHk6IFNlZ29l
IFVJLCBBcmlhbDsgDQoJZm9udC1zaXplOiAxMnB0OyAN
Cglmb250LXdlaWdodDogNzAwOw0KCWNvbG9yOiAjNzA0
MDQwOyANCgliYWNrZ3JvdW5kLWNvbG9yOiAjZDFhNWE1
OyANCglib3JkZXI6IDFweCBzb2xpZCAjOTA3MDYwOw0K
CXdpZHRoOiA3MHB4Ow0KCWhlaWdodDogMjdweDsNCn0N
Cjwvc3R5bGU+DQo8Ym9keSBjbGFzcz0iRGxnQm9keSI+
DQo8ZGl2IGNsYXNzPSJEbGdNc2ciPjxTdHJvbmc+U2hv
d0hUTUxEaWFsb2c8L1N0cm9uZz4gDQpGdW5jdGlvbiBj
cmVhdGVzIGEgbW9kYWwgZGlhbG9nIGJveCB0aGF0IGRp
c3BsYXlzIEhUTUwuPC9kaXY+DQo8ZGl2IGNsYXNzPSJE
bGdCdXR0b25zIj4NCjxpbnB1dCBjbGFzcz0iRGxnQnRu
IiBpZD0iYnRuT2siIHR5cGU9IlN1Ym1pdCIgdmFsdWU9
Ik9LIj4gDQo8aW5wdXQgY2xhc3M9IkRsZ0J0biIgaWQ9
ImJ0bkNhbmNlbCIgdHlwZT0iU3VibWl0IiB2YWx1ZT0i
Q2FuY2VsIj4gDQo8L2Rpdj4NCjxzY3JpcHQgZm9yPSJi
dG5PayIgZXZlbnQ9Im9uY2xpY2siPg0KCXdpbmRvdy5y
ZXR1cm5WYWx1ZT0iQWdyZWUiOw0KCXdpbmRvdy5jbG9z
ZSgpOw0KPC9zY3JpcHQ+DQo8c2NyaXB0IGZvcj0iYnRu
Q2FuY2VsIiBldmVudD0ib25jbGljayI+DQoJd2luZG93
LnJldHVyblZhbHVlPSJEaXNhZ3JlZSI7DQoJd2luZG93
LmNsb3NlKCk7DQo8L3NjcmlwdD4NCjwvYm9keT4=
ENDTEXT
 
    * converting back from base64 to normal text
    cHtml=STRCONV(m.cHtml,14)
 
    * saving to HTML file
    TRY
        SET SAFETY OFF
        STRTOFILE(m.cHtml, m.cFilename)
    CATCH
    FINALLY
        SET SAFETY ON
    ENDTRY
 
PROCEDURE declare
    DECLARE INTEGER CreateURLMonikerEx IN urlmon;
        INTEGER pMkCtx, STRING szURL,;
        INTEGER @ppmk, LONG dwFlags
 
    DECLARE INTEGER ShowHTMLDialog IN mshtml;
        INTEGER hwndParent, INTEGER pMk, STRING pvarArgIn,;
        STRING pchOptions, STRING @pvarArgOut
 
    DECLARE RtlMoveMemory IN kernel32 As MemToStr;
        STRING @, INTEGER, INTEGER
 
FUNCTION buf2dword(cBuffer)
RETURN Asc(SUBSTR(cBuffer, 1,1)) + ;
    BitLShift(Asc(SUBSTR(cBuffer, 2,1)),  8) +;
    BitLShift(Asc(SUBSTR(cBuffer, 3,1)), 16) +;
    BitLShift(Asc(SUBSTR(cBuffer, 4,1)), 24)
 
FUNCTION ToUnicode(cStr)
RETURN STRCONV(cStr+CHR(0), 5)
 
FUNCTION FromUnicode(cStr)
RETURN STRTRAN(STRCONV(cStr, 6), CHR(0), "")
 
FUNCTION Mem2Str(nBaseAddr As Number)
#DEFINE BUFFER_SIZE 16
#DEFINE EMPTY_BUFFER REPLICATE(CHR(0), BUFFER_SIZE)
* reads Unicode string from specified memory address
 
    IF nBaseAddr = 0
        RETURN ""
    ENDIF
 
    LOCAL nCurAddr, cResult, cBuffer, nPos
    nCurAddr=nBaseAddr
    cResult=""
 
    DO WHILE .T.
        cBuffer = EMPTY_BUFFER
        = MemToStr(@cBuffer, nCurAddr, BUFFER_SIZE)
        nPos = AT(CHR(0)+CHR(0), cBuffer)
 
        IF nPos > 0
            cResult = cResult + SUBSTR(cBuffer, 1, nPos)
            RETURN cResult
        ELSE
            cResult = cResult + cBuffer
            nCurAddr = m.nCurAddr + BUFFER_SIZE
        ENDIF
    ENDDO
 

User rating: 9/10 (2 votes)
Rate this code sample:
  • ~
4147 bytes  
Created: 2009-12-09 16:16:35  
Modified: 2009-12-10 13:26:39  
Visits in 7 days: 71  
Listed functions:
CreateURLMonikerEx
ShowHTMLDialog
Printer friendly API declarations
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (23.22.212.158)
4 sec.Example: 'Drawing cursors for the classes defined by the system (preregistered): BUTTON, EDIT, LISTBOX etc.'
35 min.Example: 'Building a tree of subdirectories for a given path using FindFile functions'
Language: 'C#'
2.54 hrs.Function: 'EnumPorts'
3.35 hrs.Function: 'GdipGetImageWidth'
5.61 hrs.Function: 'SQLTables'
Function group: 'ODBC API'
10.24 hrs.Example: 'Extended MessageBox Class'
 Function: 'BeginUpdateResource'
 Example: 'Using FrameRgn for displaying system colors'
16.61 hrs.Example: 'How to write and read Window Properties for the specified window'
 Example: 'Retrieving a universal form for the drive-based path for a network resource'
Google
Advertise here!