Menu komplett selber zeichnen

Für allgemeine Fragen zur Programmierung mit PureBasic.
manfred
Beiträge: 8
Registriert: 26.02.2005 16:03

Menu komplett selber zeichnen

Beitrag von manfred »

Halo ,
Im Codearchiv gibt einen Quelltext , der dem Menu icons und textfarbe hinzufügt/ändert. Aller´dings bleibt der Menühintergrund gleich.
Kann mir vieleicht jemand sagen , wie das Callback aussehen muss,um das Menü komplett selber zu zeichnen?
Danke im Voraus! :mrgreen:

Hier der Codearchiv Quelltext

Code: Alles auswählen

Procedure wcb(wnd, msg, wParam, lParam) 

  If msg = #WM_MEASUREITEM 
    
    hdc = GetDC_(wnd) 
    *lpmis.MEASUREITEMSTRUCT = lParam 
    *lmyitem.MyItem = *lpmis\itemData 
    
    GetTextExtentPoint32_(hdc,*lmyitem\Text,Len(*lmyitem\Text),@size.SIZE); 
    *lpmis\itemWidth = size\cx 
    *lpmis\itemHeight = size\cy 

    ReleaseDC_(wnd,hdc) 
    ProcedureReturn  #True 
    
  ElseIf msg = #WM_DRAWITEM 
    *lpdis.DRAWITEMSTRUCT = lParam 
    *llmyitem.MyItem = *lpdis\itemData 
    dwCheckXY = GetMenuCheckMarkDimensions_() 
    wCheckX = (dwCheckXY >> 16 & $FFFF) + 10 
    nTextX = wCheckX + *lpdis\rcItem\left 
    nTextY = *lpdis\rcItem\top 
    
    If *lpdis\itemState & #ODS_SELECTED 
      

      If *lpdis\itemState & #ODS_DISABLED
        SetTextColor_(*lpdis\hdc,RGB(128,128,128)) 
      Else 
        SetTextColor_(*lpdis\hdc,RGB(255,255,255))  
      EndIf     
      
      SetBkColor_(*lpdis\hdc,SelBkColor) 
      *lpdis\rcItem\left = *lpdis\rcItem\left + nTextX -4 
      
      ExtTextOut_(*lpdis\hdc,nTextX,nTextY,#ETO_OPAQUE,*lpdis\rcItem,*llmyitem\Text,Len(*llmyitem\Text),0) 
      
      If *lpdis\itemState & #ODS_DISABLED
        *lpdis\rcItem\left = *lpdis\rcItem\left - nTextX  +4
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left,*lpdis\rcItem\top,*llmyitem\hIcoo,16,15,0,GetClassLong_(wnd,#GCL_HBRBACKGROUND) ,3)    
      Else    
        *lpdis\rcItem\left = *lpdis\rcItem\left - nTextX +4 
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left,*lpdis\rcItem\top,*llmyitem\hIco,16,15,0,GetClassLong_(wnd,#GCL_HBRBACKGROUND),3) 
      EndIf 
      
      
    Else  
      *lpdis\rcItem\left = *lpdis\rcItem\left + nTextX -4 
      If *lpdis\itemState & #ODS_DISABLED  
        SetTextColor_(*lpdis\hdc,RGB(128,128,128)) 
      Else 
        SetTextColor_(*lpdis\hdc,RGB(0,0,0)) 
      EndIf 
      
      ExtTextOut_(*lpdis\hdc,nTextX,nTextY,#ETO_OPAQUE,*lpdis\rcItem,*llmyitem\Text,Len(*llmyitem\Text),0) 
      
      *lpdis\rcItem\left = *lpdis\rcItem\left - nTextX +4 
      DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left,*lpdis\rcItem\top,*llmyitem\hIcoo,16,15,0,GetClassLong_(wnd,#GCL_HBRBACKGROUND),3) 
    EndIf 
    
    SelectObject_(*lpdis\hdc,hOldFont) 
    ProcedureReturn  #True 
    
  ElseIf msg = #WM_DESTROY 
    For i = 0 To 3 
      DeleteObject_(pmyitem(i)\hIco) 
    Next i 
    PostQuitMessage_(0) 
  Else 
    ProcedureReturn #PB_ProcessPureBasicEvents 
    
  EndIf 
EndProcedure