Thema: Delphi Menu Hintergrundbild

Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#5

AW: Menu Hintergrundbild

  Alt 30. Aug 2016, 06:45
Jetzt geht's soweit muss nur noch etwas an den Ausmaßen des Hintergrundbild feilschen.

Ich kopiere jetzt den Hintergrund so wie von himitsu vorgeschlagen in die Items.

Vorschau (Von meine Server da die Bilder hier schlecht sind nach dem Upload)
Inklusive Transparenten (kann man ausschalten) Menu Ownerdraw.

Zitat:
damit den Bildausschnitt berechnen
Muss ich noch machen noch nicht exakt.

Der ganze Kram..
Delphi-Quellcode:
{$REGION 'WM_DRAWITEM'}
    WM_DRAWITEM:
      begin
        PDis := Pointer(lP);
        case PDis^.CtlType of
          ODT_MENU: // 1 Ownerdrawn menu item
            begin
              hMenuWnd := WindowFromDC(PDis.HDC);

              if (IsWindow(hMenuWnd)) then
              begin
                if OnTransMenu then
                begin
                  if ckAeroBlur.GetCheckButtonStatus(ckAeroBlur.Handle)
                    or ckCrystal.GetCheckButtonStatus(ckCrystal.Handle) then
                    if trbGlassOpacity.GetTrackValue(trbGlassOpacity.Handle) >= 128 then
                      SKAERO_SetLayeredAlpha
                        (hMenuWnd, trbGlassOpacity.GetTrackValue(trbGlassOpacity.Handle))
                    else
                      SKAERO_SetLayeredAlpha(hMenuWnd, 128);
                end
                else
                  SKAERO_SetLayeredAlpha(hMenuWnd, 255)
              end;

              if hSubSkinMenu = PDis.ItemId then
                PDis.ItemId := IDM_Skin;

              GDIP_DisposeImage(Img);
              GDIP_DisposeImage(ImgItem);
              Img := 0;
              ImgItem := 0;

              SetBkMode(PDis.HDC, OPAQUE);

              Txt := PWideChar(GetMenuTxt(PDis.ItemId, Img, ImgItem, ImgSep));

              // Create Graphics
              if GDIP_CreateFromHDC(PDis.HDC, Graphics) = 0 then
              begin
                // DrawButton
                if (PDis.itemState and ODS_SELECTED) <> 0 then
                  SKAERO_PaintButton(Graphics, 3, ImgItem, PDis.rcItem.Left, PDis.rcItem.Top,
                    PDis.rcItem.Right, 20, BS_PUSHBUTTON)
                else
                begin
                  ImgBack := Cardinal(SKAERO_GetProperty(WinHandle, FORM_Center));

                  GetClientRect(hMenuWnd, Rect);
                  GDIP_GetImageSize(ImgBack, imgW, imgH);
                  GDIP_SetInterpolationMode(Graphics, InterpolationModeHighQualityBicubic);
                  //GDIP_DrawImageRectRectI(Graphics, ImgBack, PDis.rcItem.Left, PDis.rcItem.Top,
                  // PDis.rcItem.Right, Rect.Bottom, 0, PDis.rcItem.Top, imgW, imgH , 2, nil, False, nil);

                  GDIP_DrawImageRectRectI(Graphics, ImgBack, PDis.rcItem.Left, PDis.rcItem.Top,
                    PDis.rcItem.Right, 20, 0, PDis.rcItem.Top, imgW, 20 , 2, nil, False, nil);

                  if (PDis.ItemId = IDM_SeperatorFiles) or (PDis.ItemId = IDM_SeperatorPList)
                    or (PDis.ItemId = IDM_SeperatorSkins) or
                    (PDis.ItemId = IDM_SeperatorClose) then
                  SKAERO_PaintButton(Graphics, 4, ImgItem, PDis.rcItem.Left, PDis.rcItem.Top,
                    PDis.rcItem.Right, 20, BS_PUSHBUTTON)
                end;

                // DrawText
                GDIP_GetImageSize(Img, imgW, imgH);
                if not(PDis.ItemId = IDM_SeperatorFiles) and not(PDis.ItemId = IDM_SeperatorPList)
                  and not(PDis.ItemId = IDM_SeperatorSkins) and not
                  (PDis.ItemId = IDM_SeperatorClose) then
                begin
                  PDis.rcItem.Left := 18;
                  PDis.rcItem.Top := PDis.rcItem.Top + 2;
                  GDIP_DrawTextToDC(PDis.HDC, Txt, PDis.rcItem, SKAERO_INACTIVECAPTION, PWideChar
                      (SKAERO_TEXTFONT), SKAERO_PUSHBUTFONTSIZE, FontStyleBoldItalic, -1, 0);
                end
                else
                begin
                  PDis.rcItem.Left := 0;
                  PDis.rcItem.Top := PDis.rcItem.Top + 2;
                  GDIP_DrawTextToDC(PDis.HDC, Txt, PDis.rcItem, SKAERO_ACTIVECAPTION, PWideChar
                      (SKAERO_TEXTFONT), SKAERO_PUSHBUTFONTSIZE, FontStyleBoldItalic, -1, 0);
                end;

                PDis.rcItem.Left := 0;

                case PDis.ItemId of
                  IDM_WMPPRESET .. IDM_WMPPRESET_LAST:
                    begin
                      newItem := WMPVisPreset[PlgSelectedPreset];
                      if Txt = newItem then
                      begin
                        imgW := imgW div 2;
                        GDIP_DrawImageRectRectI
                          (Graphics, Img, PDis.rcItem.Left + 3, PDis.rcItem.Top + 2, imgW, imgH,
                          imgW, 0, imgW, imgH, 2, nil, False, nil);

                        GDIP_DisposeImage(Img);
                      end
                      else
                      begin
                        if (PDis.ItemId >= IDM_WMPPRESET) and (PDis.ItemId <= IDM_WMPPRESET_LAST)
                          then
                          imgW := imgW div 2;
                          GDIP_DrawImageRectRectI
                            (Graphics, Img, PDis.rcItem.Left + 3, PDis.rcItem.Top + 2, imgW, imgH, 0,
                            0, imgW, imgH, 2, nil, False, nil);

                        GDIP_DisposeImage(Img);
                      end;
                    end;
                  IDM_AMPMODULE .. IDM_AMPMODULE_LAST:
                    begin
                      newItem := AmpVisPreset[PlgSelectedModule];
                      if Txt = newItem then
                      begin
                        imgW := imgW div 2;
                        GDIP_DrawImageRectRectI
                          (Graphics, Img, PDis.rcItem.Left + 3, PDis.rcItem.Top + 2, imgW, imgH,
                          imgW, 0, imgW, imgH, 2, nil, False, nil);

                        GDIP_DisposeImage(Img);
                      end
                      else
                      begin
                        if (PDis.ItemId >= IDM_AMPMODULE) and (PDis.ItemId <= IDM_AMPMODULE_LAST)
                          then
                          imgW := imgW div 2;
                          GDIP_DrawImageRectRectI
                            (Graphics, Img, PDis.rcItem.Left + 3, PDis.rcItem.Top + 2, imgW, imgH, 0,
                            0, imgW, imgH, 2, nil, False, nil);

                        GDIP_DisposeImage(Img);
                      end;
                    end;
                  IDM_SKINS .. IDM_SKINS_LAST:
                    begin
                      newItem := SkinList[ActiveSkin];
                      if Txt = newItem then
                      begin
                        imgW := imgW div 2;
                        GDIP_DrawImageRectRectI
                          (Graphics, Img, PDis.rcItem.Left + 3, PDis.rcItem.Top + 2, imgW, imgH,
                          imgW, 0, imgW, imgH, 2, nil, False, nil);

                        GDIP_DisposeImage(Img);
                      end
                      else
                      begin
                        if (PDis.ItemId >= IDM_SKINS) and (PDis.ItemId <= IDM_SKINS_LAST) then
                          imgW := imgW div 2;
                          GDIP_DrawImageRectRectI
                            (Graphics, Img, PDis.rcItem.Left + 3, PDis.rcItem.Top + 2, imgW, imgH, 0,
                            0, imgW, imgH, 2, nil, False, nil);

                        GDIP_DisposeImage(Img);
                      end;
                      PDis.rcItem.Left := 0;
                    end;
                else
                  begin
                    GDIP_GetImageSize(Img, imgW, imgH);
                    GDIP_DrawImageRectRectI(Graphics, Img, PDis.rcItem.Left + 3, PDis.rcItem.Top,
                      imgW, imgH, 0, 0, imgW, imgH, 2, nil, False, nil);
                  end;
                end;
                GDIP_DeleteGraphics(Graphics);
              end;
              Result := 1;
              exit;
            end;
          ODT_LISTBOX:
            begin
              Result := 1;
              exit;
            end;
        end;
      end;
{$ENDREGION}
gruss

Geändert von EWeiss (30. Aug 2016 um 06:54 Uhr)
  Mit Zitat antworten Zitat