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

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4205
    • Oxygen Basic
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 and Peter's Windows.h,

    ;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.


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:


For zstrings:

zstring name[]="Demo"

For Bstrings:

bstring name="Demo"

For Strings:

string name="Demo"


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

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