前面有帖子说用SetSysColor来实现,但是这样会修改其他菜单的颜色,这样也不是办法,不知道有谁有好的解决办法?
欢迎大家讨论!!
还有个问题就是我在菜单中加入一个自定义事件,祖先中我只定义一个MenuItem,里面加入个自定义事件,我本来想让所有的子对象都能象它一样拥有这个事件。可是当我继承后只能看见第一个MenuItem有这个事件。所以如果想给每个MenuItem加入一个相同的事件,不知道大家是怎么实现的?不会是手工为每个MenuItem加入相同的事件吧。
28 个解决方案
#1
我也正为此事情苦恼
我在窗口pbm_menuselect事件中
il_windc = GetWindowDC(Handle(THIS))
GetWindowRect(Handle(this),ist_rectwnd)
tagrect lstr_rect
long count
string ls
boolean lb_flag = false
if isnull(MenuID) or not isvalid(MenuID) then return
//int ii
//if itemid>=10000 then
// ii = itemid - 10001
//else
// ii = itemid
//end if
//messagebox("",itemid)
long ll_menuDC,ll_new
lb_flag =GetMenuItemRect(handle(this),hmenu,itemid,lstr_rect)
if lb_flag = false then
return 1
end if
//count = getMenuItemCount(hMenu)
//GetMenuString(hmenu,itemid,ls,100,1024)
il_brush = CreateSolidBrush(rgb(225,225,225))
offSetRect(lstr_rect,-ist_rectwnd.left ,-ist_rectwnd.top)
DrawEdge(il_winDC,lstr_rect, 4, 12)
ll_menuDC = CreateCompatibleDC(il_windc)
//创建一幅与il_memDC兼容位图(色表一致)
ll_new = CreateCompatibleBitmap( il_winDC,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top)
SelectObject(ll_menuDC,ll_new)
tagrect lstr_temp
lstr_temp.left = 0
lstr_temp.right = lstr_rect.right - lstr_rect.Left
lstr_temp.top = 0
lstr_temp.bottom = lstr_rect.Bottom - lstr_rect.top
FillRect(ll_menuDC,lstr_temp,il_brush)
BitBlt(il_winDC,lstr_rect.Left,lstr_rect.top,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top,ll_menuDC,0,0,SRCAND)
DeleteObject(ll_new)
DeleteObject(il_brush)
DeleteDC(ll_menuDC)
DeleteDC(il_windc)
可以使得一级菜单上选择时候改变,但是二级不行,可以得到其rect,但是一画就画在了窗口上
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
呵呵,一切重任交给楼主
我在窗口pbm_menuselect事件中
il_windc = GetWindowDC(Handle(THIS))
GetWindowRect(Handle(this),ist_rectwnd)
tagrect lstr_rect
long count
string ls
boolean lb_flag = false
if isnull(MenuID) or not isvalid(MenuID) then return
//int ii
//if itemid>=10000 then
// ii = itemid - 10001
//else
// ii = itemid
//end if
//messagebox("",itemid)
long ll_menuDC,ll_new
lb_flag =GetMenuItemRect(handle(this),hmenu,itemid,lstr_rect)
if lb_flag = false then
return 1
end if
//count = getMenuItemCount(hMenu)
//GetMenuString(hmenu,itemid,ls,100,1024)
il_brush = CreateSolidBrush(rgb(225,225,225))
offSetRect(lstr_rect,-ist_rectwnd.left ,-ist_rectwnd.top)
DrawEdge(il_winDC,lstr_rect, 4, 12)
ll_menuDC = CreateCompatibleDC(il_windc)
//创建一幅与il_memDC兼容位图(色表一致)
ll_new = CreateCompatibleBitmap( il_winDC,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top)
SelectObject(ll_menuDC,ll_new)
tagrect lstr_temp
lstr_temp.left = 0
lstr_temp.right = lstr_rect.right - lstr_rect.Left
lstr_temp.top = 0
lstr_temp.bottom = lstr_rect.Bottom - lstr_rect.top
FillRect(ll_menuDC,lstr_temp,il_brush)
BitBlt(il_winDC,lstr_rect.Left,lstr_rect.top,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top,ll_menuDC,0,0,SRCAND)
DeleteObject(ll_new)
DeleteObject(il_brush)
DeleteDC(ll_menuDC)
DeleteDC(il_windc)
可以使得一级菜单上选择时候改变,但是二级不行,可以得到其rect,但是一画就画在了窗口上
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
呵呵,一切重任交给楼主
#2
就是,菜单的HDC不知道在哪个事件里获取,我前面已经说过了,不知道怎么样去获取重画事件。你这样只能改变选择时的颜色吧,我想要的是在显示时就想修改颜色。
#3
可以先找个vb的例子研究研究
#4
不会,但可把这问题放公告上,希望更多的人能看见,确实是好问题
#5
使用位图彩旦, Win32 API 对这个有比较好的
#6
可以使得一级菜单上选择时候改变,但是二级不行,可以得到其rect,但是一画就画在了窗口上
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
是这个原因, PB 可能对 win32 api 支持不好!
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
是这个原因, PB 可能对 win32 api 支持不好!
#7
我查了一下msdn
如果pb要更改菜单背景的话,需要在这几个事件中处理
pbm_menuchar
pbm_measureitem
pbm_drawitem
问题是
1 无法用pbm_menuchar来定义一个事件,提示事件参数type是一个保留字!
2 在drawitem中无法得到TAGDRAWITMESTRUCT这个结构,这个结构中有个hdc参数,虽然事件中有一个参数drawitemstruct,但是是long型的,pb中怎么从中得到一个结构,我是没有办法
所以,我认为实现起来太难,还是找个ocx来包装菜单的好!:)
如果pb要更改菜单背景的话,需要在这几个事件中处理
pbm_menuchar
pbm_measureitem
pbm_drawitem
问题是
1 无法用pbm_menuchar来定义一个事件,提示事件参数type是一个保留字!
2 在drawitem中无法得到TAGDRAWITMESTRUCT这个结构,这个结构中有个hdc参数,虽然事件中有一个参数drawitemstruct,但是是long型的,pb中怎么从中得到一个结构,我是没有办法
所以,我认为实现起来太难,还是找个ocx来包装菜单的好!:)
#8
关注
#9
大家多想想啊!!!
#10
用CopyMem可以得到TAGDRAWITMESTRUCT这个结构
#11
具体怎么个用法?给个例子吧。
#12
?????????????
#13
www.google.com
#14
FUNCTION boolean GetMenuItemInfo(ulong hMenu,ulong un,boolean b,ref MENUITEMINFO lpMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "GetMenuItemInfoA"
FUNCTION boolean SetMenuItemInfo(ulong hMenu,ulong un,boolean bool,ref MENUITEMINFO lpcMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "SetMenuItemInfoA"
FUNCTION boolean GetMenuItemRect(ulong hWnd,ulong hMenu,ulong uItem,ref us_RECT lprcItem) LIBRARY "user32.dll"
FUNCTION ulong GetMenu(ulong hwnd) LIBRARY "user32.dll"
FUNCTION ulong GetSubMenu(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemCount(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemID(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong IsMenu(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong DrawMenuBar(ulong hwnd) LIBRARY "user32.dll"
//内存拷贝
SUBROUTINE MoveMemory(ref drawitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref drawitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ref measureitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref measureitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
这是我用到的部分函数,其实唯一的难题就是将long -》 一个结构,最后四个就可以作到了
下面是一些结构:
type us_rect from structure
long left
long top
long right
long bottom
end type
type measureitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemwidth
unsignedlong itemheight
ulong itemdata
end type
type drawitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemaction
unsignedlong itemstate
unsignedlong hwnditem
unsignedlong hdc
us_rect rcitem
unsignedlong itemdata
end type
type menuiteminfo from structure
unsignedlong cbsize
unsignedlong fmask
unsignedlong ftype
unsignedlong fstate
unsignedlong wid
unsignedlong hsubmenu
unsignedlong hbmpchecked
unsignedlong hbmpunchecked
ulong dwitemdata
string dwtypedata
unsignedlong cch
end type
FUNCTION boolean SetMenuItemInfo(ulong hMenu,ulong un,boolean bool,ref MENUITEMINFO lpcMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "SetMenuItemInfoA"
FUNCTION boolean GetMenuItemRect(ulong hWnd,ulong hMenu,ulong uItem,ref us_RECT lprcItem) LIBRARY "user32.dll"
FUNCTION ulong GetMenu(ulong hwnd) LIBRARY "user32.dll"
FUNCTION ulong GetSubMenu(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemCount(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemID(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong IsMenu(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong DrawMenuBar(ulong hwnd) LIBRARY "user32.dll"
//内存拷贝
SUBROUTINE MoveMemory(ref drawitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref drawitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ref measureitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref measureitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
这是我用到的部分函数,其实唯一的难题就是将long -》 一个结构,最后四个就可以作到了
下面是一些结构:
type us_rect from structure
long left
long top
long right
long bottom
end type
type measureitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemwidth
unsignedlong itemheight
ulong itemdata
end type
type drawitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemaction
unsignedlong itemstate
unsignedlong hwnditem
unsignedlong hdc
us_rect rcitem
unsignedlong itemdata
end type
type menuiteminfo from structure
unsignedlong cbsize
unsignedlong fmask
unsignedlong ftype
unsignedlong fstate
unsignedlong wid
unsignedlong hsubmenu
unsignedlong hbmpchecked
unsignedlong hbmpunchecked
ulong dwitemdata
string dwtypedata
unsignedlong cch
end type
#15
//以下是定义的常量,不一定全部用得到,呵呵
constant ulong WM_ENTERMENULOOP = 529
constant ulong TPM_LEFTBUTTON = 0
constant ulong TPM_RIGHTBUTTON = 2
constant ulong TPM_LEFTALIGN = 0
constant ulong TPM_CENTERALIGN = 4
constant ulong TPM_RIGHTALIGN = 8
//#if(WINVER >= = 0400)
constant ulong TPM_TOPALIGN = 0
constant ulong TPM_VCENTERALIGN = 16
constant ulong TPM_BOTTOMALIGN = 32
constant ulong TPM_HORIZONTAL = 0 /* Horz alignment matters more */
constant ulong TPM_VERTICAL = 64 /* Vert alignment matters more */
constant ulong TPM_NONOTIFY = 128 /* Don't send any notification msgs */
constant ulong TPM_RETURNCMD = 256
//#endif /* WINVER >= = 0400 */
constant ulong ODA_DRAWENTIRE = 1
constant ulong ODA_SELECT = 2
constant ulong ODA_FOCUS = 4
constant ulong ODS_SELECTED = 1
constant ulong ODS_GRAYED = 2
constant ulong ODS_DISABLED = 4
constant ulong ODS_CHECKED = 8
constant ulong ODS_FOCUS = 16
//#if(WINVER >= 0x0400)
constant ulong ODS_DEFAULT = 32
constant ulong ODS_COMBOBOXEDIT = 512
constant ulong ODS_HOTLIGHT = 64
//#endif /* WINVER >= 0x0400 */
constant ulong ODT_MENU = 1
constant ulong ODT_LISTBOX = 2
constant ulong ODT_COMBOBOX = 3
constant ulong ODT_BUTTON =4
//#if(WINVER >= 0x0400)
constant ulong ODT_STATIC =5
//#endif /* WINVER >= 0x0400 */
constant ulong MF_INSERT =0
constant ulong MF_CHANGE =128
constant ulong MF_APPEND =256
constant ulong MF_DELETE =512
constant ulong MF_REMOVE =4096
constant ulong MF_BYCOMMAND =0
constant ulong MF_BYPOSITION =1024
constant ulong MF_SEPARATOR =2048
constant ulong MF_ENABLED =0
constant ulong MF_GRAYED =1
constant ulong MF_DISABLED =2
constant ulong MF_UNCHECKED =0
constant ulong MF_CHECKED =8
constant ulong MF_USECHECKBITMAPS =512
constant ulong MF_STRING =0
constant ulong MF_BITMAP =4
constant ulong MF_OWNERDRAW =256
constant ulong MF_POPUP =16
constant ulong MF_MENUBARBREAK =32
constant ulong MF_MENUBREAK =64
constant ulong MF_UNHILITE =0
constant ulong MF_HILITE =128
//#if(WINVER >= =0400)
constant ulong MF_DEFAULT =4096
//#endif /* WINVER >= =0400 */
constant ulong MF_SYSMENU =8192
constant ulong MF_HELP =16384
//#if(WINVER >= =0400)
constant ulong MF_RIGHTJUSTIFY =16384
//#endif /* WINVER >= =0400 */
constant ulong MF_MOUSESELECT =32768
//#if(WINVER >= =0400)
constant ulong MF_END =128// Obsolete -- only used by old RES files */
//#endif /* WINVER >= =0400 */
//#if(WINVER >= =0400)
constant ulong MFT_STRING =MF_STRING
constant ulong MFT_BITMAP =MF_BITMAP
constant ulong MFT_MENUBARBREAK =MF_MENUBARBREAK
constant ulong MFT_MENUBREAK =MF_MENUBREAK
constant ulong MFT_OWNERDRAW =MF_OWNERDRAW
constant ulong MFT_RADIOCHECK =512
constant ulong MFT_SEPARATOR =MF_SEPARATOR
constant ulong MFT_RIGHTORDER =8192
constant ulong MFT_RIGHTJUSTIFY =MF_RIGHTJUSTIFY
//* Menu flags for Add/Check/EnableMenuItem() */
constant ulong MFS_GRAYED =3
constant ulong MFS_DISABLED =MFS_GRAYED
constant ulong MFS_CHECKED =MF_CHECKED
constant ulong MFS_HILITE =MF_HILITE
constant ulong MFS_ENABLED =MF_ENABLED
constant ulong MFS_UNCHECKED =MF_UNCHECKED
constant ulong MFS_UNHILITE =MF_UNHILITE
constant ulong MFS_DEFAULT =MF_DEFAULT
constant long MIIM_STATE = 1
constant long MIIM_ID = 2
constant long MIIM_SUBMENU = 4
constant long MIIM_CHECKMARKS = 8
constant long MIIM_TYPE = 16
constant long MIIM_DATA = 32
constant long MIIM_ALL = MIIM_STATE + MIIM_ID + MIIM_CHECKMARKS + MIIM_SUBMENU + MIIM_TYPE + MIIM_DATA
constant long DRAWITEMSTRUCT_SIZE = 48
constant long MEASUREITEMSTRUCT_SIZE = 24
constant long MENUITEMINFO_SIZE = 44
constant ulong WM_ENTERMENULOOP = 529
constant ulong TPM_LEFTBUTTON = 0
constant ulong TPM_RIGHTBUTTON = 2
constant ulong TPM_LEFTALIGN = 0
constant ulong TPM_CENTERALIGN = 4
constant ulong TPM_RIGHTALIGN = 8
//#if(WINVER >= = 0400)
constant ulong TPM_TOPALIGN = 0
constant ulong TPM_VCENTERALIGN = 16
constant ulong TPM_BOTTOMALIGN = 32
constant ulong TPM_HORIZONTAL = 0 /* Horz alignment matters more */
constant ulong TPM_VERTICAL = 64 /* Vert alignment matters more */
constant ulong TPM_NONOTIFY = 128 /* Don't send any notification msgs */
constant ulong TPM_RETURNCMD = 256
//#endif /* WINVER >= = 0400 */
constant ulong ODA_DRAWENTIRE = 1
constant ulong ODA_SELECT = 2
constant ulong ODA_FOCUS = 4
constant ulong ODS_SELECTED = 1
constant ulong ODS_GRAYED = 2
constant ulong ODS_DISABLED = 4
constant ulong ODS_CHECKED = 8
constant ulong ODS_FOCUS = 16
//#if(WINVER >= 0x0400)
constant ulong ODS_DEFAULT = 32
constant ulong ODS_COMBOBOXEDIT = 512
constant ulong ODS_HOTLIGHT = 64
//#endif /* WINVER >= 0x0400 */
constant ulong ODT_MENU = 1
constant ulong ODT_LISTBOX = 2
constant ulong ODT_COMBOBOX = 3
constant ulong ODT_BUTTON =4
//#if(WINVER >= 0x0400)
constant ulong ODT_STATIC =5
//#endif /* WINVER >= 0x0400 */
constant ulong MF_INSERT =0
constant ulong MF_CHANGE =128
constant ulong MF_APPEND =256
constant ulong MF_DELETE =512
constant ulong MF_REMOVE =4096
constant ulong MF_BYCOMMAND =0
constant ulong MF_BYPOSITION =1024
constant ulong MF_SEPARATOR =2048
constant ulong MF_ENABLED =0
constant ulong MF_GRAYED =1
constant ulong MF_DISABLED =2
constant ulong MF_UNCHECKED =0
constant ulong MF_CHECKED =8
constant ulong MF_USECHECKBITMAPS =512
constant ulong MF_STRING =0
constant ulong MF_BITMAP =4
constant ulong MF_OWNERDRAW =256
constant ulong MF_POPUP =16
constant ulong MF_MENUBARBREAK =32
constant ulong MF_MENUBREAK =64
constant ulong MF_UNHILITE =0
constant ulong MF_HILITE =128
//#if(WINVER >= =0400)
constant ulong MF_DEFAULT =4096
//#endif /* WINVER >= =0400 */
constant ulong MF_SYSMENU =8192
constant ulong MF_HELP =16384
//#if(WINVER >= =0400)
constant ulong MF_RIGHTJUSTIFY =16384
//#endif /* WINVER >= =0400 */
constant ulong MF_MOUSESELECT =32768
//#if(WINVER >= =0400)
constant ulong MF_END =128// Obsolete -- only used by old RES files */
//#endif /* WINVER >= =0400 */
//#if(WINVER >= =0400)
constant ulong MFT_STRING =MF_STRING
constant ulong MFT_BITMAP =MF_BITMAP
constant ulong MFT_MENUBARBREAK =MF_MENUBARBREAK
constant ulong MFT_MENUBREAK =MF_MENUBREAK
constant ulong MFT_OWNERDRAW =MF_OWNERDRAW
constant ulong MFT_RADIOCHECK =512
constant ulong MFT_SEPARATOR =MF_SEPARATOR
constant ulong MFT_RIGHTORDER =8192
constant ulong MFT_RIGHTJUSTIFY =MF_RIGHTJUSTIFY
//* Menu flags for Add/Check/EnableMenuItem() */
constant ulong MFS_GRAYED =3
constant ulong MFS_DISABLED =MFS_GRAYED
constant ulong MFS_CHECKED =MF_CHECKED
constant ulong MFS_HILITE =MF_HILITE
constant ulong MFS_ENABLED =MF_ENABLED
constant ulong MFS_UNCHECKED =MF_UNCHECKED
constant ulong MFS_UNHILITE =MF_UNHILITE
constant ulong MFS_DEFAULT =MF_DEFAULT
constant long MIIM_STATE = 1
constant long MIIM_ID = 2
constant long MIIM_SUBMENU = 4
constant long MIIM_CHECKMARKS = 8
constant long MIIM_TYPE = 16
constant long MIIM_DATA = 32
constant long MIIM_ALL = MIIM_STATE + MIIM_ID + MIIM_CHECKMARKS + MIIM_SUBMENU + MIIM_TYPE + MIIM_DATA
constant long DRAWITEMSTRUCT_SIZE = 48
constant long MEASUREITEMSTRUCT_SIZE = 24
constant long MENUITEMINFO_SIZE = 44
#16
个人意见:觉得没必要讨论这个问题,有什么应用要非的修改菜单颜色呢,这个时间花在什么上面不好呢;再说,说不定pb下个版本就支持了呢。
#17
十分同意楼上意见,多学学总体设计,系统分析,怎么把数据组织好,运算速度快一些,达到设计目的。
#18
are2000(土狗) 界面 是关键,见面上去了.整体设计就比较完善了.
关注
关注
#19
可以使用ACTIVEBAR控件实现,比较方便.
#20
同意are2000(土狗) 的说法。
数据库的功能上去了,查询速度上去了。就可以了。没有必要花那么多心思在表面功夫上。
数据库的功能上去了,查询速度上去了。就可以了。没有必要花那么多心思在表面功夫上。
#21
关注
#22
我看wu_07(itsy bitsy spider)和chinalht(有多少爱,可以重来) 都是win api高手了,不错不错,俺要多学习了!!!
#23
up
#24
哈哈..........
关注之中
关注之中
#25
to chinalht(有多少爱,可以重来),你和我的想法一样哈。当时我也是看到strcopy函数用的别名是“RtlMoveMemory”,就把它用上了,用来传递MEASUREITEMSTRUCT和DRAWITEMSTRUCT的值
#26
我用自画菜单项实现了与windows开始菜单一样的效果
#27
看一下我写的程序:
http://www.pdriver.com/bbs3/cgi-bin/topic.cgi?forum=6&topic=36136&show=0
http://www.pdriver.com/bbs3/cgi-bin/topic.cgi?forum=6&topic=36136&show=0
#28
//这是从pdriver上下的一个例子
//设置文件子菜单背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic2.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//获取窗口指定子菜单的句柄
ll_hSubMenu = GetSubMenu(ll_hMainMenu, 0)
//设置菜单信息
SetMenuInfo(ll_hSubMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------------------------
//设置主菜单条背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic1.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//设置主菜单信息
SetMenuInfo(ll_hMainMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------
type menuinfo from structure
long cbsize
long fmask
long dwstyle
long cymax
long hbrback
long dwcontexthelpid
long dwmenudata
end type
//菜单相关API函数
FUNCTION Long SetMenu ( Long hwnd, Long hMenu) LIBRARY "user32"
FUNCTION Long GetMenu ( Long hwnd) LIBRARY "user32"
FUNCTION Long GetSubMenu ( Long hMenu, Long nPos) LIBRARY "user32"
FUNCTION Long DrawMenuBar ( Long hwnd) LIBRARY "user32"
FUNCTION Long SetMenuInfo (Long hmenu, REF MENUINFO mi) LIBRARY "user32"
//创建区域填充刷子函数
FUNCTION Long CreatePatternBrush(Long hBitmap) LIBRARY "gdi32.dll"
//载入位图函数
FUNCTION Long LoadImage(Long hInst, string lpsz, Long uType, Long cxDesired, Long cyDesired, Long fuLoad) LIBRARY "user32.dll" ALIAS FOR "LoadImageA"
//释放对象函数
FUNCTION Long DeleteObject(Long hObject) LIBRARY "gdi32.dll"
//LoadImage常量
CONSTANT Long LR_LOADFROMFILE = 16
CONSTANT Long IMAGE_BITMAP = 0
CONSTANT Long IMAGE_ICON = 1
CONSTANT Long IMAGE_CURSOR = 2
//MENUINFO常量
CONSTANT Long MIM_BACKGROUND = 2
CONSTANT Long MIM_APPLYTOSUBMENUS = 2147483648
//设置文件子菜单背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic2.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//获取窗口指定子菜单的句柄
ll_hSubMenu = GetSubMenu(ll_hMainMenu, 0)
//设置菜单信息
SetMenuInfo(ll_hSubMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------------------------
//设置主菜单条背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic1.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//设置主菜单信息
SetMenuInfo(ll_hMainMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------
type menuinfo from structure
long cbsize
long fmask
long dwstyle
long cymax
long hbrback
long dwcontexthelpid
long dwmenudata
end type
//菜单相关API函数
FUNCTION Long SetMenu ( Long hwnd, Long hMenu) LIBRARY "user32"
FUNCTION Long GetMenu ( Long hwnd) LIBRARY "user32"
FUNCTION Long GetSubMenu ( Long hMenu, Long nPos) LIBRARY "user32"
FUNCTION Long DrawMenuBar ( Long hwnd) LIBRARY "user32"
FUNCTION Long SetMenuInfo (Long hmenu, REF MENUINFO mi) LIBRARY "user32"
//创建区域填充刷子函数
FUNCTION Long CreatePatternBrush(Long hBitmap) LIBRARY "gdi32.dll"
//载入位图函数
FUNCTION Long LoadImage(Long hInst, string lpsz, Long uType, Long cxDesired, Long cyDesired, Long fuLoad) LIBRARY "user32.dll" ALIAS FOR "LoadImageA"
//释放对象函数
FUNCTION Long DeleteObject(Long hObject) LIBRARY "gdi32.dll"
//LoadImage常量
CONSTANT Long LR_LOADFROMFILE = 16
CONSTANT Long IMAGE_BITMAP = 0
CONSTANT Long IMAGE_ICON = 1
CONSTANT Long IMAGE_CURSOR = 2
//MENUINFO常量
CONSTANT Long MIM_BACKGROUND = 2
CONSTANT Long MIM_APPLYTOSUBMENUS = 2147483648
#1
我也正为此事情苦恼
我在窗口pbm_menuselect事件中
il_windc = GetWindowDC(Handle(THIS))
GetWindowRect(Handle(this),ist_rectwnd)
tagrect lstr_rect
long count
string ls
boolean lb_flag = false
if isnull(MenuID) or not isvalid(MenuID) then return
//int ii
//if itemid>=10000 then
// ii = itemid - 10001
//else
// ii = itemid
//end if
//messagebox("",itemid)
long ll_menuDC,ll_new
lb_flag =GetMenuItemRect(handle(this),hmenu,itemid,lstr_rect)
if lb_flag = false then
return 1
end if
//count = getMenuItemCount(hMenu)
//GetMenuString(hmenu,itemid,ls,100,1024)
il_brush = CreateSolidBrush(rgb(225,225,225))
offSetRect(lstr_rect,-ist_rectwnd.left ,-ist_rectwnd.top)
DrawEdge(il_winDC,lstr_rect, 4, 12)
ll_menuDC = CreateCompatibleDC(il_windc)
//创建一幅与il_memDC兼容位图(色表一致)
ll_new = CreateCompatibleBitmap( il_winDC,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top)
SelectObject(ll_menuDC,ll_new)
tagrect lstr_temp
lstr_temp.left = 0
lstr_temp.right = lstr_rect.right - lstr_rect.Left
lstr_temp.top = 0
lstr_temp.bottom = lstr_rect.Bottom - lstr_rect.top
FillRect(ll_menuDC,lstr_temp,il_brush)
BitBlt(il_winDC,lstr_rect.Left,lstr_rect.top,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top,ll_menuDC,0,0,SRCAND)
DeleteObject(ll_new)
DeleteObject(il_brush)
DeleteDC(ll_menuDC)
DeleteDC(il_windc)
可以使得一级菜单上选择时候改变,但是二级不行,可以得到其rect,但是一画就画在了窗口上
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
呵呵,一切重任交给楼主
我在窗口pbm_menuselect事件中
il_windc = GetWindowDC(Handle(THIS))
GetWindowRect(Handle(this),ist_rectwnd)
tagrect lstr_rect
long count
string ls
boolean lb_flag = false
if isnull(MenuID) or not isvalid(MenuID) then return
//int ii
//if itemid>=10000 then
// ii = itemid - 10001
//else
// ii = itemid
//end if
//messagebox("",itemid)
long ll_menuDC,ll_new
lb_flag =GetMenuItemRect(handle(this),hmenu,itemid,lstr_rect)
if lb_flag = false then
return 1
end if
//count = getMenuItemCount(hMenu)
//GetMenuString(hmenu,itemid,ls,100,1024)
il_brush = CreateSolidBrush(rgb(225,225,225))
offSetRect(lstr_rect,-ist_rectwnd.left ,-ist_rectwnd.top)
DrawEdge(il_winDC,lstr_rect, 4, 12)
ll_menuDC = CreateCompatibleDC(il_windc)
//创建一幅与il_memDC兼容位图(色表一致)
ll_new = CreateCompatibleBitmap( il_winDC,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top)
SelectObject(ll_menuDC,ll_new)
tagrect lstr_temp
lstr_temp.left = 0
lstr_temp.right = lstr_rect.right - lstr_rect.Left
lstr_temp.top = 0
lstr_temp.bottom = lstr_rect.Bottom - lstr_rect.top
FillRect(ll_menuDC,lstr_temp,il_brush)
BitBlt(il_winDC,lstr_rect.Left,lstr_rect.top,lstr_rect.right - lstr_rect.Left,lstr_rect.Bottom - lstr_rect.top,ll_menuDC,0,0,SRCAND)
DeleteObject(ll_new)
DeleteObject(il_brush)
DeleteDC(ll_menuDC)
DeleteDC(il_windc)
可以使得一级菜单上选择时候改变,但是二级不行,可以得到其rect,但是一画就画在了窗口上
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
呵呵,一切重任交给楼主
#2
就是,菜单的HDC不知道在哪个事件里获取,我前面已经说过了,不知道怎么样去获取重画事件。你这样只能改变选择时的颜色吧,我想要的是在显示时就想修改颜色。
#3
可以先找个vb的例子研究研究
#4
不会,但可把这问题放公告上,希望更多的人能看见,确实是好问题
#5
使用位图彩旦, Win32 API 对这个有比较好的
#6
可以使得一级菜单上选择时候改变,但是二级不行,可以得到其rect,但是一画就画在了窗口上
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
是这个原因, PB 可能对 win32 api 支持不好!
可能需要得到菜单的dc(??有么??),不过我连GetMenuItemInfo得到这个MENUITEMINFO结构都没有成功,最后也懒得再试了,
是这个原因, PB 可能对 win32 api 支持不好!
#7
我查了一下msdn
如果pb要更改菜单背景的话,需要在这几个事件中处理
pbm_menuchar
pbm_measureitem
pbm_drawitem
问题是
1 无法用pbm_menuchar来定义一个事件,提示事件参数type是一个保留字!
2 在drawitem中无法得到TAGDRAWITMESTRUCT这个结构,这个结构中有个hdc参数,虽然事件中有一个参数drawitemstruct,但是是long型的,pb中怎么从中得到一个结构,我是没有办法
所以,我认为实现起来太难,还是找个ocx来包装菜单的好!:)
如果pb要更改菜单背景的话,需要在这几个事件中处理
pbm_menuchar
pbm_measureitem
pbm_drawitem
问题是
1 无法用pbm_menuchar来定义一个事件,提示事件参数type是一个保留字!
2 在drawitem中无法得到TAGDRAWITMESTRUCT这个结构,这个结构中有个hdc参数,虽然事件中有一个参数drawitemstruct,但是是long型的,pb中怎么从中得到一个结构,我是没有办法
所以,我认为实现起来太难,还是找个ocx来包装菜单的好!:)
#8
关注
#9
大家多想想啊!!!
#10
用CopyMem可以得到TAGDRAWITMESTRUCT这个结构
#11
具体怎么个用法?给个例子吧。
#12
?????????????
#13
www.google.com
#14
FUNCTION boolean GetMenuItemInfo(ulong hMenu,ulong un,boolean b,ref MENUITEMINFO lpMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "GetMenuItemInfoA"
FUNCTION boolean SetMenuItemInfo(ulong hMenu,ulong un,boolean bool,ref MENUITEMINFO lpcMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "SetMenuItemInfoA"
FUNCTION boolean GetMenuItemRect(ulong hWnd,ulong hMenu,ulong uItem,ref us_RECT lprcItem) LIBRARY "user32.dll"
FUNCTION ulong GetMenu(ulong hwnd) LIBRARY "user32.dll"
FUNCTION ulong GetSubMenu(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemCount(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemID(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong IsMenu(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong DrawMenuBar(ulong hwnd) LIBRARY "user32.dll"
//内存拷贝
SUBROUTINE MoveMemory(ref drawitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref drawitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ref measureitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref measureitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
这是我用到的部分函数,其实唯一的难题就是将long -》 一个结构,最后四个就可以作到了
下面是一些结构:
type us_rect from structure
long left
long top
long right
long bottom
end type
type measureitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemwidth
unsignedlong itemheight
ulong itemdata
end type
type drawitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemaction
unsignedlong itemstate
unsignedlong hwnditem
unsignedlong hdc
us_rect rcitem
unsignedlong itemdata
end type
type menuiteminfo from structure
unsignedlong cbsize
unsignedlong fmask
unsignedlong ftype
unsignedlong fstate
unsignedlong wid
unsignedlong hsubmenu
unsignedlong hbmpchecked
unsignedlong hbmpunchecked
ulong dwitemdata
string dwtypedata
unsignedlong cch
end type
FUNCTION boolean SetMenuItemInfo(ulong hMenu,ulong un,boolean bool,ref MENUITEMINFO lpcMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "SetMenuItemInfoA"
FUNCTION boolean GetMenuItemRect(ulong hWnd,ulong hMenu,ulong uItem,ref us_RECT lprcItem) LIBRARY "user32.dll"
FUNCTION ulong GetMenu(ulong hwnd) LIBRARY "user32.dll"
FUNCTION ulong GetSubMenu(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemCount(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong GetMenuItemID(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
FUNCTION ulong IsMenu(ulong hMenu) LIBRARY "user32.dll"
FUNCTION ulong DrawMenuBar(ulong hwnd) LIBRARY "user32.dll"
//内存拷贝
SUBROUTINE MoveMemory(ref drawitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref drawitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ref measureitemstruct lpDest,ulong lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
SUBROUTINE MoveMemory(ulong lpDest,ref measureitemstruct lpSource,long nCount) LIBRARY "KERNEL32.dll" Alias for "RtlMoveMemory"
这是我用到的部分函数,其实唯一的难题就是将long -》 一个结构,最后四个就可以作到了
下面是一些结构:
type us_rect from structure
long left
long top
long right
long bottom
end type
type measureitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemwidth
unsignedlong itemheight
ulong itemdata
end type
type drawitemstruct from structure
unsignedlong ctltype
unsignedlong ctlid
unsignedlong itemid
unsignedlong itemaction
unsignedlong itemstate
unsignedlong hwnditem
unsignedlong hdc
us_rect rcitem
unsignedlong itemdata
end type
type menuiteminfo from structure
unsignedlong cbsize
unsignedlong fmask
unsignedlong ftype
unsignedlong fstate
unsignedlong wid
unsignedlong hsubmenu
unsignedlong hbmpchecked
unsignedlong hbmpunchecked
ulong dwitemdata
string dwtypedata
unsignedlong cch
end type
#15
//以下是定义的常量,不一定全部用得到,呵呵
constant ulong WM_ENTERMENULOOP = 529
constant ulong TPM_LEFTBUTTON = 0
constant ulong TPM_RIGHTBUTTON = 2
constant ulong TPM_LEFTALIGN = 0
constant ulong TPM_CENTERALIGN = 4
constant ulong TPM_RIGHTALIGN = 8
//#if(WINVER >= = 0400)
constant ulong TPM_TOPALIGN = 0
constant ulong TPM_VCENTERALIGN = 16
constant ulong TPM_BOTTOMALIGN = 32
constant ulong TPM_HORIZONTAL = 0 /* Horz alignment matters more */
constant ulong TPM_VERTICAL = 64 /* Vert alignment matters more */
constant ulong TPM_NONOTIFY = 128 /* Don't send any notification msgs */
constant ulong TPM_RETURNCMD = 256
//#endif /* WINVER >= = 0400 */
constant ulong ODA_DRAWENTIRE = 1
constant ulong ODA_SELECT = 2
constant ulong ODA_FOCUS = 4
constant ulong ODS_SELECTED = 1
constant ulong ODS_GRAYED = 2
constant ulong ODS_DISABLED = 4
constant ulong ODS_CHECKED = 8
constant ulong ODS_FOCUS = 16
//#if(WINVER >= 0x0400)
constant ulong ODS_DEFAULT = 32
constant ulong ODS_COMBOBOXEDIT = 512
constant ulong ODS_HOTLIGHT = 64
//#endif /* WINVER >= 0x0400 */
constant ulong ODT_MENU = 1
constant ulong ODT_LISTBOX = 2
constant ulong ODT_COMBOBOX = 3
constant ulong ODT_BUTTON =4
//#if(WINVER >= 0x0400)
constant ulong ODT_STATIC =5
//#endif /* WINVER >= 0x0400 */
constant ulong MF_INSERT =0
constant ulong MF_CHANGE =128
constant ulong MF_APPEND =256
constant ulong MF_DELETE =512
constant ulong MF_REMOVE =4096
constant ulong MF_BYCOMMAND =0
constant ulong MF_BYPOSITION =1024
constant ulong MF_SEPARATOR =2048
constant ulong MF_ENABLED =0
constant ulong MF_GRAYED =1
constant ulong MF_DISABLED =2
constant ulong MF_UNCHECKED =0
constant ulong MF_CHECKED =8
constant ulong MF_USECHECKBITMAPS =512
constant ulong MF_STRING =0
constant ulong MF_BITMAP =4
constant ulong MF_OWNERDRAW =256
constant ulong MF_POPUP =16
constant ulong MF_MENUBARBREAK =32
constant ulong MF_MENUBREAK =64
constant ulong MF_UNHILITE =0
constant ulong MF_HILITE =128
//#if(WINVER >= =0400)
constant ulong MF_DEFAULT =4096
//#endif /* WINVER >= =0400 */
constant ulong MF_SYSMENU =8192
constant ulong MF_HELP =16384
//#if(WINVER >= =0400)
constant ulong MF_RIGHTJUSTIFY =16384
//#endif /* WINVER >= =0400 */
constant ulong MF_MOUSESELECT =32768
//#if(WINVER >= =0400)
constant ulong MF_END =128// Obsolete -- only used by old RES files */
//#endif /* WINVER >= =0400 */
//#if(WINVER >= =0400)
constant ulong MFT_STRING =MF_STRING
constant ulong MFT_BITMAP =MF_BITMAP
constant ulong MFT_MENUBARBREAK =MF_MENUBARBREAK
constant ulong MFT_MENUBREAK =MF_MENUBREAK
constant ulong MFT_OWNERDRAW =MF_OWNERDRAW
constant ulong MFT_RADIOCHECK =512
constant ulong MFT_SEPARATOR =MF_SEPARATOR
constant ulong MFT_RIGHTORDER =8192
constant ulong MFT_RIGHTJUSTIFY =MF_RIGHTJUSTIFY
//* Menu flags for Add/Check/EnableMenuItem() */
constant ulong MFS_GRAYED =3
constant ulong MFS_DISABLED =MFS_GRAYED
constant ulong MFS_CHECKED =MF_CHECKED
constant ulong MFS_HILITE =MF_HILITE
constant ulong MFS_ENABLED =MF_ENABLED
constant ulong MFS_UNCHECKED =MF_UNCHECKED
constant ulong MFS_UNHILITE =MF_UNHILITE
constant ulong MFS_DEFAULT =MF_DEFAULT
constant long MIIM_STATE = 1
constant long MIIM_ID = 2
constant long MIIM_SUBMENU = 4
constant long MIIM_CHECKMARKS = 8
constant long MIIM_TYPE = 16
constant long MIIM_DATA = 32
constant long MIIM_ALL = MIIM_STATE + MIIM_ID + MIIM_CHECKMARKS + MIIM_SUBMENU + MIIM_TYPE + MIIM_DATA
constant long DRAWITEMSTRUCT_SIZE = 48
constant long MEASUREITEMSTRUCT_SIZE = 24
constant long MENUITEMINFO_SIZE = 44
constant ulong WM_ENTERMENULOOP = 529
constant ulong TPM_LEFTBUTTON = 0
constant ulong TPM_RIGHTBUTTON = 2
constant ulong TPM_LEFTALIGN = 0
constant ulong TPM_CENTERALIGN = 4
constant ulong TPM_RIGHTALIGN = 8
//#if(WINVER >= = 0400)
constant ulong TPM_TOPALIGN = 0
constant ulong TPM_VCENTERALIGN = 16
constant ulong TPM_BOTTOMALIGN = 32
constant ulong TPM_HORIZONTAL = 0 /* Horz alignment matters more */
constant ulong TPM_VERTICAL = 64 /* Vert alignment matters more */
constant ulong TPM_NONOTIFY = 128 /* Don't send any notification msgs */
constant ulong TPM_RETURNCMD = 256
//#endif /* WINVER >= = 0400 */
constant ulong ODA_DRAWENTIRE = 1
constant ulong ODA_SELECT = 2
constant ulong ODA_FOCUS = 4
constant ulong ODS_SELECTED = 1
constant ulong ODS_GRAYED = 2
constant ulong ODS_DISABLED = 4
constant ulong ODS_CHECKED = 8
constant ulong ODS_FOCUS = 16
//#if(WINVER >= 0x0400)
constant ulong ODS_DEFAULT = 32
constant ulong ODS_COMBOBOXEDIT = 512
constant ulong ODS_HOTLIGHT = 64
//#endif /* WINVER >= 0x0400 */
constant ulong ODT_MENU = 1
constant ulong ODT_LISTBOX = 2
constant ulong ODT_COMBOBOX = 3
constant ulong ODT_BUTTON =4
//#if(WINVER >= 0x0400)
constant ulong ODT_STATIC =5
//#endif /* WINVER >= 0x0400 */
constant ulong MF_INSERT =0
constant ulong MF_CHANGE =128
constant ulong MF_APPEND =256
constant ulong MF_DELETE =512
constant ulong MF_REMOVE =4096
constant ulong MF_BYCOMMAND =0
constant ulong MF_BYPOSITION =1024
constant ulong MF_SEPARATOR =2048
constant ulong MF_ENABLED =0
constant ulong MF_GRAYED =1
constant ulong MF_DISABLED =2
constant ulong MF_UNCHECKED =0
constant ulong MF_CHECKED =8
constant ulong MF_USECHECKBITMAPS =512
constant ulong MF_STRING =0
constant ulong MF_BITMAP =4
constant ulong MF_OWNERDRAW =256
constant ulong MF_POPUP =16
constant ulong MF_MENUBARBREAK =32
constant ulong MF_MENUBREAK =64
constant ulong MF_UNHILITE =0
constant ulong MF_HILITE =128
//#if(WINVER >= =0400)
constant ulong MF_DEFAULT =4096
//#endif /* WINVER >= =0400 */
constant ulong MF_SYSMENU =8192
constant ulong MF_HELP =16384
//#if(WINVER >= =0400)
constant ulong MF_RIGHTJUSTIFY =16384
//#endif /* WINVER >= =0400 */
constant ulong MF_MOUSESELECT =32768
//#if(WINVER >= =0400)
constant ulong MF_END =128// Obsolete -- only used by old RES files */
//#endif /* WINVER >= =0400 */
//#if(WINVER >= =0400)
constant ulong MFT_STRING =MF_STRING
constant ulong MFT_BITMAP =MF_BITMAP
constant ulong MFT_MENUBARBREAK =MF_MENUBARBREAK
constant ulong MFT_MENUBREAK =MF_MENUBREAK
constant ulong MFT_OWNERDRAW =MF_OWNERDRAW
constant ulong MFT_RADIOCHECK =512
constant ulong MFT_SEPARATOR =MF_SEPARATOR
constant ulong MFT_RIGHTORDER =8192
constant ulong MFT_RIGHTJUSTIFY =MF_RIGHTJUSTIFY
//* Menu flags for Add/Check/EnableMenuItem() */
constant ulong MFS_GRAYED =3
constant ulong MFS_DISABLED =MFS_GRAYED
constant ulong MFS_CHECKED =MF_CHECKED
constant ulong MFS_HILITE =MF_HILITE
constant ulong MFS_ENABLED =MF_ENABLED
constant ulong MFS_UNCHECKED =MF_UNCHECKED
constant ulong MFS_UNHILITE =MF_UNHILITE
constant ulong MFS_DEFAULT =MF_DEFAULT
constant long MIIM_STATE = 1
constant long MIIM_ID = 2
constant long MIIM_SUBMENU = 4
constant long MIIM_CHECKMARKS = 8
constant long MIIM_TYPE = 16
constant long MIIM_DATA = 32
constant long MIIM_ALL = MIIM_STATE + MIIM_ID + MIIM_CHECKMARKS + MIIM_SUBMENU + MIIM_TYPE + MIIM_DATA
constant long DRAWITEMSTRUCT_SIZE = 48
constant long MEASUREITEMSTRUCT_SIZE = 24
constant long MENUITEMINFO_SIZE = 44
#16
个人意见:觉得没必要讨论这个问题,有什么应用要非的修改菜单颜色呢,这个时间花在什么上面不好呢;再说,说不定pb下个版本就支持了呢。
#17
十分同意楼上意见,多学学总体设计,系统分析,怎么把数据组织好,运算速度快一些,达到设计目的。
#18
are2000(土狗) 界面 是关键,见面上去了.整体设计就比较完善了.
关注
关注
#19
可以使用ACTIVEBAR控件实现,比较方便.
#20
同意are2000(土狗) 的说法。
数据库的功能上去了,查询速度上去了。就可以了。没有必要花那么多心思在表面功夫上。
数据库的功能上去了,查询速度上去了。就可以了。没有必要花那么多心思在表面功夫上。
#21
关注
#22
我看wu_07(itsy bitsy spider)和chinalht(有多少爱,可以重来) 都是win api高手了,不错不错,俺要多学习了!!!
#23
up
#24
哈哈..........
关注之中
关注之中
#25
to chinalht(有多少爱,可以重来),你和我的想法一样哈。当时我也是看到strcopy函数用的别名是“RtlMoveMemory”,就把它用上了,用来传递MEASUREITEMSTRUCT和DRAWITEMSTRUCT的值
#26
我用自画菜单项实现了与windows开始菜单一样的效果
#27
看一下我写的程序:
http://www.pdriver.com/bbs3/cgi-bin/topic.cgi?forum=6&topic=36136&show=0
http://www.pdriver.com/bbs3/cgi-bin/topic.cgi?forum=6&topic=36136&show=0
#28
//这是从pdriver上下的一个例子
//设置文件子菜单背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic2.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//获取窗口指定子菜单的句柄
ll_hSubMenu = GetSubMenu(ll_hMainMenu, 0)
//设置菜单信息
SetMenuInfo(ll_hSubMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------------------------
//设置主菜单条背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic1.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//设置主菜单信息
SetMenuInfo(ll_hMainMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------
type menuinfo from structure
long cbsize
long fmask
long dwstyle
long cymax
long hbrback
long dwcontexthelpid
long dwmenudata
end type
//菜单相关API函数
FUNCTION Long SetMenu ( Long hwnd, Long hMenu) LIBRARY "user32"
FUNCTION Long GetMenu ( Long hwnd) LIBRARY "user32"
FUNCTION Long GetSubMenu ( Long hMenu, Long nPos) LIBRARY "user32"
FUNCTION Long DrawMenuBar ( Long hwnd) LIBRARY "user32"
FUNCTION Long SetMenuInfo (Long hmenu, REF MENUINFO mi) LIBRARY "user32"
//创建区域填充刷子函数
FUNCTION Long CreatePatternBrush(Long hBitmap) LIBRARY "gdi32.dll"
//载入位图函数
FUNCTION Long LoadImage(Long hInst, string lpsz, Long uType, Long cxDesired, Long cyDesired, Long fuLoad) LIBRARY "user32.dll" ALIAS FOR "LoadImageA"
//释放对象函数
FUNCTION Long DeleteObject(Long hObject) LIBRARY "gdi32.dll"
//LoadImage常量
CONSTANT Long LR_LOADFROMFILE = 16
CONSTANT Long IMAGE_BITMAP = 0
CONSTANT Long IMAGE_ICON = 1
CONSTANT Long IMAGE_CURSOR = 2
//MENUINFO常量
CONSTANT Long MIM_BACKGROUND = 2
CONSTANT Long MIM_APPLYTOSUBMENUS = 2147483648
//设置文件子菜单背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic2.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//获取窗口指定子菜单的句柄
ll_hSubMenu = GetSubMenu(ll_hMainMenu, 0)
//设置菜单信息
SetMenuInfo(ll_hSubMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------------------------
//设置主菜单条背景
Long ll_hwnd, ll_BitMapBrush
Long ll_hMainMenu, ll_hSubMenu
Long ll_hBitMap
String ls_BitMapFileName
MENUINFO lstr_MenuInfo
//获取菜单的父句柄
ll_hwnd = Handle(Parent)
//使用API函数LoadImage()调入BITMAP图像
ls_BitMapFileName ="Pic1.Bmp"
ll_hBitMap = LoadImage(0, ls_BitMapFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
//创建位图刷子
ll_BitMapBrush = CreatePatternBrush(ll_hBitmap)
//设置MENUINFO结构
lstr_MenuInfo.cbSize = 28
lstr_MenuInfo.cyMax = 0
lstr_MenuInfo.fMask = MIM_BACKGROUND
lstr_MenuInfo.hbrBack = ll_BitMapBrush
//获取窗口主菜单的句柄
ll_hMainMenu = GetMenu(ll_hwnd)
//设置主菜单信息
SetMenuInfo(ll_hMainMenu, lstr_MenuInfo)
//重新绘制菜单
DrawMenuBar(ll_hwnd)
//释放对象
DeleteObject(ll_hBitMap)
----------------------------------------------
type menuinfo from structure
long cbsize
long fmask
long dwstyle
long cymax
long hbrback
long dwcontexthelpid
long dwmenudata
end type
//菜单相关API函数
FUNCTION Long SetMenu ( Long hwnd, Long hMenu) LIBRARY "user32"
FUNCTION Long GetMenu ( Long hwnd) LIBRARY "user32"
FUNCTION Long GetSubMenu ( Long hMenu, Long nPos) LIBRARY "user32"
FUNCTION Long DrawMenuBar ( Long hwnd) LIBRARY "user32"
FUNCTION Long SetMenuInfo (Long hmenu, REF MENUINFO mi) LIBRARY "user32"
//创建区域填充刷子函数
FUNCTION Long CreatePatternBrush(Long hBitmap) LIBRARY "gdi32.dll"
//载入位图函数
FUNCTION Long LoadImage(Long hInst, string lpsz, Long uType, Long cxDesired, Long cyDesired, Long fuLoad) LIBRARY "user32.dll" ALIAS FOR "LoadImageA"
//释放对象函数
FUNCTION Long DeleteObject(Long hObject) LIBRARY "gdi32.dll"
//LoadImage常量
CONSTANT Long LR_LOADFROMFILE = 16
CONSTANT Long IMAGE_BITMAP = 0
CONSTANT Long IMAGE_ICON = 1
CONSTANT Long IMAGE_CURSOR = 2
//MENUINFO常量
CONSTANT Long MIM_BACKGROUND = 2
CONSTANT Long MIM_APPLYTOSUBMENUS = 2147483648