Seite 3 von 3

Verfasst: 30.11.2004 11:33
von Lukaso
Hallo,

im PureBasic Examples/Advantage Examples, ist eine GUI Example, dort gibt es die MS-Office Menüs ....

MFG Lukaso

Verfasst: 30.11.2004 15:00
von nicolaus
@Danilo

Danke dir erst mal für das beispiel und du hast recht mit dem PSDK und der MSDN und ich arbeite auch viel damit (siehst du bald an ner lib von mir).

@Lukaso
sorry aber ich finde da kein beispiel in der ich den style wie bei office habe.
Was hast du denn für ne PB version?

Verfasst: 30.11.2004 16:10
von Lukaso
@nicolaus
Habs auch im Netz gefunden: http://serveurperso.com/~flype/BeatnikGUI.zip

MFG Lukaso

Verfasst: 30.11.2004 16:59
von nicolaus
Ich danke dir erst mal doch geht das wie es aussieht nich bei nem Popupmenu :cry:

Werd das halt selebr bauen denke ich mal. Danilo hat mir ja nen anfang gezeigt.

Verfasst: 30.11.2004 21:28
von nicolaus
@Danilo

Da du ja nich mit office arbeitest nen kleiner tip wo das menu auch so ist wie in office und zwar im PSDK wenn du mal in dem fensterteil wo die beschreibungen immer stehen rechte maustaste machst da kommt ein menu und genau den style versuche ich mir auch gerade für ein popupmenu zu bauen.
Hmm mal sehen wenn ich erfolgreich war werd ich das hier posten

Verfasst: 10.08.2005 16:16
von MASH
Geht es auch das man an so ein menü kleine icons mittels:

Code: Alles auswählen

SetMenuItemBitmaps_(Menu,Item,#MF_BYCOMMAND,UseImage(Image),UseImage(Image))
vorne dran heften kann?

Verfasst: 10.08.2005 20:29
von Kekskiller
Das erinnert mich daran, wie ich krampfhaft versucht hatte, einen Code im CodeArchiv so umzuarbeiten, dass ich mit ihm Menus + Icons und Hintergrund machen konnte. Das war das Resultat:

Code: Alles auswählen

Global SelFrontColor.l, SelBkColor.l 
Global NrmFrontColor.l, NrmBkColor.l
Global DisFrontColor.l, DisBkColor.l 
Global BorderImage.l, BorderWidth.l, BorderHeight.l
Global IconHeight.l, IconWidth.l
Global SeperatorFrontColor.l, SeperatorBkColor.l, SeperatorHeight.l

Global TextDegree.l

Structure MyItem
  hFont.l
  Text.s
  hIcoNrm.l
  hIcoCheck.l
  hIcoSel.l
  hIcoDis.l
EndStructure

;Je nach Anzahl der Menüeinträge dimensionieren 
Dim pmyitem.MyItem(255) 

Procedure MenuStyleCallBack(wnd, msg, wParam, lParam, result)
  fSelected = #False 
  
  If msg = #WM_MEASUREITEM 
    *lpmis.MEASUREITEMSTRUCT = lParam 
    
    If *lpmis\CtlType = #ODT_MENU
      
      hdc = GetDC_(wnd) 
      *lmyitem.MyItem = *lpmis\itemData 
      hFontOld = SelectObject_(hdc,*lmyitem\hFont) 
      GetTextExtentPoint32_(hdc,*lmyitem\Text,Len(*lmyitem\Text),@size.SIZE); 
      *lpmis\itemWidth = size\cx + IconWidth * 2
      If *lmyitem\Text = ""
        *lpmis\itemHeight = SeperatorHeight
      Else
        *lpmis\itemHeight = IconHeight;size\cy 
      EndIf
      SelectObject_(hdc,hOldFont) 
      ReleaseDC_(wnd,hdc) 
      
      ProcedureReturn  #True 
      
    EndIf
    
    
  ElseIf msg = #WM_DRAWITEM 
    *lpdis.DRAWITEMSTRUCT = lParam 
    
    If *lpdis\CtlType = #ODT_MENU
      
      *llmyitem.MyItem = *lpdis\itemData 
      hOldFont = SelectObject_(*lpdis\hdc,*llmyitem\hFont) 
      
      If *llmyitem\Text = ""
        SetTextColor_(*lpdis\hdc,SeperatorFrontColor) 
        SetBkColor_(*lpdis\hdc,SeperatorBkColor) 
        fSelected = #True 
        dwCheckXY = GetMenuCheckMarkDimensions_() 
        wCheckX = (dwCheckXY >> 16 & $FFFF) + 10 
        nTextX = wCheckX + *lpdis\rcItem\left 
        nTextY = *lpdis\rcItem\top 
        ExtTextOut_(*lpdis\hdc,nTextX,nTextY,#ETO_OPAQUE,*lpdis\rcItem,*llmyitem\Text,Len(*llmyitem\Text),0) 
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left-1,*lpdis\rcItem\top-1, BorderImage,BorderWidth,SeperatorHeight+1 ,0,0,3) 
        SelectObject_(*lpdis\hdc,hOldFont)
        
      ElseIf *lpdis\itemState & #ODS_DISABLED
        SetTextColor_(*lpdis\hdc,DisFrontColor) 
        SetBkColor_(*lpdis\hdc,DisBkColor) 
        fSelected = #True 
        dwCheckXY = GetMenuCheckMarkDimensions_() 
        wCheckX = (dwCheckXY >> 16 & $FFFF) + 10 
        nTextX = wCheckX + *lpdis\rcItem\left 
        nTextY = *lpdis\rcItem\top 
        ExtTextOut_(*lpdis\hdc,nTextX,nTextY,#ETO_OPAQUE,*lpdis\rcItem,*llmyitem\Text,Len(*llmyitem\Text),0) 
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left-1,*lpdis\rcItem\top-1, BorderImage,BorderWidth,BorderHeight ,0,0,3) 
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left+1,*lpdis\rcItem\top,*llmyitem\hIcoDis, IconWidth,IconHeight ,0,0,3) 
        SelectObject_(*lpdis\hdc,hOldFont)
        
      ElseIf *lpdis\itemState & #ODS_SELECTED 
        SetTextColor_(*lpdis\hdc,SelFrontColor) 
        SetBkColor_(*lpdis\hdc,SelBkColor) 
        fSelected = #True 
        dwCheckXY = GetMenuCheckMarkDimensions_() 
        wCheckX = (dwCheckXY >> 16 & $FFFF) + 10 
        nTextX = wCheckX + *lpdis\rcItem\left 
        nTextY = *lpdis\rcItem\top 
        ExtTextOut_(*lpdis\hdc,nTextX,nTextY,#ETO_OPAQUE,*lpdis\rcItem,*llmyitem\Text,Len(*llmyitem\Text),0) 
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left+1,*lpdis\rcItem\top,*llmyitem\hIcoSel, IconWidth,IconHeight ,0,0,3) 
        SelectObject_(*lpdis\hdc,hOldFont)
        
      ElseIf *lpdis\itemState & #ODS_CHECKED
        SetTextColor_(*lpdis\hdc,SelFrontColor) 
        SetBkColor_(*lpdis\hdc,SelBkColor) 
        fSelected = #True 
        dwCheckXY = GetMenuCheckMarkDimensions_() 
        wCheckX = (dwCheckXY >> 16 & $FFFF) + 10 
        nTextX = wCheckX + *lpdis\rcItem\left 
        nTextY = *lpdis\rcItem\top 
        ExtTextOut_(*lpdis\hdc,nTextX,nTextY,#ETO_OPAQUE,*lpdis\rcItem,*llmyitem\Text,Len(*llmyitem\Text),0) 
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left+1,*lpdis\rcItem\top,*llmyitem\hIcoCheck, IconWidth,IconHeight ,0,0,3) 
        SelectObject_(*lpdis\hdc,hOldFont)
        
      Else
        SetTextColor_(*lpdis\hdc,NrmFrontColor) 
        SetBkColor_(*lpdis\hdc,NrmBkColor) 
        dwCheckXY = GetMenuCheckMarkDimensions_() 
        wCheckX = (dwCheckXY >> 16 & $FFFF) + 10 
        nTextX = wCheckX + *lpdis\rcItem\left 
        nTextY = *lpdis\rcItem\top 
        ExtTextOut_(*lpdis\hdc,nTextX,nTextY,#ETO_OPAQUE,*lpdis\rcItem,*llmyitem\Text,Len(*llmyitem\Text),0)
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left-1,*lpdis\rcItem\top-1, BorderImage,BorderWidth,BorderHeight ,0,0,3) 
        DrawIconEx_(*lpdis\hdc,*lpdis\rcItem\left+1,*lpdis\rcItem\top,*llmyitem\hIcoNrm, IconWidth,IconHeight ,0,0,3) 
        SelectObject_(*lpdis\hdc,hOldFont) 
      EndIf 
      
      ProcedureReturn  #True 
      
    EndIf
    
  ElseIf msg = #WM_DESTROY 
    PostQuitMessage_(0)
  Else 
    ProcedureReturn result
  EndIf 
