ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡
µÚÈýµç×ÓÊé ·µ»Ø±¾ÊéĿ¼ ¼ÓÈëÊéÇ© ÎÒµÄÊé¼Ü ÎÒµÄÊéÇ© TXTÈ«±¾ÏÂÔØ ¡ºÊղص½ÎÒµÄä¯ÀÀÆ÷¡»

CÓïÑÔʵÀý½Ì³Ì(PDF¸ñʽ)-µÚ46²¿·Ö

¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿! Èç¹û±¾ÊéûÓÐÔĶÁÍ꣬ÏëÏ´μÌÐø½Ó×ÅÔĶÁ£¬¿ÉʹÓÃÉÏ·½ "Êղص½ÎÒµÄä¯ÀÀÆ÷" ¹¦ÄÜ ºÍ "¼ÓÈëÊéÇ©" ¹¦ÄÜ£¡




pDC¡­¡·FrameRect£¨&lpDrawItemStruct¡­¡·rcItem£»¡¡&br£©£»¡¡¡¡



£ý¡¡¡¡



if¡¡£¨£¡£¨lpDrawItemStruct¡­¡·itemState¡¡&¡¡ODS_SELECTED£©¡¡&&¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡383¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

£¨lpDrawItemStruct¡­¡·itemAction¡¡&¡¡ODA_SELECT£©£©¡¡¡¡



£û¡¡¡¡



//¡¡Ñ¡ÖÐ״̬ÓÉÑ¡ÖбäΪ·ÇÑ¡ÖУ¬Çå³ýÆä±ß¿òµÄ¼ÓÁÁÏÔʾ¡¡¡¡



CBrush¡¡br£¨cr£©£»¡¡¡¡



pDC¡­¡·FrameRect£¨&lpDrawItemStruct¡­¡·rcItem£»¡¡&br£©£»¡¡¡¡



£ý¡¡¡¡



£ý¡¡¡¡



¶ÔÓÚ×Ô»æÖÆ×éºÏ¿òÀ´Ëµ£¬³ÉÔ±º¯ÊýDrawItemÊÇÐèÒªÖØÔصÄÒ»¸öºÜÖØÒª¡¡

µÄ³ÉÔ±º¯Êý¡£¸Ãº¯ÊýÔÚ×Ô»æÖÆ×éºÏ¿òµÄ¿ÉÊÓ²¿·Ö·¢Éú¸Ä±äʱÓÉ¿ò¼Üµ÷¡¡

Óá£ÔÚĬÈÏÇé¿öÏ£¬¸Ã³ÉÔ±º¯Êý²»×öÈκβÙ×÷¡£Æä²ÎÊý¡¡

lpDrawItemStructËùÖ¸ÏòµÄDRAWITEMSTRUCT½á¹¹°üÀ¨ÁËÖØ»æÖÆËùÐèÒª¡¡

µÄ¸÷ÖÖÐÅÏ¢£¬ÈçËùÐèÖØ»æµÄÏî¡¢ÆäÉ豸ÉÏÏÂÎÄÒÔ¼°ËùÖ´ÐеÄÖØ»æÐÐΪ¡¡

µÈ¡£ÔڸóÉÔ±º¯ÊýÖÕֹǰ£¬Ó¦ÓóÌÐòÓ¦¸Ã»Ö¸´ÓɸÃDRAWITEMSTRUCT½á¡¡

¹¹ËùÌṩµÄΪ¸ÃÏÔʾÉÏÏÂÎÄËùÑ¡¶¨Í¼ÐÎÉ豸½Ó¿Ú¡£¡¡¡¡



Óɱí6¡£30¿ÉÖªÔÚ±¾Ê¾Àý³ÌÐòÖÐËùʹÓõÄ×Ô»æ×éºÏ¿òÖеĿÉÑ¡ÏîÊÇÓÐÐò¡¡

µÄ£¬¶øËüÃǶ¼ÊÇһЩÑÕÉ«Öµ£¬¿ò¼ÜÈçºÎÖªµÀµ±Ò»¸öеÄÑÕÉ«Öµ±»Ìí¼Ó¡¡

µ½×éºÏ¿òµÄÁбí¿òÖÐʱ£¬ËüÓ¦¸Ã´¦ÓÚÄĸöÑÕɫֵ֮ǰ£¬ÄĸöÑÕÉ«ÖµÖ®¡¡

ºóÄØ£¿Õâʱͨ¹ýµ÷ÓóÉÔ±º¯ÊýpareItem³ÉÔ±º¯ÊýÀ´ÊµÏֵġ£Èç¹û¡¡

