• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

Using Macros Verses Alias Regarding Dealing With 'A' And 'W' Unicode Issue

Started by Frederick J. Harris, May 10, 2011, 07:32:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frederick J. Harris

Hi Jose!

   I have a general question about includes.  While rooting around in your includes and the PowerBASIC includes for the
new compilers, I noted you used macros to redefine CreateWindowEx As either CreateWindowExW or CreateWindowExA, depending
of course, to the definition or lack thereof of %UNICODE....
 

DECLARE FUNCTION CreateWindowExA IMPORT "USER32.DLL" ALIAS "CreateWindowExA" ( _
   BYVAL dwExStyle AS DWORD _                           ' __in DWORD dwExStyle
, BYREF lpClassName AS ASCIIZ _                        ' __in_opt LPCSTR lpClassName
, BYREF lpWindowName AS ASCIIZ _                       ' __in_opt LPCSTR lpWindowName
, BYVAL dwStyle AS DWORD _                             ' __in DWORD dwStyle
, BYVAL X AS LONG _                                    ' __in int X
, BYVAL Y AS LONG _                                    ' __in int Y
, BYVAL nWidth AS LONG _                               ' __in int nWidth
, BYVAL nHeight AS LONG _                              ' __in int nHeight
, OPTIONAL BYVAL hwndParent AS DWORD _                 ' __in_opt HWND hwndParent
, OPTIONAL BYVAL hMenu AS DWORD _                      ' __in_opt HMENU hMenu
, OPTIONAL BYVAL hInstance AS DWORD _                  ' __in_opt HINSTANCE hInstance
, OPTIONAL BYREF lpParam AS ANY _                      ' __in_opt LPVOID lpParam
) AS DWORD                                             ' HWND

DECLARE FUNCTION CreateWindowExW IMPORT "USER32.DLL" ALIAS "CreateWindowExW" ( _
   BYVAL dwExStyle AS DWORD _                           ' __in DWORD dwExStyle
, BYREF lpClassName AS WSTRINGZ _                      ' __in_opt LPCWSTR lpClassName
, BYREF lpWindowName AS WSTRINGZ _                     ' __in_opt LPCWSTR lpWindowName
, BYVAL dwStyle AS DWORD _                             ' __in DWORD dwStyle
, BYVAL X AS LONG _                                    ' __in int X
, BYVAL Y AS LONG _                                    ' __in int Y
, BYVAL nWidth AS LONG _                               ' __in int nWidth
, BYVAL nHeight AS LONG _                              ' __in int nHeight
, OPTIONAL BYVAL hwndParent AS DWORD _                 ' __in_opt HWND hwndParent
, OPTIONAL BYVAL hMenu AS DWORD _                      ' __in_opt HMENU hMenu
, OPTIONAL BYVAL hInstance AS DWORD _                  ' __in_opt HINSTANCE hInstance
, OPTIONAL BYREF lpParam AS ANY _                      ' __in_opt LPVOID lpParam
) AS DWORD                                             ' HWND

#IF %DEF(%UNICODE)
   MACRO CreateWindowEx = CreateWindowExW
#ELSE
   MACRO CreateWindowEx = CreateWindowExA
#ENDIF



In the PowerBASIC declares (below) they used the alias keyword to accomplish what looks to me to be about the same thing,
although it is a somewhat longer and more verbose technique.  I was wondering what the pros and cons of these
two different techniques would be; is one technique better than the other?


DECLARE FUNCTION CreateWindowExA LIB "User32.dll" ALIAS "CreateWindowExA" _
( _
  BYVAL dwExStyle AS DWORD, _
  Byref lpClassName AS ASCIIZ, _
  Byref lpWindowName AS ASCIIZ, _
  BYVAL dwStyle AS DWORD, _
  BYVAL x AS LONG, _
  BYVAL y AS LONG, _
  BYVAL nWidth AS LONG, _
  BYVAL nHeight AS LONG, _
  BYVAL hWndParent AS DWORD, _
  BYVAL hMenu AS DWORD, _
  BYVAL hInstance AS DWORD, _
  Byref lpParam AS ANY _
) AS DWORD

DECLARE FUNCTION CreateWindowExW LIB "User32.dll" ALIAS "CreateWindowExW" _
( _
  BYVAL dwExStyle AS DWORD, _
  Byref lpClassName AS WSTRINGZ, _
  Byref lpWindowName AS WSTRINGZ, _
  BYVAL dwStyle AS DWORD, _
  BYVAL x AS LONG, _
  BYVAL y AS LONG, _
  BYVAL nWidth AS LONG, _
  BYVAL nHeight AS LONG, _
  BYVAL hWndParent AS DWORD, _
  BYVAL hMenu AS DWORD, _
  BYVAL hInstance AS DWORD, _
  lpParam AS ANY _
) AS DWORD

#IF %DEF(%UNICODE)
    DECLARE FUNCTION CreateWindowEx LIB "User32.dll" ALIAS "CreateWindowExW" _
    ( _
      BYVAL dwExStyle AS DWORD, _
      Byref lpClassName AS WSTRINGZ, _
      Byref lpWindowName AS WSTRINGZ, _
      BYVAL dwStyle AS DWORD, _
      BYVAL x AS LONG, _
      BYVAL y AS LONG, _
      BYVAL nWidth AS LONG, _
      BYVAL nHeight AS LONG, _
      BYVAL hWndParent AS DWORD, _
      BYVAL hMenu AS DWORD, _
      BYVAL hInstance AS DWORD, _
      lpParam AS ANY _
    ) AS DWORD
#ELSE
    DECLARE FUNCTION CreateWindowEx LIB "User32.dll" ALIAS "CreateWindowExA" _
    ( _
      BYVAL dwExStyle AS DWORD,
      Byref lpClassName AS ASCIIZ, _
      Byref lpWindowName AS ASCIIZ, _
      BYVAL dwStyle AS DWORD, _
      BYVAL x AS LONG, _
      BYVAL y AS LONG, _
      BYVAL nWidth AS LONG, _
      BYVAL nHeight AS LONG, _
      BYVAL hWndParent AS DWORD, _
      BYVAL hMenu AS DWORD, _
      BYVAL hInstance AS DWORD, _
      lpParam AS ANY _
    ) AS DWORD
#ENDIF ' NOT %UNICODE

                       

José Roca

 
The disadvantage of the macros is that they can conflict with, for example, a method in an interface with the same name.