[ n1tr0 @ 12.05.2005. 17:49 ] @
Kako da kada napravim meni u VB.NET-u ubacim i slike pored opcija na meniju npr. pored File da bude slika za list,pored save da bude npr. disketa ili slicno?!? |
[ n1tr0 @ 12.05.2005. 17:49 ] @
[ NeznamTkoSam @ 12.05.2005. 18:58 ] @
Code: I pogledaj www.codeproject.comImports System Imports System.Drawing Imports System.Windows.Forms Imports System.Runtime.InteropServices Public Class MainForm Inherits System.Windows.Forms.Form Private mnuSave As System.Windows.Forms.MenuItem Private mnuSep1 As System.Windows.Forms.MenuItem Private mnuMain As System.Windows.Forms.MainMenu Private mnuExit As System.Windows.Forms.MenuItem Private mnuFile As System.Windows.Forms.MenuItem Private mnuOpen As System.Windows.Forms.MenuItem <DllImport("user32.dll")> _ Public Shared Function GetMenu(ByVal hwnd As IntPtr) As IntPtr End Function <DllImport("user32.dll")> _ Public Shared Function GetSubMenu(ByVal hMenu As IntPtr, ByVal nPos As Integer) As IntPtr End Function <DllImport("user32.dll")> _ Public Shared Function GetMenuItemID(ByVal hMenu As IntPtr, ByVal nPos As Integer) As IntPtr End Function <DllImport("user32.dll")> _ Public Shared Function SetMenuItemBitmaps(ByVal hMenu As IntPtr, ByVal nPosition As IntPtr, ByVal wFlags As Integer, ByVal hBitmapUnchecked As IntPtr, ByVal hBitmapChecked As IntPtr) As Integer End Function Public Sub SetImage(ByVal mnu As MenuItem, ByVal bmp As Bitmap) Dim ptrMenu As IntPtr = GetMenu(Me.Handle) Dim ptrSubMenu As IntPtr = GetSubMenu(ptrMenu, 0) Dim ptrID As IntPtr = GetMenuItemID(ptrSubMenu, 0) bmp.MakeTransparent(bmp.GetPixel(1, 1)) Dim hBmp As IntPtr = bmp.GetHbitmap SetMenuItemBitmaps(ptrMenu, ptrID, 0, hBmp, hBmp) End Sub Public Sub New() InitializeComponent SetImage(mnuExit, New Bitmap("exit.bmp")) ' prvi argument je menu, a drugi je slika End Sub <STAThread()> _ Public Shared Sub Main(ByVal args As String()) Application.Run(New MainForm) End Sub Private Sub InitializeComponent() Me.mnuOpen = New System.Windows.Forms.MenuItem Me.mnuFile = New System.Windows.Forms.MenuItem Me.mnuExit = New System.Windows.Forms.MenuItem Me.mnuMain = New System.Windows.Forms.MainMenu Me.mnuSep1 = New System.Windows.Forms.MenuItem Me.mnuSave = New System.Windows.Forms.MenuItem Me.mnuOpen.Index = 0 Me.mnuOpen.Text = "Open" Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpen, Me.mnuSave, Me.mnuSep1, Me.mnuExit}) Me.mnuFile.Text = "File" Me.mnuExit.Index = 3 Me.mnuExit.Text = "Exit" Me.mnuMain.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile}) Me.mnuSep1.Index = 2 Me.mnuSep1.Text = "-" Me.mnuSave.Index = 1 Me.mnuSave.Text = "Save" Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Menu = Me.mnuMain Me.Name = "MainForm" Me.Text = "MainForm" End Sub End Class [ NeznamTkoSam @ 13.05.2005. 17:20 ] @
n1tr0, radi sad?
Copyright (C) 2001-2024 by www.elitesecurity.org. All rights reserved.
|