ÔÚ´´½¨×éºÏ¿òʱָ¶¨ÁËLBS_SORTÑùʽ£¬Ôò±ØÐëÖØÔظóÉÔ±º¯ÊýÒÔÌṩ¡¡

×ã¹»µÄÀíÓÉÀ´°ïÖú¿ò¼Ü¶ÔÐÂÌí¼ÓÈë×éºÏ¿òµÄÁбí¿òÖеÄÑÕÉ«Ïî½øÐÐÅÅ¡¡

Ðò¡£ÕâÀÎÒÃÇÊ×Ïȸù¾ÝÑÕÉ«ÁÁ¶ÈµÄ´óСÀ´¶ÔÑÕÉ«½øÐÐÅÅÐò£¬¶ÔÓÚÁÁ¡¡

¶ÈÏàͬµÄÑÕÉ«£¬ÎÒÃÇÒÀ´ÎÒÔ´ÓÀ¶É«µ½ºìÉ«µÄÓÅÏȼ¶À´Åж¨ÆäÏà¶Ôλ¡¡

Öá£Õâ¸ö²Ù×÷ÊÇÒÔÏÂÃæµÄ´úÂëÀ´ÊµÏֵģº¡¡¡¡



int¡¡CClrboBox£º£ºpareItem£¨LPPAREITEMSTRUCT¡¡lppareItemStruct£©¡¡¡¡¡¡



£û¡¡¡¡



//¡¡TODO£º¡¡Ìí¼ÓÅжÏÖ¸¶¨ÏîµÄÅÅÐò˳ÐòµÄ´úÂë¡¡¡¡



//¡¡µ±Ïî¡¡1¡¡ÔÚÏî¡¡2¡¡Ö®Ç°Ê±·µ»Ø¡¡¡­1¡¡¡¡



//¡¡µ±Ïî¡¡1¡¡ºÍÏî¡¡2¡¡Ë³ÐòÏàͬʱ·µ»Ø¡¡0¡¡¡¡



//¡¡µ±Ïî¡¡1¡¡ÔÚÏî¡¡2¡¡Ö®ºóʱ·µ»Ø¡¡1¡¡¡¡



//¡¡»ñµÃÏî¡¡1¡¡ºÍÏî¡¡2¡¡µÄÑÕÉ«Öµ¡¡¡¡



COLORREF¡¡cr1¡¡=¡¡£¨COLORREF£©lppareItemStruct¡­¡·itemData1£»¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡384¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

COLORREF¡¡cr2¡¡=¡¡£¨COLORREF£©lppareItemStruct¡­¡·itemData2£»¡¡¡¡



if¡¡£¨cr1¡¡==¡¡cr2£©¡¡¡¡



£û¡¡¡¡



//¡¡Ïî¡¡1¡¡ºÍÏî¡¡2¡¡¾ßÓÐÏàͬµÄÑÕÉ«¡¡¡¡



return¡¡0£»¡¡¡¡



£ý¡¡¡¡



//¡¡½øÐÐÁÁ¶È±È½Ï£»¡¡ÁÁ¶ÈµÍµÄÅÅÁÐ˳ÐòÔÚÇ°¡¡¡¡



int¡¡intensity1¡¡=¡¡GetRValue£¨cr1£©¡¡£«¡¡GetGValue£¨cr1£©¡¡£«¡¡GetBValue£¨cr1£©£»¡¡¡¡



int¡¡intensity2¡¡=¡¡GetRValue£¨cr2£©¡¡£«¡¡GetGValue£¨cr2£©¡¡£«¡¡GetBValue£¨cr2£©£»¡¡¡¡



if¡¡£¨intensity1¡¡¡¶¡¡intensity2£©¡¡¡¡



return¡¡¡­1£»¡¡¡¡



else¡¡if¡¡£¨intensity1¡¡¡·¡¡intensity2£©¡¡¡¡



return¡¡1£»¡¡¡¡



//¡¡Èç¹ûÁÁ¶ÈÏàͬ£»¡¡°´ÑÕÉ«½øÐÐÅÅÐò£»¡¡£¨À¶É«×îÇ°£»¡¡ºìÉ«×îºó£©¡¡¡¡



if¡¡£¨GetBValue£¨cr1£©¡¡¡·¡¡GetBValue£¨cr2£©£©¡¡¡¡



return¡¡¡­1£»¡¡¡¡



else¡¡if¡¡£¨GetGValue£¨cr1£©¡¡¡·¡¡GetGValue£¨cr2£©£©¡¡¡¡



return¡¡¡­1£»¡¡¡¡



else¡¡if¡¡£¨GetRValue£¨cr1£©¡¡¡·¡¡GetRValue£¨cr2£©£©¡¡¡¡



