Author Topic: Assigning string pointer to long variable  (Read 1769 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Assigning string pointer to long variable
« on: September 20, 2011, 03:45:44 AM »
Peter and all Windows Api users:

This is an issue with the low-level Windows type definitions that is used in MinWinc.inc and Peter's Windows.h,

 type WNDCLASS
    ;40 bytes
    style         as long
    lpfnwndproc   as long
    cbClsextra    as long
    cbWndExtra    as long
    hInstance     as long
    hIcon         as long
    hCursor       as long
    hbrBackground as long
   lpszMenuName  as long
    lpszClassName as long
 end type


In previous versions a string literal or bstring could be assigned directly to lpszClassName or lpszMenuName.

lpszClassName="Demo"

Unfortunately This is no longer possible because the compiler type-converter will evaluate the string and turn it into a long integer. This change of behaviour is a necessary rationalisation to make Oxygen logically consistent.


The solution is to use a pointer or casting operator thus:

For String Literals:

lpszClassName=@"Demo"

For zstrings:

zstring name[]="Demo"
lpszClassName=@name

For Bstrings:

bstring name="Demo"
lpszClassName=?name

For Strings:

string name="Demo"
lpszClassName=*name

Charles

PS: zip file below containing Window.h with these modifications






« Last Edit: September 20, 2011, 03:55:24 AM by Charles Pegge »