Hi Pritpal,
--- wapi_commctrl.c (now)
#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
#include "hbwapi.h"
---

Please don't explicitly #include <windows.h>, it's not
necessary, as it's automatically pulled in by hbapi.h
by #defining HB_OS_WIN_USED.

This is the clean way (notice that commctrl.h is moved
after Harbour headers, and windows.h got deleted):
--- wapi_commctrl.c (corrected)
#include "hbapi.h"
#include "hbwapi.h"

#include <commctrl.h>
---

--- hbwapi.h (now)
   #define wapi_ret_HANDLE( n )     ( hb_retnint( ( HB_PTRDIFF ) n ) )
   #define wapi_ret_HRESULT( hr )   ( hb_retnint( ( HB_PTRDIFF ) hr ) )
   #define wapi_ret_COLORREF( n )   ( hb_retnint( ( HB_PTRDIFF ) n ) )
---

This isn't ideal, we should use hb_retptr() otherwise the
caller can easily mess up the values and cause various
security holes, GPFs and other random behaviour.

I'd suggest to change this right from the start, before
introducing numeric dependent code in hbwin itself, too.
With these pointers, .prg level code should only do equality
check, call hb_IsPointer() and Empty() on these values.
Everything else is to be avoided.

--- hbwapi.h (corrected)
   #define wapi_ret_HANDLE( n )     ( hb_retptr( ( HB_PTRDIFF ) n ) )
   #define wapi_ret_HRESULT( hr )   ( hb_retptr( ( HB_PTRDIFF ) hr ) )
   #define wapi_ret_COLORREF( n )   ( hb_retptr( ( HB_PTRDIFF ) n ) )
---

Even more ideally we should switch to hb_retptrGC() to
avoid resource leaks due to .prg level programming errors,
but this can be done later.

Brgds,
Viktor

On Sat, Feb 14, 2009 at 10:46 PM, <vouch...@users.sourceforge.net> wrote:

> Revision: 10273
>
> http://harbour-project.svn.sourceforge.net/harbour-project/?rev=10273&view=rev
> Author:   vouchcac
> Date:     2009-02-14 21:46:19 +0000 (Sat, 14 Feb 2009)
>
> Log Message:
> -----------
> 2009-02-14 13:32 UTC-0800 Pritpal Bedi (prit...@vouchcac.com)
>  + harbour/contrib/hbwin/wapi_commctrl.c
>    + Added WAPI_Image*() functions.
>
>  * harbour/contrib/hbwin/hbwapi.h
>    + Added more _par and _ret defines.
>
>    ; The idea is to encapsulate Harbour API for WINAPI
>      parameters and return values. Now wapi_commctrl.c
>      looks very clean and easy to understand code.
>      Also I have contained all those functions which are
>      either not required on normal programming level
>      OR I could not convert, with #if 0 / #endif blocks.
>      But the header definitions are pulled from MSDN and
>      have been kept alongwith. This ensures that whenever
>      someone will try to implement them, all info will be
>      handy.
>
>    ; Please approve the above implementation so that I
>      include these files in the build batches.
>
> Modified Paths:
> --------------
>    trunk/harbour/ChangeLog
>    trunk/harbour/contrib/hbwin/hbwapi.h
>
> Added Paths:
> -----------
>    trunk/harbour/contrib/hbwin/wapi_commctrl.c
>
>
> This was sent by the SourceForge.net collaborative development platform,
> the world's largest Open Source development site.
> _______________________________________________
> Harbour mailing list
> Harbour@harbour-project.org
> http://lists.harbour-project.org/mailman/listinfo/harbour
>
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to