return¡¡¡­1£»¡¡¡¡



else¡¡¡¡



return¡¡1£»¡¡¡¡



£ý¡¡¡¡



ÉÏÃæµÄ´úÂëͬʱҲ˵Ã÷ÁËpareItem³ÉÔ±º¯ÊýµÄ²»Í¬·µ»ØÖµËù´ú±í¡¡

µÄ²»Í¬º¬Òå¡£ÕâÀïҪעÒâµÄÊÇ£¬ÓÉÓÚͬÁÁ¶ÈµÄ²»Í¬ÑÕÉ«¸øÈ˵ÄÑÛ¾¦µÄ¡¡

ÁÁ¶È¸Ð¾õÊDz»Ò»ÑùµÄ£¨ÕâºÃ±ÈÈ˶ú¶ÔÉùÒôµÄ¸ßƵ¶ÎºÍµÍƵ¶ÎµÄÌý¾õÁé¡¡

Ãô¶ÈÒª±È¶ÔÖÐƵ¶ÎµÄÌý¾õÁéÃô¶ÈҪСһÑù£©£¬ÉÏÃæµÄÅÅÐò½á¹û¸øÈ˸С¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡385¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¾õ²¢²»ÏóÎÒÃÇËùÏëÏóµÄÄÇÑù£¬ÊÇͨ¹ýÑÕÉ«µÄÁÁ¶ÈÀ´½øÐеġ£µ«ÎÒÃÇû¡¡

ÓбØÒªÔÚÕâ¸öÎÊÌâÉϹý·ÖµÄ¾À²ø¶øÀË·Ñʱ¼ä¡£ÁíÍâÎÒÃǽâÊÍһϣ¬Îª¡¡

ʲôҪʹÓÃ~cr¡¡¡¡&¡¡¡¡0x00FFFFFFÀ´´úÌæ~cr¡£ºÜ¶àÈË»áÈÏΪֱ½Ó½«ÑÕÉ«¡¡

Öµ°´Î»È¡·´¾Í¿ÉÒԵõ½Æä¶Ô±ÈÉ«£¬µ«ÊÂʵ²»ÊÇÕâÑùµÄ¡£ÕâÊÇÒòΪÈç¹û¡¡

32λÑÕÉ«ÖµµÄ¸ßλ×Ö½Ú²»ÎªÁãµÄ»°£¬¸ÃÑÕÉ«Öµ½«²»±»µ±×÷Ò»¸öRGBÑÕ¡¡

É«Öµ£¬¶øʹÓÃij¸ö32λֵÓë0x00FFFFFF°´Î»ÓëÇ¡¿ÉÒÔʹÆä¸ßλ×Ö½ÚΪ¡¡

Á㣬¶øÆäËüλÔò²»±ä¡£¡¡¡¡



µ½Ä¿Ç°ÎªÖ¹ÎÒÃÇÍê³ÉÁË×Ô»æÖÆ×éºÏ¿ò¶ÔÓ¦µÄÀàCClrboBoxµÄÉè¼Æ£¬¡¡

ÏÂÃæÎÒÃÇÀ´¿´ÈçºÎÔÚ³ÌÐòÖн«ÀàCClrboBoxµÄ¶ÔÏóÓë¶Ô»°¿òÄ£°åÖС¡

µÄÏÖ´æ×éºÏ¿òÏà¹ØÁª£¬ÕâÊÇʹÓú¯ÊýSubclassDlgItemÀ´ÊµÏֵġ£Êס¡

ÏÈÔÚÀàCboDemoDlgÖÐÌí¼ÓÒ»¸öÀàÐÍΪCClrboBoxµÄ³ÉÔ±±äÁ¿¡¡

m_clrbo£¬Æä·ÃÎÊÏÞÖÆÔÚ±¾¹¤³ÌÖÐÊDz»ÖØÒªµÄ£¬¿ÉÒÔ½«ËüÉèÖÃΪ¡¡

protected¡£È»ºó£¬ÔÚÀàCboDemoDlgµÄOnInitDialog³ÉÔ±º¯ÊýÖС¡

µÄ//¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡TODO×¢ÊÍÖ®ºóÌí¼ÓÏÂÃæµÄÒ»ÐдúÂ룬ÕâÐдúÂ뽫¶ÔÏó¡¡

m_clrboÓëIDΪIDC_CLRBOÏà¹ØÁª£¬µÚÒ»¸ö²ÎÊýΪ¿Ø¼þµÄ¸¸´°¿Ú¡¡

µÄÖ¸Õë¡£¡¡¡¡



