|
-
February 14th, 2008, 12:04 PM
#1
[RESOLVED] Need help with modify notify windowstate and sysmenu
Hi guys
I have a question about changes the system menu and the notify texts on windowstate (like maximum, minimize and close texts on the top right corner). Is it possible to make two different classes module, E.G make one for English and make another one for French. And is it possible to call one of those class by if I selection on one of the menu item one at a time that will convert to other which it would have to be something looking like this:
http://img262.imageshack.us/img262/7185/englishbi7.jpg
http://img144.imageshack.us/img144/2592/frenchte1.jpg
Form1
Code:
Option Explicit
Private Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd 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 Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Const SC_CLOSE As Long = &HF060&
Private Const GWL_WNDPROC As Long = (-4&)
Private Const MF_BYCOMMAND As Long = &H0&
Private Const MF_BYPOSITION As Long = &H400&
Private Const MF_SEPARATOR As Long = &H800&
Private Const MF_CHECKED As Long = &H8&
Private Const MF_GRAYED As Long = &H1&
Private Const MF_BITMAP = &H4&
Private Sub Form_Load()
Dim hMenu As Long, hID As Long
hMenu = GetSystemMenu(Me.hWnd, 0)
'add a item in first pos
InsertMenu hMenu, &H0, MF_BYPOSITION, IDM.a, "First Menu"
'add a checked item before close item
InsertMenu hMenu, SC_CLOSE, MF_BYCOMMAND + MF_CHECKED, IDM.b, "Option &Before Close"
''add separator after close item
InsertMenu hMenu, SC_CLOSE, MF_BYCOMMAND + MF_SEPARATOR, 0&, vbNullString
''add item (after the last item)
InsertMenu hMenu, &HFFFFFFFF, 0&, IDM.c, "&New Close Button"
''add a disabled item
InsertMenu hMenu, &HFFFFFFFF, MF_GRAYED, IDM.d, "&Option MaRiO"
'add a separator
InsertMenu hMenu, &HFFFFFFFF, MF_BYCOMMAND + MF_SEPARATOR, 0&, vbNullString
InsertMenu hMenu, &HFFFFFFFF, MF_BYPOSITION, IDM.e, "&Last Option"
'refresh menu
DrawMenuBar hMenu
'draw icon in pos 13
hID& = GetMenuItemID(hMenu&, 13)
SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, Picture1.Picture, Picture1.Picture
'draw icon in first item
hID& = GetMenuItemID(hMenu&, 0)
SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, Picture2.Picture, Picture2.Picture
'delete the Close item
DeleteMenu hMenu, SC_CLOSE, MF_BYCOMMAND
'subclass
procOld = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Module1
Code:
Option Explicit
Public Enum IDM
a = 128
b
c
d
e
End Enum
Public procOld As Long
Private Declare Function CallWindowProc& Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc&, ByVal hWnd&, ByVal Msg&, ByVal wParam&, ByVal lParam&)
Private Const WM_SYSCOMMAND = &H112
Public Function WindowProc(ByVal hWnd As Long, _
ByVal iMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Select Case iMsg
Case WM_SYSCOMMAND
Select Case wParam
Case IDM.a
MsgBox "'First menu' Cliked"
Case IDM.b
MsgBox "'Option Before Close' Cliked"
Case IDM.c
MsgBox "GoodBye"
Unload Form1
Exit Function
'Case IDM.d: MsgBox "Clik en 'Option MaRiO' Cliked" 'Disabled...
Case IDM.e
MsgBox "'Last Option' Cliked"
End Select
End Select
WindowProc = CallWindowProc(procOld, hWnd, iMsg, wParam, lParam)
End Function
Let me know if that is possible to do that?? If so how?? Also I would like to know if that is possible to call and change the notify texts on windowstate the one that come with max, mini and close button on the very top right corner of the screen??
If you know what I means, please can you post the code something would be like this:
Code:
Public Sub English_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles English.Click
Me.NotifyWindowstate.Text = "Maximum"
End Sub
Public Sub French_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles French.Click
Me.NotifyWindowstate.Text = "Maximizar"
End Sub
If not, please can you let me know what other situations that I could do that??
Let me know if that is possible....
Thanks,
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|