Flickering List View

I created list view using win API CreateWindowEx. The List View is flickering too much and its processing is too slow (when moving using the arrow keys) although I am using double buffering in its eXstyle.

Below is a part of the code showing the styles and the creation of the ListView:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
HWND BsolListView::BsolLvCreate (BsolWindow * prntWnd_p) {
	DWORD style_v, styleEx_v;
	int X_v, Y_v, W_v, H_v, ctrlId_v;

	X_v = this->LvClass.X;
	Y_v = this->LvClass.Y;
	W_v = this->LvClass.width;
	H_v = this->LvClass.hight;
	ctrlId_v = this->LvClass.ctrlId;

	styleEx_v = LVS_EX_FULLROWSELECT 
		  | LVS_EX_DOUBLEBUFFER 
		  | LVS_EX_LABELTIP
		  | LVS_EX_INFOTIP
//		  | LVS_EX_GRIDLINES
//		  | LVS_EX_SUBITEMIMAGES
//		  | LVS_EX_ONECLICKACTIVATE
//		  | LVS_EX_TWOCLICKACTIVATE
//		  | LVS_EX_BORDERSELECT
//		  | LVS_EX_TRACKSELECT
//		  | LVS_EX_TRANSPARENTBKGND // see WM_PRINTCLIENT
		  ;
	style_v = WS_CHILD 
//		| WS_SIZEBOX 
//		| WS_SYSMENU 
		| WS_BORDER 
//		| WS_CAPTION 
		| LVS_OWNERDATA 
		| LVS_EDITLABELS 
		| LVS_REPORT
//		| LVS_EX_GRIDLINES
		;

	this->LvWnd = CreateWindowEx(NULL, WC_LISTVIEW, TEXT("List Of Values"),
				  style_v, X_v, Y_v, W_v, H_v, 
				  prntWnd_p->BsolGetWndHandle(), 
				 (HMENU)ctrlId_v, prntWnd_p->BsolGetInstance(), 
				  NULL);

	lvOriginWndProc_g = (WNDPROC)SetWindowLong (this->LvWnd, GWL_WNDPROC, 
						(long)BsolListViewProcedure);

	ListView_SetExtendedListViewStyle (this->LvWnd, styleEx_v);

	INITCOMMONCONTROLSEX icex;
	
	icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
	icex.dwICC = ICC_STANDARD_CLASSES 
		   | ICC_COOL_CLASSES 
		   | ICC_LISTVIEW_CLASSES
		   ;

	// Initialize ListView Columns
	this->BsolLvInitColumns();

	ListView_SetItemCountEx (this->LvWnd, this->LvClass.extra2, 
				LVSICF_NOINVALIDATEALL);

	ShowWindow (this->LvWnd, SW_SHOW);

	return this->LvWnd;
}


Code of BsolLvInitColumns:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
long BsolListView::BsolLvInitColumns () {
	WCHAR szText[256];     // Temporary buffer.
	int iCol;

	// Initialize the LVCOLUMN structure.
	// The mask specifies that the format, width, text,
	// and subitem members of the structure are valid.
	this->LvColumn.mask = LVCF_FMT 
			    | LVCF_WIDTH 
			    | LVCF_TEXT 
			    | LVCF_SUBITEM
			    ;

	// Add the columns.
	for (iCol = 0; iCol < this->LvNumCol; iCol++) {
		this->LvColumn.iSubItem = iCol;
		this->LvColumn.pszText = szText;
		this->LvColumn.cx = 100;               // Width of column in pixels.

		if ( iCol < 2 )
			this->LvColumn.fmt = LVCFMT_LEFT;  // Left-aligned column.
		else
			this->LvColumn.fmt = LVCFMT_RIGHT; // Right-aligned column.

		// Load the names of the column headings from the string resources.
		LoadString(NULL, //eArgs_p->ehIns,
				   2650 + iCol,
				   szText,
				   sizeof(szText)/sizeof(szText[0]));

		// Insert the columns into the list view.
		if (ListView_InsertColumn(this->LvWnd, iCol, &this->LvColumn) == -1)
			return FALSE;
	}

	return 1;
}


I hope I am clear enough.
Best Regards,
Ahmad
hey.. any update on this issue? what can I do for the flickering List View..
Any ideas?

Thanks..
Try using NULL for the Background Brush when registering your parent window's class.
EssGeEich:

I am using (HBRUSH)(COLOR_WINDOW), when I used the NULL as you suggested, all the colors in thew window client area turned to be white as well as the performance of the List View is still slow (upon using the arrow keys or keyboard)..

Any further suggestions?

Regards,
Ahmad
Topic archived. No new replies allowed.