m_clrbo¡£SubclassDlgItem£¨IDC_CLRBO£»¡¡this£©£»¡¡¡¡



ÕâÑù¾Í¿ÉÒÔͨ¹ýCWndµÄÏûÏ¢Ó³Éä»úÖƺÍÏûÏ¢´«µÝ·¾¶ÔÚÀà¡¡

CClrboBoxÖд¦ÀíIDC_CLRBOÖÐʼþÁË¡£±ÈÈçµ±×éºÏ¿òÖеÄÏîÐè¡¡

ÒªÖØ»æʱ£¬ÔÚCClrboBoxÖж¨ÒåµÄDrawItem³ÉÔ±º¯Êý½«±»µ÷Óã¬ÔÚ¡¡

ÕýÈ·µÄ»æÖÆ×éºÏ¿òÖеÄÄÚÈÝ¡£¡¡¡¡



4¡£¡¡¡¡¡¡ÕâÀÎÒÃÇÔÚ³õʼʱûÓÐΪ×éºÏ¿òÌí¼ÓÈκÎÑ¡ÔñÏÓû§¿ÉÒÔµ¥¡¡

»÷Èçͼ6¡£54µÄ¶Ô»°¿òÖÐËùʾµÄ¡¡¡°Ìí¼ÓÑÕÉ«¡±°´Å¥Ïò×éºÏ¿òµÄÁбí¿òÖС¡

Ìí¼ÓÐÂÑÕÉ«Ïî¡£µ¥»÷¸Ã°´Å¥Ê×ÏȽ«µ¯³öÒ»¸öÑÕÉ«Ñ¡Ôñ¶Ô»°¿ò£¬Óû§Èç¡¡

¹û´ÓÑÕÉ«Ñ¡Ôñ¶Ô»°¿òÖÐÑ¡ÔñÁËÒ»ÖÖ¾ßÌåµÄÑÕÉ«£¬¸ÃÑÕÉ«½«±»Ìí¼Óµ½×é¡¡

ºÏ¿òµÄÁбí¿òÖÐÒÔ¹©Ñ¡Ôñ¡£»ùÓÚÕâ¸öÒªÇó£¬ÎÒÃÇΪ°´Å¥IDC_ADDCLRµÄ¡¡

BN_CLICKEDʼþÌí¼ÓÈçϵÄÃüÁî´¦Àí³ÉÔ±º¯ÊýOnAddClr£º¡¡¡¡



void¡¡CboDemoDlg£º£ºOnAddClr£¨£©¡¡¡¡¡¡



£û¡¡¡¡



CColorDialog¡¡dlg£¨0£»¡¡0£»¡¡this£©£»¡¡¡¡



int¡¡iRes=dlg¡£DoModal£¨£©£»¡¡¡¡



if¡¡£¨iRes==IDOK£©¡¡¡¡



£û¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡386¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

COLORREF¡¡cr=dlg¡£GetColor£¨£©£»¡¡¡¡



m_clrbo¡£AddString£¨¡¡£¨LPCTSTR£©cr¡¡£©£»¡¡¡¡



£ý¡¡¡¡



else¡¡¡¡



£û¡¡¡¡



£ý¡¡¡¡



£ý¡¡¡¡



ËäȻʹÓÃÑÕÉ«¶Ô»°¿òÔÚ±¾ÊéµÄÇ°ÃæÄÚÈÝÖÐûÓн²Êö¹ý£¬µ«¼´Ê¹ÊǶԳõ¡¡

ѧÕ߶øÑÔ£¬ÉÏÃæµÄ´úÂëÒ²ÊǷdz£Ö®¼òµ¥µÄ£¬ÎÒÃÇÕâÀï¾Í²»¹ý¶àµÄ×÷½²¡¡

½âÁË¡£¡¡¡¡



ÏÂÃæÀ´¿´ÈçºÎΪ¡¡¡°¸Ä±äÑÕÉ«¡±°´Å¥¡¡£¨IDC_CHGCLR£©Ìí¼Óµ¥»÷ÃüÁî´¦Àí³É¡¡

Ô±º¯Êý¡£ÎÒÃÇÏ£ÍûÓû§ÔÚµ¥»÷¸Ã°´Å¥Ê±£¬¸Ä±ä¾²Ì¬Îı¾¿Ø¼þ¡¡

IDC_CLRSTATICµÄÑÕÉ«ÒÔ·´Ó³Óû§ËùÑ¡ÔñµÄÑÕÉ«¡£Èç¹û¸Ä±ä¾²Ì¬Îı¾¡¡

