Author Topic: Windows API Headers III v.1.06  (Read 17995 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Windows API Headers III v.1.06
« on: July 14, 2014, 08:34:27 PM »
 
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.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Windows API Headers III v.1.06
« Reply #1 on: July 14, 2014, 08:56:47 PM »
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.


Offline Holger Taschenberger

  • Newbie
  • *
  • Posts: 4
  • User-Rate: +0/-0
Re: Windows API Headers III v.1.06
« Reply #2 on: July 15, 2014, 10:57:39 AM »
Dear José,

in some of your CWindows examples (see for example <http://www.powerbasic.com/support/pbforums/showthread.php?p=458304#post458304> post #4)
your Winmain starts with:

' // Set process DPI aware
   If AfxGetWindowsVersion => 6 Then SetProcessDPIAware

this is probably not what you wanted to do because it renders the exe incompatible with Windows XP
(because of static linking to 'SetProcessDPIAware' which does not exist on that OS)

your headers have a function 'AfxSetProcessDPIAware' which uses dynamic linking and could be a better choice here:
' // Set process DPI aware
   If AfxGetWindowsVersion => 6 Then AfxSetProcessDPIAware

Thanks for all your hard work,
   Holger

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: Windows API Headers III v.1.06
« Reply #3 on: July 22, 2014, 02:22:47 PM »
José,
  Did I miss it or is there no Afx MessageBox wrapper specifically for use with PBCC ?


James

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Windows API Headers III v.1.06
« Reply #4 on: July 22, 2014, 02:46:34 PM »
There is not an AfxMessageBox wrapper, neither for PBCC nor for PBWIN. You can use the MessageBox API function.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Windows API Headers III v.1.06
« Reply #5 on: July 22, 2014, 04:10:01 PM »
Depends on how you intend to use it. If you don't have a window and a message pump, GetActiveWindow will always return 0.
« Last Edit: July 22, 2014, 04:26:34 PM by José Roca »

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: Windows API Headers III v.1.06
« Reply #6 on: July 22, 2014, 04:16:10 PM »
Depends on how you intende to use it. If you don't have a window and a message pump, GetActiveWindow will always return 0.

I removed it as it did not work.

James

Offline Holger Taschenberger

  • Newbie
  • *
  • Posts: 4
  • User-Rate: +0/-0
Re: Windows API Headers III v.1.06
« Reply #7 on: July 24, 2014, 04:12:01 PM »
Dear José,

in "FreeImage.inc" of the Windows API Headers III v.1.06 some Unicode C string pointers are currently declared using void pointers ("As Dword"), for example:

DECLARE FUNCTION FreeImage_LoadU IMPORT "FreeImage.dll" ALIAS "_FreeImage_LoadU@12" ( _
   BYVAL fif AS LONG _
 , BYVAL filename AS DWORD _ ' const wchar_t *filename
 , OPTIONAL BYVAL flags AS LONG _
 ) AS DWORD

this works of course. But I think it would be closer to the original C-header and possibly also more convenient in PB to use  "ByRef WStringZ" instead, for example:

Declare Function FreeImage_LoadU Import "FreeImage.dll" Alias "_FreeImage_LoadU@12" ( _
   ByVal fif As Long _
 , ByRef filename As WStringZ _' const wchar_t *filename
 , Optional ByVal flags As Long _
 ) As Dword


Don't you think?

Kind regards,
   Holger

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Windows API Headers III v.1.06
« Reply #8 on: July 24, 2014, 06:48:45 PM »
Linux libraries such this one and SQLite use UTF-8 encoding for Unicode.

Offline Petr Schreiber

  • Full Member
  • ***
  • Posts: 183
  • User-Rate: +14/-4
Re: Windows API Headers III v.1.06
« Reply #9 on: July 24, 2014, 10:02:53 PM »
Just noticed the update José,

very much appreciated, thank you!


Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Offline Holger Taschenberger

  • Newbie
  • *
  • Posts: 4
  • User-Rate: +0/-0
Re: Windows API Headers III v.1.06
« Reply #10 on: August 12, 2014, 06:32:39 PM »
xlcall.inc defines the following equates without a type-specifier:

'/*
'** Function number bits
'*/

%xlCommand    = &H8000
%xlSpecial    = &H4000
%xlIntl       = &H2000
%xlPrompt     = &H1000

This can potentially create trouble because some of these values are ORed with other equates defined elsewhere. For example, to show an alert prompt you would typically use:
Excel4(%xlcAlert, ...)
with %xlcAlert defined as
%xlcAlert = (118 Or %xlCommand).

This will not work correctly with the current include file. It will however work correctly when %xlCommand is defined as %xlCommand = &H8000&.

With kind regards,
   Holger

Offline Holger Taschenberger

  • Newbie
  • *
  • Posts: 4
  • User-Rate: +0/-0
Re: Windows API Headers III v.1.06
« Reply #11 on: August 15, 2014, 05:43:19 PM »
xlcall.inc defines the following structure:

Type FP Dword
   rows As Integer
   columns As Integer
   Array(0) As Double
End Type

This is not correct and leads to misalignment of the 2nd structure member (columns) (because the C compiler uses natural alignment). It cannot work correctly.
I belief the correct definition is:
 
Type FP Qword Fill
   rows As Integer
   columns As Integer
   Array(0) As Double
End Type

This works fine.
Kind regards,
   Holger
« Last Edit: August 15, 2014, 06:29:41 PM by Holger Taschenberger »

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Windows API Headers III v.1.06
« Reply #12 on: August 15, 2014, 10:47:47 PM »
If it works for you, I will change it. I never have been able to test it because I don't have Excel instaled.
« Last Edit: December 05, 2014, 12:49:19 AM by José Roca »

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: Windows API Headers III v.1.06
« Reply #13 on: November 01, 2014, 05:52:41 PM »
José,
  Did I miss finding wrapper functions for File IO ??

James

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Windows API Headers III v.1.06
« Reply #14 on: November 01, 2014, 07:30:01 PM »
No. I would like to write a class, to provide exception handling. We'll see, as Bob said.