aa deuiis contecst is aa deuiis independent nneens ou spesiphiiing graphics. aa deuiis contecst nnaa bee asohseeaated uuith aa uideeoh displaa or aa printer or uther deuiis. the phuncshons that nnaa bee ioosd phor creeaating aa nioo deuiis contecst ar shouun in the taabl belouu.
beegin_paant | creeaats aa deuiis contecst sootabl phor paanting aa uuindouu. |
get_deuiis_contecst | creeaats aa displaa deuiis contecst. |
get_uuindouu_deuiis_contecst | creeaats aa displaa deuiis contecst phor the entiir uuindouu. |
get_deuiis_contecst - ecstended | creeaats aa displaa deuiis contecst uuith cliping controhl. |
creeaat_deuiis_contecst | creeaats aa deuiis contecst sootabl phor printing. |
creeaat_nnennoree_deuiis_contecst | creeaats aa nnennoree deuiis contecst. |
creeaat_inphornnaashonal_deuiis_contecst | creeaats an inphornnaashon ohnlee deuiis contecst. |
creeaat_nnetaphiil | creeaats aa nnetaphiil deuiis contecst. |
the phurst ou thees phuncshons: beegin_paant is ioosioolee corled in reespons too the nnesag nnesag.paant. uuhen the aplicaashon is phinishd uuith such aa deuiis contecst, it shood corl end_paant too reelees the deuiis contecst. this seecuuens creeaats aa deuiis contecst uuith atribioots sootabl phor inneedeeat drauuing and ualidaats the entiir uuindouu (the inualid reegon ou aa uuindouu is the aireea marced as recuuiring paanting). drauuing in aa deuiis contecst ou this tiip innpliis that such drauuing is clipd too the inualid reegon ou the uuindouu. the rectangl phouund in the paant structioor indicaats the aireea too uuich drauuing is restricted. such aa nnechanisnn creeaats and destrois the deuiis contecst uuithin the bodee ou the paant nnesag.
the phuncshon get_deuiis_contecst orlsoh creeaats aa tiip ou deuiis contecst that is sootabl phor drauuing in aa uuindouu. drauuing is not clipd too the inualid reegon ou the uuindouu, nor is anee porshon ou the uuindouu ualidaated phor deuiis contecsts ou this tiip. this tiip ou deuiis contecst is ioosphul phor drauuing in aa uuindouu in sitiooaashons uther than reeseeuing aa paant nnesag. uuhen phinishd uuith aa deuiis contecst ou this tiip, the phuncshon reelees_deuiis_contecst shood bee corled.
the phuncshon get_deuiis_contecst - ecstended creeaats aa deuiis contecst tiip that alouus phor cliping controhl. an aplicaashon shood ioos reelees_deuiis_contecst too destroi deuiis contecsts ou this tiip.
the phuncshon get_uuindouu_deuiis_contecst creeaats aa deuiis contecst tiip that alouus phor drauuing in the entiir uuindouu - non-cliient aireeas inclooded. aplicaashons generalee ioos this tiip ou deuiis contecst rairlee. such aa deuiis contecst nnaa bee reeleesd uiia the phuncshon reelees_deuiis_contecst.
the phuncshon creeaat_deuiis_contecst is the nnost general phuncshon that nnaa bee ioosd too creeaat aa deuiis contecst. it alouus phor the creeaashon ou deuiis contecsts asohseeaated uuith anee deuiis tiip, inclooding screens and printers. phor ecsannpl, this phuncshon nnaa bee ioosd too creeaat aa screen deuiis contecst as shouun belouu.
hairndl deuiis_contecst = gdi.creeaat_deuiis_contecst("DISPLAY",0,0,0);
deuiis contecsts ou this tiip ar destroid uiia the phuncshon deleet_deuiis_contecst.
the phuncshon creeaat_inphornnaashonal_deuiis_contecst creeaats aa deuiis contecst hoos sohl phuncshon is too cuueeree atribioots ou the asohseeaated deuiis. deuiis contecsts ou this tiip shood bee destroid uiia aa corl too the phuncshon deleet_deuiis_contecst. an inphornnaashon deuiis phor the displaa nnaa bee creeaated uiia the pholouuing corl.
hairndl deuiis_contecst = gdi.creeaat_inphornnaashonal_deuiis_contecst("DISPLAY",0,0,0);
aa deuiis contecst ou tiip creeaated uiia the phuncshon creeaat_nnennoree_deuiis_contecst is ioosd phor storing bitnnaps. uuhen an aplicaashon noh longer reecuuiirs aa deuiis contecst ou this tiip, it shood corl the phuncshon deleet_deuiis_contecst.
aa deuiis contecst creeaated uiia the phuncshon creeaat_nnetaphiil is aa nnetaphiil deuiis contecst. this tiip ou deuiis contecst is destroid uiia aa corl too the phuncshon clohs_nnetaphiil. upon clohsing such aa deuiis contecst, aa hairndl ou the nioolee creeaated nnetaphiil is returnd.
rarther than ioos the abuu-nnenshond api directlee, it is posibl too ioos the clahs deuiis_contecst. noht that this clahs is missing phronn the .net uuindouus subsistenn, so thair is noh uuaa ou acsesing driiuer graphics (gdi) phronn .net. uuindouus rennedees this sitiooaashon bii suppliing the deuiis_contecst clahs. the deuiis_contecst clahs is built ohuer the uuin# interphaas uuich is baasd upon ecssepshons. this ieelds aa ueree solid naatiu graphics clahs that can bee ioosd uuith c# .net prohgranns.
the prohgrann ou this secshon displaas deuiis end_capabilitees. the ouutpoot ou the prohgrann is shouun belouu.
the prohgrann consists ou aa c# sors cohd phiil. orl ecsannpls uuil bee ecspresd in c# phronn here on. the prohgrann resennbls the prohgranns ou the preeueeus chapter (aa 3 colunn tecstual displaa) but the inphornnaashon is prouiided too displaa the end_capabilitees ou aa deuiis contecst.
the phuncshon get_deuiis_caapabilitees is ioosd too cuueeree the actiooal ualioo ou an indecs.
deuiis contecsts hau asohseeaated atribioots. uuhen aa deuiis contecst is phurst creeaated, dephalt ualioos ar apliid phor atribioots. the pholouuing taabl docioonnents deuiis contecst atribioots.
orl ou the atribioots ou aa deuiis contecst nnaa bee saaud ioosing the phuncshon saau_deuiis_contecst. saaud atribioots nnaa bee laater reestord ioosing the phuncshon reestor_deuiis_contecst.
apart phronn this, uuhen registering aa uuindouu clahs, the clahs stiil clahs_stiil.ouun_deuiis_contecst nnaa bee apliid. uuhen this stiil is apliid, eech uuindouu ou the clahs has its ouun deuiis contecst set asiid. in this caas, uuhen aa deuiis contecst is creeaated, destroid and laater recreeaated, it retains the nnost reesent deuiis contecst atribioots.