¿Ø¼þµÄÑÕÉ«ÄØ£¿ÎÒÃÇÕâÀïʹÓÃÁ˽«¡¡×Ô»æÖƾ²Ì¬Îı¾¿Ø¼þµÄ°ì·¨¡£Õâ²¢¡¡

²»ÊÇ×î¼òµ¥µÄ·½·¨¡£×î¼òµ¥µÄ·½·¨ÊÇ´¦Àí¶Ô»°¿òµÄWM_CTLCOLORÏû¡¡

Ï¢£¬¸ÃÏûÏ¢Ôڿؼþ½«Òª±»ÖØ»æÇ°·¢Ë͸ø¸Ã¿Ø¼þµÄ¸¸´°¿Ú¡£ÕâÀïÎÒÃÇÉá¡¡

½ü¶øÇóÔ¶£¬Ö÷ÒªÊÇΪÁ˸½´ø½²ÊöÒ»ÏÂ×Ô»æÖƾ²Ì¬Îı¾¿Ø¼þµÄÓ÷¨£¬Ëü¡¡

ºÍ×Ô»æÖÆ×éºÏ¿òµÄÓ÷¨´æÔÚһЩÇø±ð¡£µ«ÊÇ£¬ÔÚ×ÊÔ´±à¼­Æ÷ÖÐÎÒÃDz»¡¡

¿ÉÒÔÉèÖÃÒ»¸ö¾²Ì¬Îı¾¿Ø¼þµÄ×Ô»æÖÆÑùʽ£¬²»¹ýÕâ²¢²»Òâ潫²»¿ÉÒÔ¡¡

ʹÓÃ×Ô»æÖƾ²Ì¬¿Ø¼þ¡£·½·¨²¢²»¸´ÔÓ¡£Ê×ÏÈ£¬Îª¾²Ì¬Îı¾¿Ø¼þÌí¼Ó×Ô¡¡

»æÖÆÑùʽ£¬½«ÏÂÃæµÄ´úÂëÌí¼Óµ½ÀàCboDemoDlgµÄOnInitDialog³É¡¡

Ô±º¯ÊýÖеÄ//¡¡TODO×¢ÊÍÖ®ºó£º¡¡¡¡



GetDlgItem£¨IDC_CLRSTATIC£©¡­¡·ModifyStyle£¨0£»¡¡SS_OWNERDRAW£©£»¡¡¡¡



ÉÏÃæµÄ´úÂ뽫¾²Ì¬Îı¾¿Ø¼þÐÞ¸ÄΪ¾ßÓÐSS_OWNERDRAWÑùʽµÄ×Ô»æÖƾ²¡¡

̬¿Ø¼þ¡£ÏÂÃæÎÒÃÇÀ´¿´ÈçºÎÔÚÐèÒªµÄʱºòÖØлæÖƾ²Ì¬Îı¾¿Ø¼þ¡¡

IDC_CLRSTATIC£¬·½·¨ÊÇÔÚÀàCboDemoDlgÖÐΪÏûÏ¢WM_DRAWITEMÌí¡¡

¼Ó´¦Àíº¯ÊýOnDrawItem£¬¶øʹÓÃClassWizardºÜÈÝÒ×°ìµ½ÕâÒ»µã¡£ÖØ¡¡

ÔØ°æ±¾µÄOnDrawItem³ÉÔ±º¯ÊýµÄ¶¨ÒåÈçÏ£º¡¡¡¡



void¡¡CboDemoDlg£º£ºOnDrawItem£¨int¡¡nIDCtl£»¡¡LPDRAWITEMSTRUCT¡¡lpDrawItemStruct£©¡¡¡¡¡¡



£û¡¡¡¡



CDialog£º£ºOnDrawItem£¨nIDCtl£»¡¡lpDrawItemStruct£©£»¡¡¡¡



if¡¡£¨nIDCtl==IDC_CLRSTATIC£©¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡387¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

£û¡¡¡¡



CDC¡¡*pDC=CDC£º£ºFromHandle£¨lpDrawItemStruct¡­¡·hDC£©£»¡¡¡¡



CBrush¡¡br£¨m_crClrStatic£©£»¡¡¡¡



CRect¡¡rc=lpDrawItemStruct¡­¡·rcItem£»¡¡¡¡



pDC¡­¡·FillRect£¨&rc£»¡¡&br£©£»¡¡¡¡



£ý¡¡¡¡



£ý¡¡¡¡



ҪʹÉÏÃæµÄ´úÂëÕý³£¹¤×÷£¬ÎÒÃÇ»¹ÐèÒªÔÚÀàCboDemoDlgÖж¨ÒåÀà¡¡

