Announcement

Collapse
No announcement yet.

Windows API Headers III v.1.06

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • José Roca
    replied
    Note to PBCC only users

    My headers provide a framework that can be used both by PBWIN and PBCC users to build GUI and Graphic applications.

    The following example, compilable with PBCC 6+ embeds an instance of the WebBrowser control. #CONSOLE OFF has been used to disable the console.

    Code:
    #COMPILE EXE
    #CONSOLE OFF
    #DIM ALL
    %UNICODE = 1
    
    ' // Include files for external files
    %USEWEBBROWSER = 1            ' // Use the WebBrowser control
    #INCLUDE ONCE "CWindow.inc"   ' // CWindow class
    
    ' // Identifier
    %IDC_WEBBROWSER = 101
    
    ' ########################################################################################
    ' Main
    ' ########################################################################################
    FUNCTION WinMain (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, BYVAL lpszCmdLine AS WSTRINGZ PTR, BYVAL nCmdShow AS LONG) AS LONG
    
       ' // Set process DPI aware
       IF AfxGetWindowsVersion => 6 THEN SetProcessDPIAware
    
       ' // Create an instance of the class
       LOCAL pWindow AS IWindow
       pWindow = CLASS "CWindow"
       IF ISNOTHING(pWindow) THEN EXIT FUNCTION
    
       ' // Create the main window
       pWindow.CreateWindow(%NULL, "AddWebBrowser Template", 0, 0, 0, 0, 0, 0, CODEPTR(WindowProc))
       ' // Set the client siz
       pWindow.SetClientSize 600, 350
       ' // Center the window
       pWindow.CenterWindow
    
       ' // Add a WebBrowser control
       LOCAL hCtl AS DWORD
       LOCAL bstrURL AS WSTRING
    
       ' // You can pass a URL
       bstrURL = "http://www.jose.it-berater.org/smfforum/index.php"
    
       ' // or a path to an Active document file (Excel, Word or PDF)
    '   bstrURL = EXE.Path$ & "Test.xls"              ' <-- change me!
    '   bstrURL = EXE.Path$ & "JetSQL.doc"            ' <-- change me!
    '   bstrURL = EXE.Path$ & "COMCollections.pdf"    ' <-- change me!
    
       ' // or a fragment of HTML code (remember to always start with "MSHTML:")
    '   bstrURL = "MSHTML:<HTML><BODY>This is a line of text</BODY></HTML>"
    
       ' // or a web page (remember to always start with "MSHTML:")
    '   LOCAL s AS WSTRING
    '   LOCAL bstrName AS WSTRING
    
    '   S =  "MSHTML:<?xml version=""1.0""?>"
    '   s += "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & $CRLF
    '   s += "<html xmlns=""http://www.w3.org/1999/xhtml"">" & $CRLF
    '   s += "<head>" & $CRLF
    '   s += "<title>Image Test</title>" & $CRLF
    '   s += "</head>" & $CRLF
    '   s += "<body scroll=" & $DQ & "auto" & $DQ & " style=" & $DQ & "MARGIN: 0px 0px 0px 0px" & $DQ & " >" & $CRLF
    '   bstrName = EXE.Path$ & "Ciutat_de_les_Arts_i_de_les_Ciencies_02.jpg"
    '   s += "<img src=" & $DQ & bstrName & $DQ & " alt=" & $DQ & bstrName & $DQ & " title=" & $DQ & bstrName & $DQ & " "
    '   s += "/>" & $CRLF
    '   s += "</body>" & $CRLF
    '   s += "</html>" & $CRLF
    '   bstrURL = s
    
       ' // Create the control
       hCtl = pWindow.AddWebBrowserControl(pWindow.hwnd, %IDC_WEBBROWSER, bstrURL, NOTHING, 0, 0, pWindow.ClientWidth, pWindow.ClientHeight)
    
    
    
       ' // Default message pump (you can replace it with your own)
       pWindow.DoEvents(nCmdShow)
    
    END FUNCTION
    ' ########################################################################################
    
    ' ========================================================================================
    ' Main callback function.
    ' ========================================================================================
    FUNCTION WindowProc (BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    
       STATIC hInstance AS DWORD        ' // Instance handle
       STATIC lpc AS CREATESTRUCT PTR   ' // Pointer to the creation parameters
       STATIC pWindow AS IWindow        ' // Reference to the IWindow interface
    
       SELECT CASE uMsg
    
          CASE %WM_CREATE
             ' // Pointer to the creation parameters
             lpc = lParam
             ' // Instance handle
             hInstance = @lpc.hInstance
             ' // Get a reference to the IWindow interface from the CREATESTRUCT structure
             pWindow = CWindow_GetObjectFromCreateStruct(lParam)
             EXIT FUNCTION
    
          CASE %WM_SYSCOMMAND
             ' // Capture this message and send a WM_CLOSE message
             ' // Note: Needed with some OCXs, that otherwise remain in memory
             IF (wParam AND &HFFF0) = %SC_CLOSE THEN
                SendMessage hwnd, %WM_CLOSE, 0, 0
                EXIT FUNCTION
             END IF
    
          CASE %WM_COMMAND
             SELECT CASE LO(WORD, wParam)
                CASE %IDCANCEL
                   ' // If the Escape key has been pressed...
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                      EXIT FUNCTION
                   END IF
             END SELECT
    
          CASE %WM_SIZE
             IF wParam <> %SIZE_MINIMIZED THEN
                ' // Resize the control
                pWindow.MoveWindow GetDlgItem(hwnd, %IDC_WEBBROWSER), 0, 0, pWindow.ClientWidth, pWindow.ClientHeight, %TRUE
             END IF
    
          CASE %WM_DESTROY
             ' // End the application
             PostQuitMessage 0
             EXIT FUNCTION
    
       END SELECT
    
       ' // Pass unprocessed messages to Windows
       FUNCTION = DefWindowProc(hwnd, uMsg, wParam, lParam)
    
    END FUNCTION
    ' ========================================================================================

    Leave a comment:


  • José Roca
    replied
    Help file for the main classes and wrapper functions available in the version 3.1.06 of the Windows API Headers for PBWin 10+ and PBCC 6+.
    Attached Files

    Leave a comment:


  • José Roca
    replied
    What is new in version 1.06

    - IDispatchEx.inc: Inherits from IDispatch, not IUnknown. Thanks to Dominc Mitchell for reporting it.

    - Typo in UrlEscapeW. Thanks to Holger Taschenberger.

    - Added ANSI version to AfxSetWindow function. Thanks to Paul Squires.

    - Modified alignment of substructures in XLOPER12 from BYTE to DWORD. Thanks to E. Dingsor.

    - Typo in TreeView_GetISearchStringW.

    - Added BYVAL to some functions that call CoTaskMemFree to avoid leaks if using the constant %USEBDECL (for compatibility with the PowerBASIC declares).

    - Added the SYSTEM_POWER_INFORMATION structure to WinNT.inc (accidentally ommited from the C++ WinNT.h header).

    - Modified the GetHostAddr function.

    - Modified GdipAnimCtx by request of Gary Barnes.

    - Updated SQLite to version 3.8.5.

    - Updated FreeImage.inc to versión 3.16.

    Leave a comment:


  • José Roca
    started a topic Windows API Headers III v.1.06

    Windows API Headers III v.1.06

    This project is an effort to translate the C headers of the Microsoft Platform SDK for Windows to PowerBASIC™. This version has been updated using the SDK for Windows 7.1.

    These headers are freeware, not public domain. This means that you can use them for your own purposes, even in commercial applications, without paying a fee, but not to make derivative works from, sell or redistribute without permission. Also you must assume the entire risk of using them. Downloading the software indicates that you accept these terms.

    Because of the use of new data types only available in PNWIN 10.0+ and PBCC 6.0+ and other features, they can only be used with the new compilers.

    You must also be aware that these headers are not extensions to the ones provided with the compiler, but a full replacement. Therefore, you must not mix them with the PowerBASIC include files in any way, neither directly (via #INCLUDE), nor indirectly (via the include path in the IDE).

    Unzip the attached file to a folder of your choice and replace the PB Include path in the PB Ide or the editor that you are using to that folder instead of C:\PBWin10\WinApi.

    The wrapper functions for the Common Controls have been removed from CommCtrl.inc and placed in the following individual files. Therefore, the use of constants such %NOTOOLBAR, %NOUPDOWN, etc., is no longer needed. Just #INCLUDE the wanted files in your application.

    AnimateCtrl.inc (Animation control)
    ButtonCtrl.inc (Button control)
    ComboBoxCtrl.inc (ComboBox control)
    ComboBoxExCtrl.inc (ComboBoxEx control)
    DateTimeCtrl.inc (Date Time control)
    EditCtrl.inc (Edit control)
    HeaderCtrl.inc (Header control)
    HotKeyCtrl.inc (Hot Key control)
    IPAddressCtrl.inc (IP Address control)
    ListBoxCtrl.inc (ListBox control)
    ListViewCtrl.inc (ListView control)
    MonthCalCtrl.inc (Month Calendar control)
    PagerCtrl.inc (Pager control)
    ProgressBarCtrl.inc (Progress Bar control)
    RebarCtrl.inc (Rebar control)
    RichEditCtrl.inc (Rich Edit control)
    ScrollBarCtrl.inc (Scroll Bar control)
    StaticCtrl.inc (Static control)
    StatusbarCtrl.inc (Status Bar control)
    SysLinkCtrl.inc (SysLink control)
    TabCtrl.inc (Tab control)
    TaskDialogCtrl.inc (Task Dialog control)
    ToolbarCtrl.inc (Toolbar control)
    TrackbarCtrl.inc (Track Bar control)
    TreeViewCtrl.inc (TreeView control)
    UpDownCtrl.inc (UpDown control)

    There are 1,199 files using 78,456,253 bytes.
    Attached Files
    Last edited by José Roca; 23 Aug 2015, 11:00 AM.
Working...
X