EndProcedure

Procedure StyledMenuItem(num, txt.s, hFont, hIcoNrm, hIcoCheck, hIcoSel, hIcoDis)
  MenuItem(num, txt.s)
  pmyitem(num)\hFont = hFont
  pmyitem(num)\Text = txt
  pmyitem(num)\hIcoNrm = hIcoNrm
  pmyitem(num)\hIcoCheck = hIcoCheck
  pmyitem(num)\hIcoSel = hIcoSel
  pmyitem(num)\hIcoDis = hIcoDis
  If pmyitem(num)\Text = ""
    ModifyMenu_(MenuID(), num, #MF_BYCOMMAND|#MF_OWNERDRAW|#MF_DISABLED	, num, pmyitem(num))
  Else
    ModifyMenu_(MenuID(), num, #MF_BYCOMMAND|#MF_OWNERDRAW, num, pmyitem(num))
  EndIf
EndProcedure

Procedure SetMenuBorder(borderimg, borderw, borderh)
  BorderImage = borderimg
  BorderWidth = borderw
  BorderHeight = borderh
EndProcedure

Procedure SetMenuIcon(iconw, iconh)
  IconHeight = iconh
  IconWidth = iconw
EndProcedure

Procedure SetMenuSperator(sepfront,sepback, seph)
  SeperatorHeight = seph
  SeperatorFrontColor = sepfront
  SeperatorBkColor = sepback
EndProcedure

Procedure SetMenuColor(selfront,selback, nrmfront,nrmback, disfront,disback)
  SelFrontColor = selfront
  SelBkColor = selback
  NrmFrontColor = nrmfront
  NrmBkColor = nrmback
  DisFrontColor = disfront
  DisBkColor = disback
EndProcedure
Aber meine Kenntnisse haben nicht ausgereicht. Danilos, du bis ein Spatz, *keksgeb* .