ÐÍΪCOLORREFµÄ³ÉÔ±±äÁ¿m_crClrStatic£¬¸Ã³ÉÔ±±äÁ¿±£´æÁ˾²Ì¬ÎÄ¡¡

±¾¿Ø¼þÓ¦¸Ã¾ßÓеÄÑÕÉ«¡£ÎÒÃÇ×¢Òâµ½ÁËÔÚÖØÔØ°æ±¾µÄOnDrawItem³ÉÔ±¡¡

±äÁ¿µ÷ÓÃÁË»ùÀàµÄOnDrawItem³ÉÔ±º¯Êý£¬ÕâÊDZØÒªµÄ£¬²»ÒªÍü¼ÇÔÚÎÒ¡¡

ÃǵĶԻ°¿òÖл¹ÓÐÒ»¸ö×Ô»æÖÆ×éºÏ¿ò£¬»ùÀàµÄOnDrawItem³ÉÔ±º¯Êýµ÷¡¡

ÓÃ×Ô»æÖÆ×éºÏ¿òËù¶ÔÓ¦µÄCboBoxµÄÅÉÉúÀàµÄDrawItem³ÉÔ±º¯ÊýÀ´¡¡

»æÖÆ×éºÏ¿òÖеĸ÷¸öÏî¡£¡¡¡¡



ÏÂÃæÀ´¿´ÏÂѹ°´Å¥IDC_CHGCLRµÄBN_CLICKEDʼþµÄ´¦Àíº¯Êý¡¡

OnChgClr£¬Æä´úÂëÈçÏ£º¡¡¡¡



void¡¡CboDemoDlg£º£ºOnChgClr£¨£©¡¡¡¡¡¡



£û¡¡¡¡



int¡¡nSel=m_clrbo¡£GetCurSel£¨£©£»¡¡¡¡



COLORREF¡¡cr=£¨COLORREF£©m_clrbo¡£GetItemData£¨nSel£©£»¡¡¡¡



if¡¡£¨cr£¡=¡­1£©¡¡¡¡



£û¡¡¡¡



DRAWITEMSTRUCT¡¡drawItemStruct£»¡¡¡¡



drawItemStruct¡£CtlID=IDC_CLRSTATIC£»¡¡¡¡



drawItemStruct¡£hwndItem=GetDlgItem£¨IDC_CLRSTATIC£©¡­¡·GetSafeHwnd£¨£©£»¡¡¡¡



drawItemStruct¡£hDC=£º£ºGetDC£¨drawItemStruct¡£hwndItem£©£»¡¡¡¡



GetDlgItem£¨IDC_CLRSTATIC£©¡­¡·GetClientRect£¨&£¨drawItemStruct¡£rcItem£©£©£»¡¡¡¡



m_crClrStatic=cr£»¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡388¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

OnDrawItem£¨IDC_CLRSTATIC£»¡¡&drawItemStruct£©£»¡¡¡¡



£ý¡¡¡¡



£ý¡¡¡¡



¸Ã³ÉÔ±º¯Êý½«µ±Ç°Ñ¡ÖеÄÑÕÉ«Öµ¡¡£¨Èç¹û²»ÎªCB_ERRµÄ»°£©·ÅÈë³ÉÔ±±äÁ¿¡¡

m_crClrStaticÖУ¬È»ºó¹¹ÔìÒ»¸öDRAWITEMSTRUCT½á¹¹±äÁ¿£¬²¢¶ÔËü¡¡

½øÐбØÒªµÄ³õʼ»¯£¬×îºóµ÷Óøýṹ¶ÔÏóµ÷ÓÃOnDrawItem³ÉÔ±º¯ÊýÖØ¡¡

»æ¶Ô»°¿ò¡£ÒÔºóÔÚÐèÒªÖØ»æʱ£¬OnDrawItem³ÉÔ±º¯Êý»áÓÉ¿ò¼Ü×Ô¶¯µ÷¡¡

Óᣡ¡¡¡



Õâʱ¼´¿É±à¼­²¢ÔËÐÐÉÏÃæµÄʾÀý³ÌÐòÁË£¬ÆäÔËÐнá¹ûÈçͼ6¡£56Ëùʾ¡£¡¡

µ¥»÷¡¡¡°Ìí¼ÓÑÕÉ«¡±Ïò×éºÏ¿òµÄÁбí¿òÖÐÌí¼Ó¼¸ÖÖÑÕÉ«Ñ¡ÏÔÙÀ´µ÷ÊÔ¡¡

³ÌÐòµÄ¸÷ÏÄÜÊÇ·ñÕý³£¡£»¹¿ÉÒÔ²»Í¬µÄ´°¿Ú֮ǰ½øÐÐÇл»ºÍÏ໥¸²¡¡

