ä¸ã说æ³ä¸
Control.Refresh - does an Control.Invalidate followed by Control.Update.
Refresh: 强å¶æ§ä»¶ä½¿å
¶å·¥ä½åºæ æ并ç«å³éç»èªå·±åä»»ä½åæ§ä»¶ã==Invalidate + Update
Control.Invalidate - invalidates a specific region of the Control (defaults to entire client area) and causes a paint message to be sent to the control.Invalidate marks the control (region, or rect) as in need of repainting, but doesn't immediately repaint (the repaint is triggered when everything else has been taken care of and the app becomes idle).
Invalidate: 使æ§ä»¶çç¹å®åºå(å¯ä»¥èªå·±è®¾ç½®åºåï¼ä»èæé«æ§è½)æ æ并åæ§ä»¶åéç»å¶æ¶æ¯ã
å°æ§ä»¶æ 记为éè¦éç»ï¼ä½æ¯ä¸ä¼ç«å³æ§è¡å·æ°éç»ï¼çå°ç³»ç»ç©ºé²æ¶è¿è¡éç»ã
Control.Update - causes the Paint event to occur immediately (Windows will normally wait until there are no other messages for the window to process, before raising the Paint event).Update causes the control to immediately repaint if any portions have been invalidated.
Update: 使æ§ä»¶éç»å
¶å·¥ä½åºå
çæ æåºåï¼ç«å³è°ç¨Paintäºä»¶ãè¥ææ æåºåï¼Updateå°ç«å³è§¦åéç»ã
The paint event of course is where all the drawing of your form occurs. Note there is only one pending Paint event, if you call Invalidate 3 times, you will still only receive one Paint event.Paint: æ å¤ä¸å¨ãå¦æä½ è°ç¨3次Invalidateï¼ä½æ¯ç³»ç»å°åªè§¦åä¸æ¬¡Paintäºä»¶ã
Most of the time Invalidate is sufficient, and advisable as you can do a bunch of invalidations (either explicit or implicit) and then let the control repaint itself when the app is idle. It is advisable to use Update or Refresh when you want the control to immediately repaint because the app will not be idle for a user-noticable period of time.
大å¤æ°æ¶åInvalidateå·²ç»è¶³å¤äºï¼å½ç³»ç»è¦éä¸è¿è¡å¤§éçå·æ°éç»æ¶ï¼å»ºè®®ä½¿ç¨Invalidateï¼å 为è¿æ ·ç³»ç»æç»åªè¿è¡ä¸æ¬¡å·æ°ï¼æé«äºç³»ç»æ§è½ãå¦æä½ æ³ç«å³æ§è¡å·æ°çæ¶åï¼å»ºè®®ä½¿ç¨Refreshæ¹æ³ã
äºã说æ³äº
Refreshå Repaintæ¯ä¸æ ·ç,å®åªæ¯ç®åå°è°ç¨äºRepaint.
Updateä¼å¯¼è´æ´ä¸ªçªå£(对äºæ²¡æçªå£ç TGraphicControlæ¥è¯´,å°±æ¯å®çç¶æ§ä»¶ççªå£)ç«å³å¤çWM_PAINTæ¶æ¯,å³éç»åºè¯¥ç»çé¨å.
Invalidate使æ§ä»¶æå¨çªå£çæ§ä»¶å®¢æ·åºå(对äºTWinControlæ¥è¯´å°±æ¯å®ç客æ·åºå,对äºTGraphicControlæ¥è¯´å°±æ¯å®çç¶æ§ä»¶ççªå£å¨å®çåºåèå´å
çé¨å)失æ,ä»è产çä¸ä¸ªWM_PAINTæ¶æ¯,ä½å¹¶ä¸é©¬ä¸éç»,ç´å°å
¶å®æ¶æ¯å¤çå®æéå°ä¸ä¸ªUpdateçè°ç¨.
Repaintæ¯ç«å³éç»è¯¥æ§ä»¶,å¨TWinControlä¸å
¶å®å°±æ¯è°ç¨äºInvalidateåUpdate,å¨TGraphiControl ä¸åä¸åæ
åµä½äºä¸åå¤ç,é»è¾ç¨å¤æä¸äº,ä½åè½æ¯ä¸æ ·ç.
温馨提示:答案为网友推荐,仅供参考