News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

GLOBAL Structure

Started by Davis, May 20, 2024, 08:43:56 AM

Previous topic - Next topic

Davis

if this is how to delcare a LOCAL structure
what would the syntax be for a global structure ?

LOCAL          WndClass            :WNDCLASSEX

zedd151

.data?
WndClass WNDCLASSEX <?>

or

.data
WndClass WNDCLASSEX <0>

or
.data
WndClass WNDCLASSEX <>

You can also preinitialize the members of WNDCLASSEX in '.data'., rather than leaving all members as zero (and initializing in the code)

example using a preinitialized RECT structure
    .data
        btn0        RECT <774, 404, 838, 468>
:undecided:

zedd151

...
another whoops on my part....  :rolleyes:
meant to edit above not quote it.
:undecided:

NoCforMe

Sudoku said it right.
Since you're asking about local vs. global, here's a convention I follow so I can immediately tell from looking at one of my variables whether it's global or local:
; Define a global structure (WC), partially initialized:
WC WNDCLASSEX < SIZEOF WNDCLASSEX, \
CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW or CS_DBLCLKS, \
NULL, \ ;lpfnWndProc
NULL, \ ;cbClsExtra
NULL, \ ;cbWndExtra
NULL, \ ;hInstance
NULL, \ ;hIcon
NULL, \ ;hCursor
NULL, \ ;hbrBackground
NULL, \ ;lpszMenuName
NULL, \ ;lpszClassName
NULL > ;hIconSm

; Now define a local structure (wc) in a subroutine:
SomeProc PROC
LOCAL wc:WNDCLASSEX

I start all LOCAL vars. with lowercase letters and all globals with Uppercase letters.
Works well for me; I recommend it.
Assembly language programming should be fun. That's why I do it.

Davis


zedd151

:undecided: