0
我編寫我的第一個GUI程序只使用純WinAPI程序。但是我遇到了一些奇怪的問題。ListView滾動條閃爍
表單上有2個ListView元素用於輸出一些值。當第二個ListView上出現滾動條時,窗體上的所有子對象消失。該ListView的滾動條閃爍。當我推動ListView時,所有的東西都恢復正常了。我不知道該怎麼辦。
但是,此問題僅適用於窗體上的第二個ListView元素hListViewCh。第一個元素沒有問題。
下面是代碼:
case WM_CREATE:
{
GetClientRect(hWnd, &Rect);
h_Chk1 = CreateWindow(TEXT("button"), TEXT("Graphic"),
WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
Rect.right - 550,
300 + 10,
100,
20,
hWnd, (HMENU)0xCB01, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
h_Chk2 = CreateWindow(TEXT("button"), TEXT("Diagram"),
WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
Rect.right - 550,
300 + 35,
100,
20,
hWnd, (HMENU)0xCB02, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
CheckDlgButton(hWnd, 0xCB01, BST_UNCHECKED);
CheckDlgButton(hWnd, 0xCB02, BST_UNCHECKED);
hListViewCh = CreateWindow(
WC_LISTVIEW,
_T("MyList"),
LVS_REPORT|WS_CHILD|WS_VISIBLE,
Rect.right - 265,
377,
250,
200,
hWnd, (HMENU)listViewCh, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
//--
LVCOLUMN lvColumn = {0};
lvColumn.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT;
lvColumn.fmt = LVCFMT_CENTER;
lvColumn.pszText = "№";
lvColumn.cx = 30;
ListView_InsertColumn(hListViewCh, 0, &lvColumn);
lvColumn.pszText = "Property";
lvColumn.cx = 70;
ListView_InsertColumn(hListViewCh, 1, &lvColumn);
lvColumn.pszText = "Value";
lvColumn.cx = 120;
ListView_InsertColumn(hListViewCh, 2, &lvColumn);
//--
hListView = CreateWindow(
WC_LISTVIEW,
_T("Set of variate values"),
LVS_REPORT|WS_CHILD|WS_VISIBLE,
Rect.right - 550,
Rect.top + 15,
535,
275,
hWnd,
(HMENU)listView,
(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
NULL);
//--
lvColumn.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT;
lvColumn.pszText = "No";
lvColumn.fmt = LVCFMT_CENTER;
lvColumn.cx = 43;
ListView_InsertColumn(hListView, 0, &lvColumn);
//--
lvColumn.pszText = "[ a[i-1] , a[i])";
lvColumn.cx = 151;
ListView_InsertColumn(hListView, 1, &lvColumn);
//--
lvColumn.pszText = "xi";
lvColumn.cx = 85;
ListView_InsertColumn(hListView, 2, &lvColumn);
//--
lvColumn.pszText = "ni";
ListView_InsertColumn(hListView, 3, &lvColumn);
//--
lvColumn.pszText = "V";
ListView_InsertColumn(hListView, 4, &lvColumn);
//--
lvColumn.pszText = "EV";
ListView_InsertColumn(hListView, 5, &lvColumn);
break;
}
有一些重繪功能WM_PAINT使列表視圖與移動窗口最大化。
//-- LISTVIEW POSITION
SetWindowPos(hListViewCh, NULL,\
Rect.right - 265,
312,
250,
200,
SWP_NOSIZE);
//-- LISTVIEW POSITION
SetWindowPos(hListView, NULL,\
Rect.right - 550,\
Rect.top + 15,\
535,\
340,\
SWP_NOSIZE|SWP_NOZORDER);
//--
或對WM_SIZE – 2011-06-01 15:31:48
@adrian的迴應如果您選擇該路線,則還需要處理WM_MOVE。 – 2011-06-01 15:45:44
我試過按照你說的去做,但它沒有幫助 - 每次重繪後滾動閃爍。 – Anonymous 2011-06-01 16:38:14