¸Ç»òÒÆ¿ª£¬ÒÔ¹Û²ì×Ô»æÖÆ×éºÏ¿òºÍ×Ô»æÖƾ²Ì¬Îı¾¿Ø¼þÊÇ·ñÕýÈ·µÄ»æ¡¡

ÖÆÁË×ÔÉí¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Í¼6¡£¡¡56¡¡Ê¾Àý³ÌÐòboDemoµÄÔËÐнá¹û¡¡¡¡



Ïà±È½Ï±ê×¼µÄ×éºÏ¿ò¶øÑÔ£¬×Ô»æÖÆ×éºÏ¿òÒª¸´Ôӵö࣬ÎÒÃǵÃ×Ô¼º¿¼¡¡

ÂǺܶàÌØÊâµÄÎÊÌ⣬µ«ÊÇÈçʾÀý³ÌÐòËùʾ£¬ËüµÄÈ·¿ÉÒÔʵÏÖһЩºÜÓС¡

ȤµÄÌØÐÔ£¬Òò´ËÔںܶà³ÌÐòÖеõ½¹ã·ºµÄʹÓ᣶øÕÆÎÕÁË×Ô»æÖƿؼþ¡¡

µÄʹÓ㬾ͿÉÒÔʹÄãËù±àдµÄÓ¦ÓóÌÐò½çÃæ¸ü¼ÓµÄçͷ׶à²Ê£¬µ«ÊÇ£¬¡¡

ҪעÒâÒ»ÇÐÊÂÎïµÄʹÓö¼ÓÐÒ»¸ö¡¡¡°¶È¡±£¬²»ÊÊÒ˵Ľ«Ó¦ÓóÌÐòµÄÓû§¡¡

½çÃæ×öµÃ¹ý·ÖµÄ¡¡¡°»¨Á¨ºôÉÚ¡±£¬ºÜ¶àʱºòÖ»»áÊʵÃÆä·´¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡µÚ°Ë½Ú¡¡¹ö¶¯Ìõ¿Ø¼þ¡¡¡¡



¹ö¶¯Ìõ¡¡£¨Èçͼ6¡£57Ëùʾ£©±¾ÉíÒ²¿ÉÒÔ×÷ΪһÖֿؼþ£¬Í¨³£ÎÒÃÇʹÓÃÕâÖÖ¡¡

¿Ø¼þÀ´½øÐÐÈ綨λ֮ÀàµÄ²Ù×÷¡£¹ö¶¯Ìõ¿Ø¼þ·ÖΪˮƽ¹ö¶¯ÌõºÍ´¹Ö±¹ö¡¡

¶¯ÌõÁ½ÖÖ£¬ËüÃǶÔÓ¦ÓÚControls¹¤¾ßÏäÖеÄͼ±ê·Ö±ðΪ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ºÍ¡¡¡¡¡¡¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Í¼6¡£¡¡57¡¡¹ö¶¯Ìõ¿Ø¼þ¡¡¡¡



¶ÔÓÚ¹ö¶¯Ìõ¿Ø¼þ£¬¿ÉÒÔÔÚProperties¶Ô»°¿òµÄStylesÑ¡ÏÄÚÉèÖõġ¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡389¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

ÊôÐÔÖ»ÓÐÒ»ÖÖ£º¼´AlignÊôÐÔ£¬¸ÃÊôÐÔ¿ÉÒÔΪÈýÖÖÖµÖ®Ò»£ºNone¡¢¡¡

Top/LeftºÍBottom/Right¡£ÆäÖУ¬Top/Left±íʾ½«¹ö¶¯Ìõ¿Ø¼þµÄ×óÉÏ¡¡

±ßÓëÓÉCreateWindowExº¯ÊýµÄ²ÎÊý¶¨ÒåµÄ¾ØÐεÄ×óÉϱ߶ÔÆ룬¶ø¡¡

Botton/RightÔò±íʾÒÔÓÒϱ߽øÐжÔÆë¡£¸ÃÊôÐÔµÄĬÈÏֵΪNone£¬¼´¡¡

²»½øÐÐÈκζÔÆë²Ù×÷¡£¡¡¡¡



Windows±ê×¼¹ö¶¯ÌõµÄÐÐΪÓÉMFCÀàCScrollBar·â×°¡£±íÖÐÁгöÁËÔÚÀà¡¡

