![]() |
|
تلوين MainMenu أو PopMenu - نسخة قابلة للطباعة +- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum) +-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3) +--- قسم : مصادر دلفي مفتوحة تعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=14) +--- الموضوع : تلوين MainMenu أو PopMenu (/showthread.php?tid=3263) |
تلوين MainMenu أو PopMenu - paix144 - 04-07-2011 السلام عليكم و رحمة الله تلوين MainMenu أو PopMenu كود : uses ShellAPI;و في الحدث OnAdvancedDrawItem كود : procedure TForm1.Mmelesbarressontdessines1AdvancedDrawItem(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
var ClrF, ClrT, ClrSelF, ClrSelT: TColor;
Txt: String;
X, Y: Integer;
DecalTexte: Boolean;
begin
//Le caption de l'item est décalé selon la valeur de cette variable
DecalTexte := False;
//Couleurs à appliquer
ClrF := ColorBox1.Selected;
ClrT := ColorBox2.Selected;
ClrSelF := ColorBox3.Selected;
ClrSelT := ColorBox4.Selected;
//on récupère le texte de l'item
Txt := TMenuItem(Sender).Caption;
//Si le tag est à 1, on a affaire à un Item d'un menu et non au "titre" d'un menu
//Les tags des items ont été mis à 1 à la main avec l'inspecteur d'objet
If TMenuItem(Sender).Tag = 1 then
begin
//Si l'item est actuellement sélectionné on dessine avec les couleurs choisies
//pour la sélection
If odSelected in State then
begin
ACanvas.Brush.Color := ClrSelF;
ACanvas.FillRect(ARect);
ACanvas.Font.Color := ClrSelT;
end
//sinon avec les couleurs choisies pour un état "normal"
else
begin
ACanvas.Brush.Color := ClrF;
ACanvas.FillRect(ARect);
ACanvas.Font.Color := ClrT;
end;
end
else
//S'il ne s'agit pas d'un sous-item mais d'un item "racine" d'un menu
begin
//S'il est sélectionné
If odSelected in State then
begin
//Propriétés de couleur de la brosse et du pinceau
ACanvas.Brush.Color := ClrF;
ACanvas.Font.Color := ClrT;
//Dessin du fond de l'item
ACanvas.FillRect(ARect);
//J'ai fait cette application sous Windwos 98
//Ses quelques lignes donnent donc un style Win98 au menu mais il suffit de
//les commenter ou dechanger deux trois détails pour donner le style que l'on veut :)
ACanvas.Pen.Color := clBtnShadow;
ACanvas.Rectangle(ARect);
ACanvas.Pen.Color := clBtnHighlight;
ACanvas.MoveTo(ARect.Left, ARect.Bottom - 1);
ACanvas.LineTo(ARect.Right - 1, ARect.Bottom - 1);
ACanvas.LineTo(ARect.Right - 1, ARect.Top);
//Le caption sera décalé pour faire ressortir le menu
DecalTexte := True;
end
else
//S'il n'est pas sélectionné on dessiner juste le fond
begin
ACanvas.Brush.Color := ClrF;
ACanvas.FillRect(ARect);
ACanvas.Font.Color := ClrT;
end;
end;
//Si on n'est pas en présence d'un spérateur
If Txt <> '-' then
begin
//Pour dessiner du texte sans fond
ACanvas.Brush.Style := bsClear;
X := ARect.Left + 7;
Y := ARect.Top;
//Si l'item est sélectionné, le texte est décalé d'un pixel
If DecalTexte then
begin
Inc(X);
Inc(Y);
end;
//Dessin du Caption de l'item
ACanvas.TextOut(X, Y, Txt);
end
else
//S'il s'agit d'un séparateur, on dessine les deux lignes qui le matérialisent
begin
ACanvas.Brush.Color := ClrF;
ACanvas.FillRect(ARect);
ACanvas.Pen.Color := clBtnShadow;
X := ARect.Left + 2;
Y := ARect.Top + (Arect.Bottom - ARect.Top)div 2;
ACanvas.MoveTo(X, Y);
X := ARect.Left + (ARect.Right - ARect.Left) - 2;
ACanvas.LineTo(X, Y);
ACanvas.Pen.Color := clBtnHighlight;
X := ARect.Left + 2;
Inc(Y);
ACanvas.MoveTo(X, Y);
X := ARect.Left + (ARect.Right - ARect.Left) - 2;
ACanvas.LineTo(X, Y);
end;
end;تلوين MainMenu أو PopMenu - ELARAPY - 04-07-2011 [COLOR="Purple"]بارك الله فيك اخي ينقصني فهم معاني الاكواد كي لا اكون من المقلدين فانا اود ان اتخلص من Copy & Past بارك الله فيك[/COLOR] تلوين MainMenu أو PopMenu - paix144 - 05-07-2011 و فيكم بارك الله هل تفهم اللغة الفرنسية أخي؟ الكود معلق بهذه اللغة تلوين MainMenu أو PopMenu - ELARAPY - 06-07-2011 [color="purple"]للاسف لا افهم اي لغة الا العربيه وكانت الانجليزيه منذ اكثر من 15 سنه ولكن رحمها الله [/color] تلوين MainMenu أو PopMenu - cargem - 06-07-2011 ارفق المثال او صورة للنتيجة لو تكرمت تلوين MainMenu أو PopMenu - paix144 - 06-07-2011 السلام عليكم و رحمة الله قم بتعديل Proptiétés للMainMenu كما يلي كود : MainMenu1.AutoHotkeys:=maManual;
MainMenu1.OwnerDraw:=True;و المثال في المرفقات وفقكم الله |