PDA

View Full Version : سوال: رنگ منو



paysokhan
شنبه 12 بهمن 1387, 01:06 صبح
آیا رنگ منو را می توان تغییر داد؟
چطوری؟

paysokhan
شنبه 12 بهمن 1387, 14:18 عصر
اساتید محترم جواب سوال ما را مرحمت نمی کنید؟

sh2007
شنبه 12 بهمن 1387, 14:30 عصر
دوست من سلام
رنگ منو رو نمي شه تغيير داد چون استاندارد خود ويندوزه وقتي روي دسكتاپ راست كليك و پروپرتيز را بزني و اپيرنس را نتخاب كني مي تواني تمام پنجره هاي ويندوز و منو رو تغيير داد البته براي منو كنترل هاي مختلفي ساخته شده كه توي بخش اكتيو ايكس هست جستجو كن مي بيني

aidin-joon
دوشنبه 14 بهمن 1387, 14:49 عصر
سلام دوست من با اين كد رنگ منو رو ميشه تغيير داد و اگر هم خواستيد رنگشو دستكاري كنيد عبارت vbred رو تغيير بديد.
Option Explicit
'************************************************* *****************************
'Required API call declarations
'************************************************* *****************************
'CreateBrushIndirect is used to create the background brush for the menus
Private Declare Function CreateBrushIndirect Lib "gdi32" (lpLogBrush As LOGBRUSH) As Long
'GetMenu is used to get the handle to the menus
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
'GetMenuInfo is used to get the current info for the menu (so we don't change anything we shouldn't by mistake)
Private Declare Function GetMenuInfo Lib "user32" (ByVal hMenu As Long, lpcmi As tagMENUINFO) As Long
'SetMenuInfo is used to set the background brush back to the menu and all sub-menus
Private Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long, lpcmi As tagMENUINFO) As Long
'************************************************* *****************************
'Required API Type Definitions
'************************************************* *****************************
'Used in the Calls to CreateBrushIndirect
Private Type LOGBRUSH
lbStyle As Long 'Style type (we only need to create a solid background for this example)
lbColor As Long 'Set the color of the brush
lbHatch As Long 'Hatch style (not used in this example because it's ignored for Solid style)
End Type
'Used in GetMenuInfo and SetMenuInfo calls
Private Type tagMENUINFO
cbSize As Long 'The size of the type structure (use len to calculate)
fMask As Long 'Mask of information/Actions to process
dwStyle As Long 'Menu Style (not used in this example)
cyMax As Long 'Maximum height of menu in pixels (not used in this example)
hbrBack As Long 'Handle to background brush
dwContextHelpID As Long 'Help Context ID (not used in this example)
dwMenuData As Long 'Menu Data (again not used in this example)
End Type
'************************************************* *****************************
'API Constant declarations
'************************************************* *****************************
Private Const BS_SOLID = 0 'Solid style for brush
Private Const MIM_APPLYTOSUBMENUS = &H80000000 'Apply to Sub-Menus Mask
Private Const MIM_BACKGROUND = &H2 'Background Mask
Private Sub Form_Load()
Dim ret As Long 'Variable to hold return values from GetMenuInfo and SetMenuInfo
Dim hMenu As Long 'Variable to hold the handle to the menu
Dim hBrush As Long 'Variable to hold the handle to the background brush we are going to create
Dim lbBrushInfo As LOGBRUSH 'Variable to hold the information to pass to the CreateBrushIndirect API
Dim miMenuInfo As tagMENUINFO 'Variable to hold the menu info
lbBrushInfo.lbStyle = BS_SOLID 'Set our brush type to solid
lbBrushInfo.lbColor = vbRed 'Here we set our brush color
lbBrushInfo.lbHatch = 0 'This value is ignored I set it to 0 to make sure nothing weird will happen
hBrush = CreateBrushIndirect(lbBrushInfo) 'We create our brush
hMenu = GetMenu(Me.hwnd) 'Get the handle to the menu that we are modifying (note we pass the form's hWnd because it is the owner of the menu)
miMenuInfo.cbSize = Len(miMenuInfo) 'Set the MenuInfo structure size so that we don't get errors
ret = GetMenuInfo(hMenu, miMenuInfo) 'Go and get the actual menu info should return non-zero if successful
miMenuInfo.fMask = MIM_APPLYTOSUBMENUS Or MIM_BACKGROUND 'Set the mask for the changes (changing the background for menu and all sub-menus)
miMenuInfo.hbrBack = hBrush 'Assign our brush to the menu info
ret = SetMenuInfo(hMenu, miMenuInfo) 'Write our info back to the menu and we're done. (should return non-zero if successful)
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then 'Check to see if it is the right mouse button
Me.PopupMenu mnuMenu 'Bring up pop-up menu to test
End If
End Sub

paysokhan
سه شنبه 15 بهمن 1387, 01:37 صبح
قربان شما دستت درد نکنه
انشاالله بتونم جبران کنم