CScrollBarÖж¨ÒåµÄ³ÉÔ±º¯Êý¼°Æä˵Ã÷¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡±í6¡£¡¡31¡¡ÔÚÀàCScrollBarÖж¨ÒåµÄ³ÉÔ±º¯Êý¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡³ÉÔ±º¯Êý¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÃèÊö¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CScrollBar¡¡¡¡¹¹ÔìÒ»¸öCScrollBar¶ÔÏó¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Create¡¡¡¡¡¡¡¡¡¡¡¡´´½¨Ò»¸öWindows¹ö¶¯Ìõ£¬²¢½«ËüÓë¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CScrollBar¶ÔÏóÏà¹ØÁª¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡GetScrollPos¡¡¡¡»ñµÃ¹ö¶¯ÌõµÄµ±Ç°Î»Öá¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SetScrollPos¡¡¡¡ÉèÖùö¶¯ÌõµÄµ±Ç°Î»Öá¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡GetScrollRange¡¡¡¡¡¡»ñµÃ¸ø¶¨¹ö¶¯ÌõµÄµ±Ç°×î´óºÍ×îСλÖá¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SetScrollRange¡¡¡¡¡¡ÉèÖøø¶¨¹ö¶¯ÌõµÄµ±Ç°×î´óºÍ×îСλÖá¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ShowScrollBar¡¡¡¡ÏÔʾ»òÒþ²Ø¹ö¶¯Ìõ¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡EnableScrollBar¡¡¡¡ÔÊÐí»ò½ûÖ¹¹ö¶¯ÌõÉϵÄÒ»¸ö»òÁ½¸ö¼ýÍ·¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SetScrollInfo¡¡¡¡ÉèÖùØÓÚ¹ö¶¯ÌõµÄÐÅÏ¢¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡GetScrollInfo¡¡¡¡»ñµÃ¹ö¶¯ÌõµÄÐÅÏ¢¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡GetScrollLimit¡¡¡¡¡¡»ñµÃ¹ö¶¯ÌõµÄÏÞÖÆ¡¡¡¡



µ±Óû§µ¥»÷Á˹ö¶¯Ìõʱ£¬¸¸´°¿Ú½«ÊÕµ½WM_HSCROLL»òWM_VSCROLLÏû¡¡

Ï¢£¬ÔÚCWndÀàµÄ¶¨ÒåÁË´¦Àí¸ÃÏûÏ¢µÄ³ÉÔ±º¯ÊýΪOnHScrollºÍ¡¡

OnVScroll¡£³ÉÔ±º¯ÊýOnHScrollµÄÔ­ÐÍÈçÏ£º¡¡¡¡



afx_msg¡¡void¡¡OnHScroll£¨¡¡UINT¡¡nSBCode£»¡¡UINT¡¡nPos£»¡¡CScrollBar*¡¡pScrollBar¡¡£©£»¡¡¡¡



µÚÒ»¸ö²ÎÊýnSBCodeÖ¸¶¨ÈçÏÂÖ®Ò»µÄ¹ö¶¯Ìõ´úÂ룬ÕâЩ´úÂë´ú±íÓû§¡¡

Ëù×÷µÄ¹ö¶¯ÇëÇ󣺡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡SB_LEFT£º¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ïò×ó¹ö¶¯½ÏÔ¶¾àÀë¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡390¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¡¡¡¡¡¡¡¡¡¡¡¡SB_ENDSCROLL£º¡¡¡¡¡¡½áÊø¹ö¶¯¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡SB_LINELEFT£º¡¡¡¡¡¡¡¡Ïò×ó¹ö¶¯¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡SB_LINERIGHT£º¡¡¡¡¡¡ÏòÓÒ¹ö¶¯¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡SB_PAGELEFT£º¡¡¡¡¡¡¡¡Ïò×ó¹ö¶¯Ò»Ò³¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡SB_PAGERIGHT£º¡¡¡¡¡¡ÏòÓÒ¹ö¶¯Ò»Ò³¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡SB_RIGHT£º¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏòÓÒ¹ö¶¯½ÏÔ¶¾àÀë¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡SB_THUMBPOSITION£º¡¡¡¡¹ö¶¯µ½¾ø¶ÔλÖᣵ±Ç°Î»ÖÃÓÉ¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡nPos²ÎÊýÖ¸¶¨¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡SB_THUMBTRACK£º¡¡¡¡Í϶¯¹ö¶¯Ìõµ½Ö¸¶¨µÄλÖᣵ±¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ç°Î»ÖÃÓÉnPos²ÎÊýÖ¸¶¨¡¡¡¡



ͨ³££¬SB_THUMBTRACK¹ö¶¯Ìõ´úÂëÓÉÓ¦ÓóÌÐòÊ
·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨1£© ²È£¨1£©
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿!
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾­Ñé½±Àø£¬ÈÏÕæдԭ´´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾­Ñé½±ÀøŶ£¡