Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Системное программирование и WinAPI > Отрисовка фокуса в listView


Автор: Aleksandor 18.10.2006, 09:01
какая процедура в недрах виндовз рисует выбранные элементы листвью? и как бы ее перехватить?
лист виртуальный - OnGetDispInfo не подходит так как позволяет только указать индекс в image list, но выбранное изображение все равно рисуется с синим оверлеем и штриховой линией по краям smile 
Custom Draw не работает с иконками. Если перехватить WM_LBUTTONDOWN то теряется фокус ввода.
Реально работает только 
ListView_SetExtendedListViewStyle(hwndListView,LVS_EX_BORDERSELECT) - border selection style instead of highlight,
но все равно это не совсем то что нужно  smile 

Автор: Earnest 20.10.2006, 17:37
Чтобы полностью кастомизировать рисование, поможет только OwnerDraw. Но все самому рисовать придется + перестанут работать стандартные тултипы (т.е. показ строк, которые не влезли целиком).

Можно еще попробовать через CustomDraw: перед выводом выбранного итема установить нужные параметры рисования - это если тебе только цвета или фонт поменять нужно. 

Автор: Aleksandor 20.10.2006, 20:19
Owner draw ведь не работает с иконками? кажись придется в common control dll ку внедряться smile 

owner draw попробовал с другим листом, в report view. в контроле стоит стиль подчеркивания, так он пытается даже в owner draw сам подчеркивать !  smile 

кстати интересно как там рисовать в столбцах, все на одной строке? когда header двигаю он сам текст сохраняет?

Автор: Gwendolen 21.10.2006, 05:50
Win32 Programmer's Referense:

Цитата

Drawing Without the WM_PAINT Message

Although applications carry out most drawing operations while the WM_PAINT message is processing, it is sometimes more efficient for an application to draw directly in a window without relying on the WM_PAINT message. This can be useful when the user needs immediate feedback, such as when selecting text and dragging or sizing an object. In such cases, the application usually draws while processing keyboard or mouse messages. 

To draw in a window without using a WM_PAINT message, the application uses the GetDC or GetDCEx function to retrieve a display DC for the window. With the display DC, the application can draw in the window and avoid intruding into other windows. When the application has finished drawing, it calls the ReleaseDC function to release the display DC for use by other applications. 
When drawing without using a WM_PAINT message, the application usually does not invalidate the window. Instead, it draws in such a fashion that it can easily restore the window and remove the drawing. For example, when the user selects text or an object, the application typically draws the selection by inverting whatever is already in the window. The application can remove the selection and restore the original contents of the window by simply inverting again. 

The application is responsible for carefully managing any changes it makes to the window. In particular, if an application draws a selection and an intervening WM_PAINT message occurs, the application must ensure that any drawing done during the message does not corrupt the selection. To avoid this, many applications remove the selection, carry out usual drawing operations, and then restore the selection when drawing is complete. 

Т.е. стандартные функции рисования. Рисуй в выбранной строке любые картинки.

Автор: Earnest 23.10.2006, 07:57
Цитата(Aleksandor @  20.10.2006,  21:19 Найти цитируемый пост)
Owner draw ведь не работает с иконками

Да почему? Рисуй что хошь...
Цитата(Aleksandor @  20.10.2006,  21:19 Найти цитируемый пост)
кстати интересно как там рисовать в столбцах, все на одной строке? 

Да, WM_DRAWITEM приходит для всей строки, разбор по колонкам - твое дело.
Цитата(Aleksandor @  20.10.2006,  21:19 Найти цитируемый пост)
когда header двигаю он сам текст сохраняет? 

Нет, просто происходит перерисовка, и опять ты сам все рисуешь.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)