🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #1125

Re: Scoping question using C and SDK

#1125
From: Scott Heyano
Date: Wed, 23 Jan 1991 17:09
23 lines
1987 bytes
In article <1991Jan23.044611.21227@cs.uoregon.edu> akm@cs.uoregon.edu (Anant Kartik Mithal) writes:
|I'm confused by what the scope of a variable is in a Windows program.
|I would assume that it uses standard C scoping (assuming that you are 
|using C, which is what I'm using). In the Guide to Programming, in the
|chapter "Output to a Window," they give an example which requires a
|bunch of HPEN, HBRUSH etc. They ask you to construct a program (pages
|3-8 thru 3-9) that is something like
[stuff]
|It seemed to me that I could define all the pens and brushes within
|MainWndProc, so that they would  not be global variables (they were
|being used only in the WM_CREATE and the WM_PAINT cases, both within
|MainWndProc. However, when I did that, it didn't work. When I went to
|the way things are defined in the book, it worked. Unfortunately, that
|doesn't give me any way of figuring out what the scoping rules are...

	It doesn't have anything to do with windows or scoping rules,
	globals are static, locals are not (unless you explicitly
	declare as such).
	The various cases of the function are executed during
	different invocations of the function, so the values
	set in one case clause are lost by the time there are used in another.
	Try putting the variables back inside the function &
	declaring them static.
Technical Details
Message-ID: <14628@june.cs.washington.edu>
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!mit-eddie!uw-beaver!uw-june!wolf.cs.washington.edu!slh
References: <1991Jan23.044611.21227@cs.uoregon.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!mit-eddie!uw-beaver!uw-june!wolf.cs.washington.edu!slh
From: slh@wolf.cs.washington.edu (Scott Heyano)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Scoping question using C and SDK
Summary: static
Keywords: scoping, C, SDK, statics, globals
Message-ID: <14628@june.cs.washington.edu>
Date: 23 Jan 91 17:09:03 GMT
References: <1991Jan23.044611.21227@cs.uoregon.edu>
Sender: news@cs.washington.edu
Reply-To: slh@wolf.cs.washington.edu (Scott Heyano)
Organization: Computer Science & Engineering, U. of Washington, Seattle
Lines: 23