Using Win32 functions in Visual FoxPro Image Gallery
Window Class
..msdn
GetClassInfo
GetClassInfoEx
GetClassLong
GetClassName
GetWindowLong
RegisterClassEx
SetWindowLong
UnregisterClass
Code examples:
Adding user-defined items to the Control Menu of VFP form (requires VFP9)
Browsing Windows Known Folders (Special Folders)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Creating irregularly shaped FoxPro form using transparency color key
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Detecting changes in connections to removable drives (VFP9)
Displaying dimmed window behind VFP top-level form
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
Displaying icons in the system tray (VFP9)
Displaying the associated icons and descriptions for files and folders
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
Extended MessageBox Class
How to block the PrintScreen key
How to disable the Windows Clipboard (VFP9)
How to hot-track menu item selection in top-level form (requires VFP9)
How to make a VFP form fading out when released (GDI version)
How to make a VFP form fading out when released (GDI+ version)
How to view icons stored in executable files (Icon Viewer) - II
Locking the workstation
Placing a button on the VFP form as a new child window
Retrieving information about the main VFP window
Semi-transparent Form
Setting properties of the window: caption and user-defined value
Switching between keyboard layouts
System Image List Viewer
Transparent Menu Class (requires VFP9)
Using Common Controls: the Header Control
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Using Month Calendar Control (VFP9, Comctl32.dll)
Using WM_COPYDATA for interprocess communication (VFP9)
Windows Shell Icons displayed and exported to ICO files (Vista)
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
This minimalistic looking About form is created by calling the DwmExtendFrameIntoClientArea, and subsequent processing of the WM_NCCALCSIZE and WM_NCHITTEST windows messages.



See also:
  • How to draw a custom Window Caption on FoxPro form
  • Semi-transparent Form
  •  
    LOCAL oForm As TestForm
    oForm = CREATEOBJECT("AboutForm")
    oForm.Visible=.T.
    READ EVENTS
    * end of main
     
    DEFINE CLASS AboutForm As Form
     
    #DEFINE GWL_WNDPROC -4
    #DEFINE GW_CHILD 5
     
    #DEFINE WM_NCHITTEST 0x0084
    #DEFINE WM_NCCALCSIZE 0x0083
     
    #DEFINE HTCLIENT 1
    #DEFINE HTCAPTION 2
     
        Autocenter=.T.
        AlwaysOnTop=.T.
        ShowWindow=2
        Width=500
        Height=200
        Backcolor=RGB(230,230,255)
     
        hWindow=0
        hOrigProc=0
        hClientWindow=0
     
        ADD OBJECT Image1 As Image WITH;
        Left=360, Top=8, Picture="foxpro_transp.png";
     
        ADD OBJECT LabelAbout As Label WITH;
        Left=10, Top=5, Autosize=.T.,;
        Caption=" About Microsoft Visual FoxPro",;
        FontName="Impact", FontSize=20,;
        Backstyle=0, ForeColor=RGB(0,0,96)
     
        ADD OBJECT LabelCopyright As Label WITH;
        Left=20, Top=60, Width=500, Height=200,;
        Caption="Microsoft Visual FoxPro 9.0 SP2"+CHR(13)+;
            "Copyright © 1988-2006 Microsoft Corp."+CHR(13)+;
            "All rights reserved.",;
        FontName="Segoe UI", FontSize=13,;
        Backstyle=0, ForeColor=RGB(0,0,0)
     
        ADD OBJECT LabelInfo As Label WITH;
        Left=20, Top=150, Width=300, Height=200, WordWrap=.T.,;
        Caption="Visual FoxPro is a data-centric object-oriented " +;
            "and procedural programming language produced by Microsoft. " +;
            "It is derived from FoxPro (originally known as FoxBASE) " +;
            "which was developed by Fox Software beginning in 1984.",;
        FontName="Arial Narrow", FontSize=9,;
        Backstyle=0, ForeColor=RGB(0,0,0)
     
        ADD OBJECT cmdClose As CommandButton WITH;
        Left=405, Top=195, Width=80, Height=27,;
        Caption="Close", Default=.T.
     
    PROCEDURE Init
        IF VAL(OS(3)) < 6  && Vista and up
            RETURN .F.
        ENDIF
        THIS.declare
     
    PROCEDURE Destroy
        CLEAR EVENTS
     
    PROCEDURE KeyPress
    LPARAMETERS nKeyCode, nShiftAltCtrl
        IF nKeyCode = 27
            THIS.Release
        ENDIF
     
    PROCEDURE Activate
        WITH THIS
            IF .hWindow = 0
                IF .ShowWindow = 2
                    .hClientWindow = GetWindow(.HWnd, GW_CHILD)
                ENDIF
                .ExtendFrame
                .hWindow = .HWnd
                .Width = .Width + 1
                .Width = .Width - 1
            ENDIF
        ENDWITH
     
    PROCEDURE cmdClose.Click
        ThisForm.Release
     
    PROCEDURE hWindow_ASSIGN( nHWnd As Number )
        WITH THIS
            .hWindow = m.nHWnd
     
            * saving the address of the original
            * window procedure
            .hOrigProc = GetWindowLong(.hWindow, GWL_WNDPROC)
     
            IF VERSION(5) >= 900  && VFP9+
            * the following windows messages will be trapped
            * for the specified window handles
     
                = BINDEVENT( .hWindow, WM_NCCALCSIZE,;
                    THIS, "WindowProc" )
     
                * note the difference between handling 
                * the top-level forms and the child forms
                = BINDEVENT( IIF(.ShowWindow=2,;
                    .hClientWindow, .hWindow),;
                    WM_NCHITTEST, THIS, "WindowProc" )
            ENDIF
        ENDWITH
     
    PROCEDURE ExtendFrame
    * Extends the window frame behind the client area
        LOCAL cMargins
     
        * left, right, top, bottom
        cMargins =;
            num2dword(3) +;
            num2dword(3) +;
            num2dword(3) +;
            num2dword(3)
     
        nResult = DwmExtendFrameIntoClientArea(;
            THIS.HWnd, @cMargins)
     
    PROCEDURE WindowProc(hWindow as Integer,;
        nMsgID as Integer, wParam as Integer, lParam as Integer)
    * requires VFP9, otherwise ignored
     
        LOCAL nReturn
        nReturn=0
     
        DO CASE
     
        CASE nMsgID = WM_NCHITTEST
        * Sent to a window in order to determine 
        * what part of the window corresponds 
        * to a particular screen coordinate.
            RETURN THIS.ProcessHitTest(lParam)
     
        CASE nMsgID = WM_NCCALCSIZE AND wParam > 0
        * Sent when the size and position of the client area 
        * must be calculated.
     
        * If wParam is TRUE and an application returns zero, 
        * the old client area is preserved and is aligned 
        * with the upper-left corner of the new client area.
            RETURN 0
     
        OTHERWISE
        * pass control to the original window procedure
            nReturn = CallWindowProc(THIS.hOrigProc, THIS.hWindow,;
                m.nMsgID, m.wParam, m.lParam)
        ENDCASE
    RETURN nReturn
     
    PROCEDURE ProcessHitTest(lParam as Integer)
        LOCAL nXCoord, nYCoord
        * low-order word: cursor x-coordinate
        nXCoord = BITAND(m.lParam, 0x0000ffff);
            - THIS.Left
        * high-order word: cursor y-coordinate
        nYCoord = BITRSHIFT(BITAND(m.lParam, 0xffff0000), 16);
            - THIS.Top
    * top 30 pixels assumed to be a title bar - can drag by it
    * the rest is the client area of the form
    RETURN IIF(nYCoord < 30, HTCAPTION, HTCLIENT)
     
    PROCEDURE declare
        DECLARE INTEGER DwmExtendFrameIntoClientArea IN Dwmapi;
            INTEGER hWindow, STRING @pMarInset
     
        DECLARE INTEGER GetWindowLong IN user32;
            INTEGER hWindow, INTEGER nIndex
     
        DECLARE INTEGER CallWindowProc IN user32;
            INTEGER lpPrevWndFunc, INTEGER hWindow, LONG Msg,;
            INTEGER wParam, INTEGER lParam
     
        DECLARE INTEGER GetWindow IN user32;
            INTEGER hWindow, INTEGER wFlag
     
    ENDDEFINE
     
    FUNCTION num2dword(lnValue)
    #DEFINE m0 0x0000100
    #DEFINE m1 0x0010000
    #DEFINE m2 0x1000000
        IF lnValue < 0
            lnValue = 0x100000000 + lnValue
        ENDIF
        LOCAL b0, b1, b2, b3
        b3 = Int(lnValue/m2)
        b2 = Int((lnValue - b3*m2)/m1)
        b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
        b0 = Mod(lnValue, m0)
    RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
     

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    5045 bytes  
    Created: 2011-01-12 19:52:38  
    Modified: 2011-01-13 18:30:08  
    Visits in 7 days: 87  
    Listed functions:
    CallWindowProc
    DwmExtendFrameIntoClientArea
    GetWindow
    GetWindowLong
    Printer friendly API declarations
    My comment:
    Download transparent PNG file to be used with this code sample.
    Word Index links for this example:
    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 (54.234.180.187)
    1.96 hrs.Function: 'CeOpenDatabase'
    Function group: 'Remote Application Programming (RAPI)'
     Function: 'SQLFetch'
    Function group: 'ODBC API'
    3.8 hrs.Function: 'LsaFreeMemory'
     Function: 'StrFromTimeInterval'
    11.61 hrs.Example: 'Retrieving the name of the primary domain controller (PDC) and join status information (NT/2000/XP)'
     Example: 'Disk in drive A:'
    13.47 hrs.Function: 'GdipScaleMatrix'
     Function: 'CeGetVersionEx'
    Function group: 'Remote Application Programming (RAPI)'
    15.7 hrs.Example: 'Obtaining provider name for a specific type of network'
     Function: 'PathFileExists'
    Function group: 'Shell Lightweight Utility APIs -- Path Functions'
    Google
    Advertise here!