Pergunta

We are developing a custom grid control in VB6 (still need to use the classic VB - sorry :). It has a custom header based on the standard OS MS Header Control from ComCtl created using the corresponding WinAPI call to CreateWindowEx. The header items are owner drawn (the HDF_OWNERDRAW flag) and we need to draw them totally from scratch, but MS Header still draws this strange 3D border around every item.

It seems, this happens as a part of the standard functionality in the WindowProc when WM_PAINT is processed. But we cannot suppress WM_PAINT at all as in this case the WM_DRAWITEM message isn't sent and we have no place to draw our header items.

How to get rid of this standard 3D border drawing for our subclassed API header?

Foi útil?

Solução

We used so called owner drawn items, when just "useful contents" are drawn. But in our case, to draw the whole item from scratch, we needed the general custom drawing technique available in the MS common controls. This means we should process the NM_CUSTOMDRAW notification message.

Here is an example from the real working code (the WindowProc for the control's parent):

Select Case uMsg

Case WM_NOTIFY
   CopyMemory tNMH, ByVal lParam, LenB(tNMH)

   Select Case tNMH.Code

   Case NM_CUSTOMDRAW
      Dim tNMCD As NMCUSTOMDRAW
      CopyMemory tNMCD, ByVal lParam, Len(tNMCD)
      Select Case tNMCD.dwDrawStage
      Case CDDS_PREPAINT
         WindowProcParent = CDRF_NOTIFYITEMDRAW Or CDRF_NOTIFYPOSTPAINT ' CDDS_ITEMPREPAINT (below) will be raised for every item
         Exit Function
      Case CDDS_ITEMPREPAINT
         pDrawItem tNMCD
         WindowProcParent = CDRF_SKIPDEFAULT ' totally draw the column header by ourselves
         Exit Function
      Case CDDS_POSTPAINT
         pPostPaint
         Exit Function
      End Select
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top