الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

إدراج صورة في قائمة

مغلق
بدأه hanysaad في 10 أغسطس 2005 · 5 رد · 783 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

كود جميل لإدراج صورة في قائمة

Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 Command Button And 2 Picture Boxes to your form.
'Set Picture Boxes AutoSize property to True. Add pictures to the Picture Boxes.
'When the menu will be enabled, the picture in Picture1 will be displayed near him.
'When the menu will be disabled, the picture in Picture2 will be displayed near him.
'The pictures should not be bigger than 13x13.
'Add menu to your form, Add 1 sub menu to the menu and name it MyMenu.
'When you run this program, press on the button to enable\disable menu.
'Insert this code to the module :

Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal _
nPos As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal _
nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal _
nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal _
hBitmapChecked As Long) As Long
Private Const MF_BITMAP = &H4&

'Insert this code to your form:

Private Sub Command1_Click()
MyMenu.Enabled = Not MyMenu.Enabled
End Sub

Private Sub Form_Load()
'Replace 'Form1' with the name of your form
hMenu& = GetMenu(Form1.hWnd)
'Replace '0' with the menu position. '0' means the first menu from left.
'If it was the second from left, you should been place there '1'.
hSubMenu& = GetSubMenu(hMenu&, 0)
'Replace '0' with the sub menu position. '0' means the upper sub menu.
'If it was the second from top, you should been place there '1'.
hID& = GetMenuItemID(hSubMenu&, 0)
SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, Picture1.Picture, Picture2.Picture
End Sub

Hany Saad Mostafa

ITI (Information Technology Institute) l

SD Dept.-Teaching Assistant

---

اسألكم الدعاء بظهر الغيب

#2

اخ هاني انا جربت المثال لكن يظهر لي error في GetMenu في الفورم لود ولا اعرف السبب هل من الممكن ان تساعدني فيه

من تواضع لله رفعه

#3

في الجزء الموجود في الموديول حول القيم private الي public

و اضف menu و اعطها الاسم MyMenu اضف اليها قائمتين فرعيتين...عندها ستظهر الصور من picture box الى القائمتين الموجودتين في Mymenu

من قال لا إله إلا الله صادقا دخل الجنة

موقعي للتعارف و تبادل الأخبار http://www.xybond.com

#4

مشكور اخ هشام لم انتبه لهذا الخطأ

من تواضع لله رفعه

#5

مشكور أخي hanysaad على هذا الكود

ولكن أخي عند سؤال فرضًا لو كان عندي قائمتين ملف و تحرير

ويوجد في قائمة ملف : جديد ، فتح ، حفظ ، إنهاء

ويوجد في قائمة تحرير : قص ، نسخ ، لصق

كيف أستخدم الكود السابق في عرض الصور في هذه القوائم

علم أنني حاول ولكن لم أوفق..

وأكرر شكري لك..

#6

السلام عليكم

الاخ hussein2005

شكرا على متابعتك

الاخ hishamnasr

شكرا على المتابعة والرد

الاخ ail_fahad777

اولا شكرا لك على المتابعة

بالنسبة لسؤالك ارجو ان تراجع السطور الاتية فى الكود فى الحدث Private Sub Form_Load()

و اقرأ الملاحظات جيدا

'Replace '0' with the menu position. '0' means the first menu from left.
'If it was the second from left, you should been place there '1'.
hSubMenu& = GetSubMenu(hMenu&, 0)
'Replace '0' with the sub menu position. '0' means the upper sub menu.
'If it was the second from top, you should been place there '1'.
hID& = GetMenuItemID(hSubMenu&, 0)

Hany Saad Mostafa

ITI (Information Technology Institute) l

SD Dept.-Teaching Assistant

---

اسألكم الدعاء بظهر الغيب

هذا الموضوع مغلق.

مواضيع مشابهة