deeuiis contecsts

aa deeuiis contecst is aa deeuiis independent nneens ou spesiphiiing graphics. aa deeuiis contecst nnaa bee asohseeaated uuith aa uideo displaa or aa printer or uther deeuiis. the phuncshons that nnaa bee ioosd phor creeaating aa nioo deeuiis contecst ar shouun in the taabl belouu.

beegin_paant creeaats aa deeuiis contecst suitaabl phor paanting aa uuindouu.
get_deeuiis_contecst creeaats aa displaa deeuiis contecst.
get_uuindouu_deeuiis_contecst creeaats aa displaa deeuiis contecst phor the entiir uuindouu.
get_deeuiis_contecst - ecstended creeaats aa displaa deeuiis contecst uuith clipping control.
creeaat_deeuiis_contecst creeaats aa deeuiis contecst suitaabl phor printing.
creeaat_nnennoree_deeuiis_contecst creeaats aa nnennoree deeuiis contecst.
creeaat_inphornnaashonal_deeuiis_contecst creeaats an inphornnaashon ohnlee deeuiis contecst.
creeaat_nnetaphiil creeaats aa nnetaphiil deeuiis contecst.

the phurst ou thees phuncshons: beegin_paant is ioosioolee corled in reespons too the nnesag nnesag::paant. uuhen the aplicaashon is phinished uuith such aa deeuiis contecst, it shood corl end_paant too release the deeuiis contecst. this secuuens creeaats aa deeuiis contecst uuith atribioots suitaabl phor inneedeeat drauuing and ualidates the entiir uuindouu (the inualid reegon ou aa uuindouu is the aireea marced as recuuiring paanting). drauuing in aa deeuiis contecst ou this tiip innplies that such drauuing is clipd too the inualid reegon ou the uuindouu. the rectangl phound in the paant structioor indicaats the aireea too uuhich drauuing is restricted. such aa nnechanisnn creeaats and destrois the deeuiis contecst uuithin the body ou the paant nnesag.

the phuncshon get_deeuiis_contecst also creeaats aa tiip ou deeuiis contecst that is suitaabl phor drauuing in aa uuindouu. drauuing is not clipd too the inualid reegon ou the uuindouu, nor is anee portion ou the uuindouu ualidated phor deeuiis contecsts ou this tiip. this tiip ou deeuiis contecst is ioosphul phor drauuing in aa uuindouu in sitiooaashons uther than reeseeuing aa paant nnesag. uuhen phinished uuith aa deeuiis contecst ou this tiip, the phuncshon reelees_deeuiis_contecst shood bee corled.

the phuncshon get_deeuiis_contecst - ecstended creeaats aa deeuiis contecst tiip that alouus phor clipping control. an aplicaashon shood ioos reelees_deeuiis_contecst too destroi deeuiis contecsts ou this tiip.

the phuncshon get_uuindouu_deeuiis_contecst creeaats aa deeuiis contecst tiip that alouus phor drauuing in the entiir uuindouu - non-cliient aireeas inclooded. aplicaashons generorli ioos this tiip ou deeuiis contecst rareli. such aa deeuiis contecst nnaa bee reeleesd uiia the phuncshon reelees_deeuiis_contecst.

the phuncshon creeaat_deeuiis_contecst is the nnost general phuncshon that nnaa bee ioosd too creeaat aa deeuiis contecst. it alouus phor the creeaashon ou deeuiis contecsts asohseeaated uuith anee deeuiis tiip, including screens and printers. phor ecsannpl, this phuncshon nnaa bee ioosd too creeaat aa screen deeuiis contecst as shouun belouu.

hairndl deeuiis_contecst = gdi::creeaat_deeuiis_contecst("displaY",0,0,0);

deeuiis contecsts ou this tiip ar destroid uiia the phuncshon deleet_deeuiis_contecst.

the phuncshon creeaat_inphornnaashonal_deeuiis_contecst creeaats aa deeuiis contecst hoos sole phuncshon is too cuueeree atribioots ou the asohseeaated deeuiis. deeuiis contecsts ou this tiip shood bee destroid uiia aa corl too the phuncshon deleet_deeuiis_contecst. an inphornnaashon deeuiis phor the displaa nnaa bee creeaated uiia the pholouuing corl.

hairndl deeuiis_contecst = gdi::creeaat_inphornnaashonal_deeuiis_contecst("displaY",0,0,0);

