delay in calling WM_DRAWITEM
-
Hi there, i hope that someone can help me with this. My application is SDI. I wroted a class derived from CListCtrl which is created with LVS_OWNERDRAWFIXED style. There is a strange behaviour when i click on a different subitem on the same selected row. It seems that it takes 800 ms till DrawItem is called. My class implements two methods: void OnLButtonDown(...) { TRACE("Start OnLButtonDown...\n"); ... CListCtrl::OnLButtonDown(nFlags, point); TRACE("End OnLButtonDown...\n"); } void DrawItem(...) { TRACE("DrawItem...\n"); ... } When i click at different rows i see in the debug window: Start OnLButtonDown DrawItem DrawItem .. .. End OnLButtonDown Meaning, DrawItem is called before OnLButtonDown() finishes. However, if i click on the same row again i see in the debug window: Start OnLButtonDown End OnLButtonDown DrawItem In that case, DrawItem is called 800 ms after OnLButtonDown finishes. Any idea?
-
Hi there, i hope that someone can help me with this. My application is SDI. I wroted a class derived from CListCtrl which is created with LVS_OWNERDRAWFIXED style. There is a strange behaviour when i click on a different subitem on the same selected row. It seems that it takes 800 ms till DrawItem is called. My class implements two methods: void OnLButtonDown(...) { TRACE("Start OnLButtonDown...\n"); ... CListCtrl::OnLButtonDown(nFlags, point); TRACE("End OnLButtonDown...\n"); } void DrawItem(...) { TRACE("DrawItem...\n"); ... } When i click at different rows i see in the debug window: Start OnLButtonDown DrawItem DrawItem .. .. End OnLButtonDown Meaning, DrawItem is called before OnLButtonDown() finishes. However, if i click on the same row again i see in the debug window: Start OnLButtonDown End OnLButtonDown DrawItem In that case, DrawItem is called 800 ms after OnLButtonDown finishes. Any idea?
Its probably due to the difference between a selection change and no change. When you click the item for the 1st time, the control sends a message to the windows owner using SendMessage(). This causes the message loop to pump and process all the messages in the queue (otherwise the thread would block) which causes any WM_DRAWITEMs in the queue to be processed. When clicking the item the second time, the selection changing messages are not sent, as there has been no selection change, so the queue is not pumped until it returns from the LButton handler. Roger Allen Sonork 100.10016 Death come early, death come late, It takes us all, there is no reason. For every purpose under heaven, To each a turn, to each a season. A time to weep and a time to sigh, A time to laugh and a time to cry, A time to be born and a time to die. Dust to dust and ashes to ashes, And so I end my song.
-
Its probably due to the difference between a selection change and no change. When you click the item for the 1st time, the control sends a message to the windows owner using SendMessage(). This causes the message loop to pump and process all the messages in the queue (otherwise the thread would block) which causes any WM_DRAWITEMs in the queue to be processed. When clicking the item the second time, the selection changing messages are not sent, as there has been no selection change, so the queue is not pumped until it returns from the LButton handler. Roger Allen Sonork 100.10016 Death come early, death come late, It takes us all, there is no reason. For every purpose under heaven, To each a turn, to each a season. A time to weep and a time to sigh, A time to laugh and a time to cry, A time to be born and a time to die. Dust to dust and ashes to ashes, And so I end my song.
Hi Roger, thanks for your reply. You explanation seems very reasonable. How would you solve that delay? I tried to force sending selection change by calling SetSelectionMark method in OnLButtonDown,but the delay stays still. I even called Update method or RedrawItems but the result is the same. What cause the sole WM_DRAWITEM event to be sent after LButton handler returns? How to solve the delay?
-
Hi Roger, thanks for your reply. You explanation seems very reasonable. How would you solve that delay? I tried to force sending selection change by calling SetSelectionMark method in OnLButtonDown,but the delay stays still. I even called Update method or RedrawItems but the result is the same. What cause the sole WM_DRAWITEM event to be sent after LButton handler returns? How to solve the delay?
I think you would need to call: RedrawItems(index, index); UpdateWindow(); To move up the WM_DRAWITEM calls. Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!
-
I think you would need to call: RedrawItems(index, index); UpdateWindow(); To move up the WM_DRAWITEM calls. Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!
Roger, the problem still exists.