可恶的老外,这么好的控件(ICONMENU)竟然不支持中文,请高手解决!!!!!!!!
网站上发现了一个很小的,能比ACTIVEBAR更快捷地创建带图标菜单的控件--->ICONMENU,IMAGELIST中的每个图标对应一个菜单条的CAPTION(标题),用英文可以顺利地将图标(BMP)加到菜单中,但我试了很多次,该控件就是不支持中文菜单条标题(CAPTION),请高手倾力指点如何解决。
该控件比较容易操作,很简单,远比ACTIVEBAR容易,所以我很想使用它,而且可以用它直接利用工具条的IMAGELIST,一举两得呀。
该控件(含示例源代码)下载处:
http://202.103.176.84/erun/adamyl/vbcontrols/download/im209.zip
问题点数:130、回复次数:16Top
1 楼iProgram(na)回复于 2001-07-02 18:30:35 得分 20
试试在添加中文的代码的中文后加上chr(0),入:
xx.AddCaption("中文Caption" & chr(0))Top
2 楼huanggx(大侠)回复于 2001-07-02 18:31:13 得分 20
已经有破解了吗?Top
3 楼OLD_VB_FAN(蓝星)回复于 2001-07-02 19:25:44 得分 0
to iProgram(赶快去掉这鬼东西):不用写代码,直接在IMAGELIST中将菜单条的标题(CAPTION)与每一个图标(BMP)相对应即可,英文标题菜单没问题,中文的则图标无法显示,而其他效果均可以使用。
TO:huanggx(大侠):我下载的好象没有限制呀! Top
4 楼OLD_VB_FAN(蓝星)回复于 2001-07-02 22:08:19 得分 0
@_@Top
5 楼huanggx(大侠)回复于 2001-07-02 22:12:01 得分 15
我下载了你上面公布的那个im209.zip,里面的例程在我的机器上看不见菜单。但把鼠标放到菜单的位置,能看到突起的按钮。一点就会导致vb6出错,被系统杀掉。
我的环境是win2000sp2, 中文vb6 sp5Top
6 楼huangguanshu()回复于 2001-07-02 22:29:29 得分 20
这个东西我试过了,在我的机器上里面的例程一运行就出错,自己写的亦出错。
可能Win2000用不到,我的环境和大侠一样。Top
7 楼joeking(只是喜欢动手罢了)回复于 2001-07-03 01:54:16 得分 20
笨方法:如果把CAPTION直接写到图片里呢?用一个图象编辑软件可以做到,对不对?
我没有下,也不想试,我对别人的控件不感兴趣,除非真的有用,呵呵。Top
8 楼OLD_VB_FAN(蓝星)回复于 2001-07-03 09:13:33 得分 0
TO joeking(天龙):菜单条的标题(CAPTION)Top
9 楼OLD_VB_FAN(蓝星)回复于 2001-07-03 10:28:44 得分 0
@_@Top
10 楼OLD_VB_FAN(蓝星)回复于 2001-07-03 20:11:18 得分 0
Question: how to make the iconmenu control to support chinese menuitem's caption? Date: 07/02/2001 06:40AM PST
From: new_fan
Status: Waiting for Answer Points: 100
Email A Friend
I downloaded the control and its sample codes in the site as below:
http://202.103.176.84/erun/adamyl/vbcontrols/download/im209.zip
use this control, you can add bmp image into the menuitem easily, what you do is just add some bmp images
into a imagelist, then map each bmp image's keyword with a menuitem's caption (same), it works well
when i use some english menuitem'caption, but I found this control cannot support the chinese menuitem's
caption, could you tell me how to solve this problem?
Question History
Comment
From: jrspano Date: 07/02/2001 06:49AM PST
i have a class if you want it that will add icons to the menu items. it uses api calls and is number
based and not string based. I have only tried it with ico files though
Comment
From: new_fan Date: 07/02/2001 07:10AM PST
jrspano,could you give me your class and sample codes?
my email: xy_wu@netease.com
Comment
From: amit_panjwani Date: 07/02/2001 10:03AM PST
watching...
I have code ...
it works this way
I add picture boxes
specify pic source(any imge files I might need ) for pic box
... In your context you can use PRINT with Picturebox and specify font as well(in your case it may be
chinese font installed on your computer).
If you need code , lemme know
Amit
Comment
From: jrspano Date: 07/02/2001 10:20AM PST
i'll post it here so any one can see it.
copy it into a class module. add a image list.
make a new var of the class and then run. set the image list to use property with your image list. call
set menu picture for each item you want to set
ex
in ms stuff file is always first is would be postion 0 each item under it would be a number starting
with 0
SetMenuPicture 0,0,"keyforimagelist"
this would do file new
for file open it would be 0,1,"key" etc.
' ******************************************************************************
' Routine: CMenuWrapper
'
' Purpose: Class to provide menu functions not in VB
' ******************************************************************************
Option Explicit
'APIs used in class
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 m_ImageListSet As Boolean 'test to see if image list has been set
Private m_FormHwnd As Long
Private m_MenuHwnd As Long
Private m_ImageList As ImageList
Public Sub SetMenuPicture(MenuId As Long, MenuSubId As Long, ImageKey As Variant)
' ******************************************************************************
' Routine: SetMenuPicture
'
' Purpose:This sub actually sets the picture for the menu item
'
' Input Variables:MenuId 0 based item you want to work on menus go left to
' right 0 to whatever
' MenuSubId the item in MenuId you want to work on these
' go top to bottom 0 to whatever with separaters counting
' Key is the immage list position id or Key
' Output Variables:None
' ******************************************************************************
On Error GoTo hErr
Dim lngMenuItemID As Long
Dim lngRet As Long
Dim lngSubMenuHwnd As Long
'make sure vars have been set
If m_FormHwnd = 0 Then
Err.Raise vbObjectError + 1000, "CMenuWrapper", "FormHwnd hasn't been set!"
ElseIf m_ImageListSet = False Then
Err.Raise vbObjectError + 1001, "CMenuWrapper", "ImageList hasn't been set!"
End If
'get the menu hwnd from the form hwnd passed in
m_MenuHwnd = GetMenu(m_FormHwnd)
'get the header menu hwnd that we want to add picture to from menuhwnd and menu item user passes
in
lngSubMenuHwnd = GetSubMenu(m_MenuHwnd, MenuId)
'get the actual hwnd for sub item user wants
lngMenuItemID = GetMenuItemID(lngSubMenuHwnd, MenuSubId)
'set the picture for menu item
lngRet = SetMenuItemBitmaps(m_MenuHwnd, lngMenuItemID, 0, _
m_ImageList.ListImages(ImageKey).Picture, m_ImageList.ListImages(ImageKey).Picture)
Exit Sub
hErr:
Err.Raise Err.Number, "CMenuWrapper", Err.Description
End Sub
Public Property Set ImageListToUse(data As ImageList)
' ******************************************************************************
' Routine: ImageListToUse
'
' Purpose:Sets the image list to use when setting pictures
'
' Input Variables:the image list statments must be in the form
' Set DimedVarAsCMenuWrapper = imagelist1
'
' Output Variables:None
' ******************************************************************************
Set m_ImageList = data
m_ImageListSet = True
End Property
'simple let and get for form hwnd setting/getting
Public Property Let FormHwnd(data As Long)
m_FormHwnd = data
End Property
Public Property Get FormHwnd() As Long
FormHwnd = m_FormHwnd
End Property
Private Sub Class_Initialize()
m_ImageListSet = False
End Sub
Top
11 楼thriller(http://vb61.com)回复于 2001-07-04 08:03:24 得分 25
这有什么,我用纯VB代码完全做的到。抓屏助手的菜单怎么样?比它好吧?
http://vbaccelerator.com/有这方面的代码下载。
不过我可不是用的他的,我自己写的。Top
12 楼thriller(http://vb61.com)回复于 2001-07-04 08:05:59 得分 0
关键是DrawText和TextOut的控制,中文字符在VB5、6里是按一个字节,但他其实是两个字节,也就是说,Len("我们")=2,但DrawText却认为它是4,所以丢了后面的字符。Top
13 楼haitaoyu(咸鱼晾肚皮)回复于 2001-07-04 09:59:21 得分 10
gzTop
14 楼OLD_VB_FAN(蓝星)回复于 2001-07-04 15:34:10 得分 0
本帖暂保留,再加分30,请各位畅谈!!!!!!!!!!!!!Top
15 楼OLD_VB_FAN(蓝星)回复于 2001-07-04 17:53:51 得分 0
各位GO ON!Top
16 楼OLD_VB_FAN(蓝星)回复于 2001-07-04 19:07:53 得分 0
NEW:
各位,请参观
http://www.csdn.net/expert/topic/181/181778.shtm
http://www.csdn.net/expert/topic/181/181764.shtm
有经验解决者请援手!!!Top