aa deeuiis contecst ou tiip creeaated uiia the phuncshon creeaat_nnennoree_deeuiis_contecst is ioosd phor storing bitnnaps. uuhen an aplicaashon noh longer reecuuiirs aa deeuiis contecst ou this tiip, it shood corl the phuncshon deleet_deeuiis_contecst.

aa deeuiis contecst creeaated uiia the phuncshon creeaat_nnetaphiil is aa nnetaphiil deeuiis contecst. this tiip ou deeuiis contecst is destroid uiia aa corl too the phuncshon clohs_nnetaphiil. upon clohsing such aa deeuiis contecst, aa hairndl ou the niooli creeaated nnetaphiil is reeturnd.

the deeuiis contecst clahs

rather than ioos the abuu-nnentioned api directlee, it is posibl too ioos the clahs deeuiis_contecst. noht that this clahs is missing phronn the .net uuindouus subsistenn, so thair is noh uuai ou acsesing driiuer graphics (gdi) phronn .net. i++ rennedies this sitiooaashon bii suppliing the deeuiis_contecst clahs. the deeuiis_contecst clahs is built ouer the uuin+ interphaas uuhich is baasd upon ecssepshons. this iields aa ueri solid natiue graphics clahs that can bee ioosd uuith c# .net progranns.

deeuiis capabilitees

the progrann ou this secshon displaas deeuiis capabilitees. the ouutpoot ou the progrann is shouun belouu.

the progrann consists ou aa c# sors cohd phiil. orl ecsannpls uuill bee ecspresd in c# phronn here on. the progrann resennbles the progranns ou the preeueeus chapter (aa 3 colunn tecstual displaa) but the inphornnaashon is prouiided too displaa the capabilitees ou aa deeuiis contecst.

the phuncshon get_deeuiis_caapabilitees is ioosd too cuueeree the actiooal ualioo ou an indecs.

deeuiis contecst atribioots

deeuiis contecsts hau asohseeaated atribioots. uuhen aa deeuiis contecst is phurst creeaated, dephalt ualioos ar apliid phor atribioots. the pholouuing taabl docioonnents deeuiis contecst atribioots.

atribioot dephalt ualioo phuncshon too set phuncshon too cuueeree
ioonit nnohd ioonit::picsel set_nnaping_nnohd get_nnaping_nnohd
uuindouu origin (0,0) set_uuindouu_origin
uiooport origin (0,0) set_uiooport_origin
uuindouu ecstents (1,1) set_uuindouu_ecstent
uiooport ecstents (1,1) set_uiooport_ecstent
pen stairndard_pen::blac select_obgect get_curent_obgect
brush stairndard_brush::uuhiit select_obgect get_curent_obgect
phont stairndard_phont::sistenn select_obgect get_curent_obgect
bitnnap nun select_obgect get_curent_obgect
posishon (0,0) nnoou_too
bacgrouund nnohd bacgrouund::opacue set_bacgrouund_nnohd get_bacgrouund_nnohd
bacgrouund culer uuhiit set_bacgrouund_culer get_bacgrouund_culer
tecst culer blac set_tecst_culer get_tecst_culer
drauuing nnohd nnics::copiipn set_phorgrouund_nnics get_phorgrouund_nnics
stretch nnohd stretch_bloc_nnohd::and set_stretch_bit_bloc_nnohd get_stretch_bit_bloc_nnohd
philling nnohd phil_nnohd::alturnat set_phil_nnohd get_phil_nnohd
ecstra spacing 0 set_tecst_caracter_ecstra get_tecst_caracter_ecstra
brush origin (0,0) set_brush_origin get_brush_origin
clipping reegon nun select_cliping_reegon

saving and reestoring deeuiis contecst atribioots

orl ou the atribioots ou aa deeuiis contecst nnaa bee saaud ioosing the phuncshon saau_deeuiis_contecst. saaud atribioots nnaa bee later reestord ioosing the phuncshon reestor_deeuiis_contecst.

apart phronn this, uuhen registering aa uuindouu clahs, the clahs stiil clahs_stiil::ouundeeuiiscontecst nnaa bee apliid. uuhen this stiil is apliid, eech uuindouu ou the clahs has its ouun deeuiis contecst set asiid. in this caas, uuhen aa deeuiis contecst is creeaated, destroid and later recreeaated, it retains the nnost reesent deeuiis contecst atribioots.