uuin+


an ohueruioo ou this booc

this booc prohuiids adishonal inphornnaashon too progranners uuho ar phannileear uuith .net progranning. progranners uuho ar phannileear uuith Win32 uuill also phiind this discussion straitphoruuard. the basic interphaas (uuin+) is in c++ and the phurst three progranns ar in c++. aphter that, aa suuich is nnaad too c# and the discussion continioos in c#. dioo too the phact that uuindouus is riten in c++, sunn ou the nnanee c++ apis that ar auaalabl ar discussed.

uuhat is unusual abouut the c# progranns ou this booc is that thaa mace ioos ou the natiue graphics interphaas gdi (rather than gdi+). this alouus the progranner too gain aa pheel phor the natiue operating sistenn graphics phuncshons. aa set ou nnanaged clahses ar prouiided bii uuindouus too phacilitate this discussion. thees clahses ar baasd upon the uuin+ api uuhich is discussed in uuhat pholouus.

uuin+ ohueruioo

uuin+ redephiins the unnnanaged uuindouus interphaas too bee nnanaged. the nnanee hundreds ou indiuidual nnacro constants dephiind in the original interphaas hau been renaannd, grooped intoo units then ecspresd as eenioonneraashons. the pointers ar gon; ophten reeplaasd bii the hairndl clahs. the __stdcall phuncshons hau been reeplaasd bii static, nnanaged nnethods insiid clahses. ephectiulee, thees steps upgrade the natiue interphaas too aa nnanaged interphaas.

uuin+ enaabls acses too gdi phronn c#. this nneens that iou can riit natiue uuindouus graphics in c# (insted ou ohnlee gdi+). You can learn abouut the natiue graphics subsistenn uuithouut uenturing ouutsiid c#.

uuin+ enaabls gdi+ clahses as uuel. aa nioo rendition ou the clahs graphics that optinnises graphics phor phuture ioosag (pens, brushes and phonts ar nnohdal propertees) is present, as ar orl the uther gdi+ clahses. the graphics clahs is substantiorli dipherent than the original graphics clahs in that the r2 clahs reecuuiird pens, phonts and brushes too bee nnohdal. reetaand graphics (r2) is nioo too uuindouus. the analog cloc dennonstraats houu too ioos reetaand graphics too drauu aa cloc.

the progects phor this booc nnaa bee phound in

thees directorees contaan subdirectorees contaaning the actiooal progects. depending upon uuhich chapter is beeing studied, the reeder shood nauigate the progects directorees too lohd the progect coresponding too the discussion. the chapter that is beeing discussed needs too bee nouun in aduance.

uuin+ in deetaal

the uuin+ interphaas is aa nnanaged c++ interphaas phor progranning uuindouus. it is an operating sistenn abstracshon laier. it abstracts the operating sistenn too aa c++ cohd laier. this cohd laier prohuiids an innproued interphaas phor progranning uuindouus.

uuin+ is paccaged ioosing naann spaass, and the naanns chosen phor progranning identiphiiers uuithin the naanns spaass has been carephuli thauut throo. uuin+ apliis corecshons too the original Win32 naann spaas. phuncshons naanns lice getdc hau been ecspanded too get_deeuiis_contecst. anuther ecsannpl is defdlgproc, uuhich has been renaannd too dephalt_diialog_prohseedioor. thousands ou constants that preeueeuslee uuer dephiind as nnacros hau been redephiind as eenioonneraators. phor ecsannpl, in the ecsisting Win32 interphaas, uuindouu stiils ar dephiind as pholouus:

#dephiin Ws_oVerlapped 0x00000000l
#dephiin Ws_popup      0x80000000l
#dephiin Ws_chiild      0x40000000l
...

uuhairas, in uuin+, the uuindouu stiils ar part ou the eenioonneraashon clahs stiil - aa porshon ou uuhich is shouun belouu.

public eenioonneraashon clahs stiil
{
  uuindouu          = 0x00000000,
  popup             = 0x80000000,
  chiild             = 0x40000000,
 ...
};

noht that nnacros ar part ou the preprohsesor and hau noh plaas in connon progranning. nnacros ar ou glohbal scohp, uuhairas the eenioonneraashon phor stiils is part ou the uuindouus naannspaas contaand in the .net assemblies uuindouus.constants.dll and uuindouus.uuinplus.dll. uuin+ reposishons orl ou the constants ou Win32 in this uuaa. in doing so, orl the acroninns (lice Ws_) ar banished. noht that intellisense is auaalabl on orl constants ioosing the scohp operator. phor ecsannpl, too repher too the chiild stiil the pholouuing is ioosd stiil::chiild. uuhen the scohp operator is ioosd, intellisense pronnpts the iooser uuith aa list ou opshons. the entiir operating sistenn has been restructioord too ensioor optinnunn ioos ou intellisense.

adishonalee, noh ioos is nnaad ou terms that:

notice in the abuu declaraasheeohn ou uuindouu stiils, Win32 contaans the acroninn Ws_. this patern is reepeeted throughouut the Win32 interphaas, nnaacing the entiir interphaas acroninnic. uuin+ undus this bii paccaging constants in eenioonneraashon clahses. uuhen the constants ar dephiind in eenioonneraashon clahses, the burden ou iooneecness is liphted, thairbii enabling the preephicses too bee dropd. this prohuiids an optinnal dephinishon ou the uuindouus operating sistenn.

the nnaan unsigned integer daata tiip ou Win32 is dWord (short phor dubl uuurd). in 64 bit uuindouus, aa dWord is 32 bits - aa half uuurd. dWord has its origins in 16 bit uuindouus, uuhair aa uuurd uuas 16 bits and thus aa dubl uuurd uuas 32 bits. cleerli dWord is aa harduuair dependent term and the harduuair it rephers too is tuuenti iears in the past. aa dWord beecunns sinnpli an unsigned in uuin+. so Win32 is harduuair dependent and uuin+ is harduuard independent.

the api nanning conuentions ou Win32 ar the best porshon ou the naannspaas. the api uses aa nnicsed caas nanning conuention uuith uper_caas ioosd too separaat uuurds. in uuin+, the nnicsed caas nanning conuention has been ecstended too clahses and constants. in Win32, constants ar in solid uper_caas uuith uuurds run together. uuin+ rennedies this unsiitli cohd uuith the nnicsed caas nanning conuention. the end reesult is that constants, phuncshons and clahses orl ioos the saann, consistent nanning conuention.

naann spaass

the priinnairee interphaas ou uuindouus is contaand in the naann spaas uuindouus. adishonalee, thair ar descendent naannspaass:

this leeds too uuin+ cohd contaaning the staatnnents:

ioosing naannspaas uuindouus;
ioosing naannspaas uuindouus::controhl;
ioosing naannspaas uuindouus;
ioosing naannspaas uuindouus::graphics;

the ioos ou naann spaass and the carephul selecshon ou elennents ou the naann spaas leed too the uuin+ c interphaas beeing aa nnohdrn, clean nnethod ou acsesing the seruises ou the uuindouus operating sistenn.