如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
VisualC++界面编程技术学习笔记——王静文第1章基于控件的界面编程1.1自绘(OwnerItem)按钮的实现通常使用VC提供的控件时,对于控件的外观是使用系统提供默认的方式进行绘制的。自绘控件:如果控件指定了控件的自绘属性,那么控件的父窗口会收到一个由自绘控件发出的WM—_DRAWITEM消息,消息响应的函数是OnDrawItemafx_msgvoidOnDrawItem(intHYPERLINK""nIDCtl,LPDRAWITEMSTRUCTHYPERLINK""lpDrawItemStruct);ParametersnIDCtlContainstheidentifierofthecontrolthatsenttheWM_DRAWITEMmessage.Ifamenusentthemessage,nIDCtlcontains0.lpDrawItemStructSpecifiesalongpointertoaDRAWITEMSTRUCTdatastructurethatcontainsinformationabouttheitemtobedrawnandthetypeofdrawingrequired.RemarksTheitemActionmemberoftheHYPERLINK"ms-help://MS.MSDNQTR.2003FEB.2052/vclib/html/_mfc_drawitemstruct_structure.htm"DRAWITEMSTRUCTstructuredefinesthedrawingoperationthatistobeperformed.Thedatainthismemberallowstheownerofthecontroltodeterminewhatdrawingactionisrequired.Beforereturningfromprocessingthismessage,anapplicationshouldensurethatthedevicecontextidentifiedbythehDCmemberoftheDRAWITEMSTRUCTstructureisrestoredtothedefaultstate.IfthehwndItemmemberbelongstoaHYPERLINK"ms-help://MS.MSDNQTR.2003FEB.2052/vclib/html/_mfc_cbutton.htm"CButton,HYPERLINK"ms-help://MS.MSDNQTR.2003FEB.2052/vclib/html/_mfc_cmenu.htm"CMenu,HYPERLINK"ms-help://MS.MSDNQTR.2003FEB.2052/vclib/html/_mfc_clistbox.htm"CListBox,orHYPERLINK"ms-help://MS.MSDNQTR.2003FEB.2052/vclib/html/_mfc_ccombobox.htm"CComboBoxobject,thentheDrawItemvirtualfunctionoftheappropriateclassiscalled.OverridetheDrawItemmemberfunctionoftheappropriatecontrol'sclasstodrawtheitem.NoteThismemberfunctioniscalledbytheframeworktoallowyourapplicationtohandleaWindowsmessage.Theparameterspassedtoyourfunctionreflecttheparametersreceivedbytheframeworkwhenthemessagewasreceived.Ifyoucallthebase-classimplementationofthisfunction,thatimplementationwillusetheparametersoriginallypassedwiththemessageandnottheparametersyousupplytothefunction.DRAWITEMSTRUCTStructureSeeAlsoHYPERLINK"ms-help://MS.MSDNQTR.2003FEB.2052/vclib/html/_mfc_structures.2c_.styles.2c_.callbacks.2c_.and_message_maps.htm"