nvo_supermenu_class.sru 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971
  1. $PBExportHeader$nvo_supermenu_class.sru
  2. $PBExportComments$超级菜单对象
  3. forward
  4. global type nvo_supermenu_class from nonvisualobject
  5. end type
  6. type ust_menuinfo from structure within nvo_supermenu_class
  7. end type
  8. type tagrect from structure within nvo_supermenu_class
  9. end type
  10. type measureitemstruct from structure within nvo_supermenu_class
  11. end type
  12. type logfont from structure within nvo_supermenu_class
  13. end type
  14. type textmetric from structure within nvo_supermenu_class
  15. end type
  16. type zdrawitemstruct from structure within nvo_supermenu_class
  17. end type
  18. type us_bitmap from structure within nvo_supermenu_class
  19. end type
  20. type textsize from structure within nvo_supermenu_class
  21. end type
  22. type menuiteminfoa from structure within nvo_supermenu_class
  23. end type
  24. end forward
  25. type ust_menuinfo from structure
  26. unsignedlong itemid
  27. string itemname
  28. string shortcutkey
  29. menu menupt
  30. unsignedlong hicon
  31. integer level
  32. end type
  33. type tagrect from structure
  34. long left
  35. long top
  36. long right
  37. long bottom
  38. end type
  39. type measureitemstruct from structure
  40. long ctltype
  41. long ctlid
  42. long itemid
  43. long itemwidth
  44. long itemheight
  45. long itemdata
  46. end type
  47. type logfont from structure
  48. long lfHeight
  49. long lfWidth
  50. long lfEscapement
  51. long lfOrientation
  52. long lfWeight
  53. character lfItalic
  54. character lfUnderline
  55. character lfStrikeOut
  56. character lfCharSet
  57. character lfOutPrecision
  58. character lfClipPrecision
  59. character lfQuality
  60. character lfPitchAndFamily
  61. string lfFaceName
  62. end type
  63. type textmetric from structure
  64. long tmheight
  65. long tmascent
  66. long tmdescent
  67. long tminternalleading
  68. long tmexternalleading
  69. long tmavecharwidth
  70. long tmmaxcharwidth
  71. long tmweight
  72. long tmoverhang
  73. long tmdigitizedaspectx
  74. long tmdigitizedaspecty
  75. character tmfirstchar
  76. character tmlastchar
  77. character tmdefaultchar
  78. character tmbreakchar
  79. character tmitalic
  80. character tmunderlined
  81. character tmstruckout
  82. character tmpitchandfamily
  83. character tmcharset
  84. end type
  85. type zdrawitemstruct from structure
  86. long ctltype
  87. long ctlid
  88. long itemid
  89. long itemaction
  90. long itemstate
  91. long hwnditem
  92. long hdc
  93. tagrect rcitem
  94. long itemdata
  95. end type
  96. type us_bitmap from structure
  97. long bmtype
  98. long bmwidth
  99. long bmheight
  100. long bmwidthbytes
  101. long bmplanes
  102. long bmbitspixel
  103. blob bmbits
  104. end type
  105. type textsize from structure
  106. integer l_cx
  107. integer l_cy
  108. end type
  109. type menuiteminfoa from structure
  110. unsignedlong cbsize
  111. unsignedlong fmask
  112. unsignedlong ftype
  113. unsignedlong fstate
  114. unsignedlong wid
  115. unsignedlong hsubmenu
  116. unsignedlong hbmpchecked
  117. unsignedlong hbmpunchecked
  118. unsignedlong dwitemdata
  119. long dwtypedata
  120. unsignedlong cch
  121. end type
  122. global type nvo_supermenu_class from nonvisualobject autoinstantiate
  123. end type
  124. type prototypes
  125. //从指定窗口的结构中取得信息
  126. //FUNCTION uLong GetWindowLong(uLong hwnd, uLong nIndex) Alias For GetWindowLongA LIBRARY "USER32.DLL"
  127. //在窗口结构中为指定的窗口设置信息
  128. //FUNCTION uLong SetWindowLong(uLong hwnd, uLong nIndex,uLong dwNewLong) Alias For SetWindowLongA LIBRARY "USER32.DLL"
  129. //将消息信息传送给指定的窗口过程
  130. //FUNCTION ulong CallWindowProc(ulong lpPrevWndFunc,ulong hWnd,ulong Msg,ulong wParam,ulong lParam) LIBRARY "user32.dll" ALIAS FOR "CallWindowProcA"
  131. //在指定窗口的属性表中增加一个新项,或者修改一个现有项。如果指定的字符串不在属性表中,那么就增加该新的项,新项中包含该字符串和句柄,否则就用指定的句柄替换该字符串的全前句柄
  132. //FUNCTION ulong SetProp(ulong hwnd,ref string lpString,ulong hData) LIBRARY "user32.dll" ALIAS FOR "SetPropA"
  133. //从给定窗口的属性列表中检索数据句柄。给定的字符串标识了要检索的句柄。该字符串和句柄必须在前一次调用SetProp函数时已经加到属性表中
  134. //FUNCTION ulong GetProp(ulong hwnd,ref string lpString) LIBRARY "user32.dll" ALIAS FOR "GetPropA"
  135. //返回位于菜单中指定位置处的条目的菜单ID
  136. FUNCTION ulong GetMenuItemID(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
  137. //取得分配给指定窗口的菜单的句柄
  138. FUNCTION ulong GetMenu(ulong hwnd) LIBRARY "user32.dll"
  139. //取得被指定菜单激活的下拉式菜单或子菜单的句柄
  140. FUNCTION ulong GetSubMenu(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
  141. //将指定菜单项的正文字符串拷贝到指定缓冲区
  142. FUNCTION ulong GetMenuString(ulong hMenu,ulong wIDItem,ref string lpString,ulong nMaxCount,ulong wFlag) LIBRARY "user32.dll" ALIAS FOR "GetMenuStringA;Ansi"
  143. //改变菜单条目
  144. FUNCTION ulong ModifyMenu(ulong hMenu,ulong nPosition,ulong wFlags,ulong wIDNewItem,string lpString) LIBRARY "user32.dll" ALIAS FOR "ModifyMenuA;Ansi"
  145. //文本绘图函数
  146. //FUNCTION ulong TextOut(ulong hdc,ulong x,ulong y,ref string lpString,ulong nCount) LIBRARY "gdi32.dll" ALIAS FOR "TextOutA"
  147. //内存拷贝
  148. SUBROUTINE CopyMemory(ref measureitemstruct pDesc, ulong pSource,ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
  149. SUBROUTINE CopyMemory(ref zdrawitemstruct pDesc, ulong pSource,ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
  150. SUBROUTINE CopyMemory(ulong pDesc, ref measureitemstruct pSource, ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
  151. SUBROUTINE CopyMemory(ulong pDesc, ref zdrawitemstruct pSource,ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
  152. //用指定的刷子填充一个矩形
  153. FUNCTION ulong FillRect(ulong hdc,ref tagrect lpRect,ulong hBrush) LIBRARY "user32.dll" alias for "FillRect;Ansi"
  154. //用纯色创建一个刷子
  155. FUNCTION ulong CreateSolidBrush(ulong crColor) LIBRARY "gdi32.dll"
  156. //为任何一种标准系统颜色取得一个刷子
  157. FUNCTION ulong GetSysColorBrush(ulong nIndex) LIBRARY "user32.dll"
  158. //判断指定windows显示对象的颜色
  159. FUNCTION ulong GetSysColor(ulong nIndex) LIBRARY "user32.dll"
  160. //指定阴影刷子、虚线画笔以及字符中的空隙的填充方式
  161. FUNCTION ulong SetBkMode(ulong hdc,ulong nBkMode) LIBRARY "gdi32.dll"
  162. //为指定的设备场景设置背景颜色。背景颜色用于填充阴影刷子、虚线画笔以及字符(如背景模式为OPAQUE)中的空隙。也在位图颜色转换期间使用
  163. FUNCTION ulong SetBkColor(ulong hdc,ulong crColor) LIBRARY "gdi32.dll"
  164. //设置当前文本颜色。这种颜色也称为“前景色”
  165. FUNCTION ulong SetTextColor(ulong hdc,ulong crColor) LIBRARY "gdi32.dll"
  166. //将一幅位图从一个设备场景复制到另一个。源和目标DC相互间必须兼容。这个函数会在设备场景中定义一个目标矩形,并在位图中定义一个源图象。源矩形会根据需要进行伸缩,以便与目标矩形的大小相符
  167. //FUNCTION ulong StretchBlt(ulong hdc,ulong x,ulong y,ulong nWidth,ulong nHeight,ulong hSrcDC,ulong xSrc,ulong ySrc,ulong nSrcWidth,ulong nSrcHeight,ulong dwRop) LIBRARY "gdi32.dll"
  168. //将文本描绘到指定的矩形中
  169. FUNCTION ulong DrawText(ulong hdc,string lpStr,ulong nCount,ref tagrect lpRect,ulong wFormat) LIBRARY "user32.dll" ALIAS FOR "DrawTextA;Ansi"
  170. //用指定的样式描绘一个矩形的边框
  171. FUNCTION boolean DrawEdge(ulong hdc,ref tagrect qrc,ulong edge,ulong grfFlags) LIBRARY "user32.dll" alias for "DrawEdge;Ansi"
  172. //释放由调用GetDC或GetWindowDC函数获取的指定设备场景。它对类或私有设备场景无效(但这样的调用不会造成损害)
  173. FUNCTION ulong ReleaseDC(ulong hwnd,ulong hdc) LIBRARY "user32.dll"
  174. //删除专用设备场景或信息场景,释放所有相关窗口资源
  175. FUNCTION ulong DeleteDC(ulong hdc) LIBRARY "gdi32.dll"
  176. //每个设备场景都可能有选入其中的图形对象。其中包括位图、刷子、字体、画笔以及区域等等。一次选入设备场景的只能有一个对象。选定的对象会在设备场景的绘图操作中使用。例如,当前选定的画笔决定了在设备场景中描绘的线段颜色及样式
  177. FUNCTION ulong SelectObject(ulong hdc,ulong hObject) LIBRARY "gdi32.dll"
  178. //用这个函数删除GDI对象,比如画笔、刷子、字体、位图、区域以及调色板等等。对象使用的所有系统资源都会被释放
  179. FUNCTION ulong DeleteObject(ulong hObject) LIBRARY "gdi32.dll"
  180. //用指定的样式、宽度和颜色创建一个画笔
  181. FUNCTION ulong CreatePen(ulong nPenStyle,ulong nWidth,ulong crColor) LIBRARY "gdi32.dll"
  182. //为指定的设备场景指定一个新的当前画笔位置。前一个位置保存在lpPoint中
  183. FUNCTION ulong MoveToEx(ulong hdc,ulong x,ulong y,ulong lpPoint) LIBRARY "gdi32.dll"
  184. //用当前画笔画一条线,从当前位置连到一个指定的点。这个函数调用完毕,当前位置变成x,y点
  185. FUNCTION ulong LineTo(ulong hdc,ulong x,ulong y) LIBRARY "gdi32.dll"
  186. //校验窗口的全部或部分客户区。这样便可告之windows指定的区域不需要重画
  187. //FUNCTION ulong ValidateRect(ulong hwnd,ref tagrect lpRect) LIBRARY "user32.dll"
  188. //取回与某一设备场景相关的窗口的句柄
  189. //FUNCTION ulong WindowFromDC(ulong hdc) LIBRARY "user32.dll"
  190. //获取指定窗口的设备场景
  191. FUNCTION ulong GetDC(ulong hwnd) LIBRARY "user32.dll"
  192. //载入一个位图、图标或指针
  193. FUNCTION ulong LoadImage(ulong hInst,string lpsz,ulong un1,ulong n1,ulong n2,ulong un2) LIBRARY "user32.dll" ALIAS FOR "LoadImageA;Ansi"
  194. //在指定的位置画一个图标
  195. //FUNCTION ulong DrawIcon(ulong hdc,ulong x,ulong y,ulong hIcon) LIBRARY "user32.dll"
  196. FUNCTION boolean DrawIconEx(ulong hdc,ulong xLeft,ulong yTop,ulong hIcon,ulong cxWidth,ulong cyWidth,ulong istepIfAniCur,ulong hbrFlickerFreeDraw,ulong diFlags) LIBRARY "user32.dll"
  197. //创建一幅与设备有关位图,它与指定的设备场景兼容
  198. //FUNCTION ulong CreateCompatibleBitmap(ulong hdc,ulong nWidth,ulong nHeight) LIBRARY "gdi32.dll"
  199. //在指定的设备场景中设置一个像素的RGB值
  200. //FUNCTION ulong SetPixel(ulong hdc,ulong x,ulong y,ulong crColor) LIBRARY "gdi32.dll"
  201. //Function Long GetMenuItemRect (long hWnd,long hMenu, long uItem, tagrect lprcItem)Library "user32"
  202. FUNCTION ulong GetTextFace(ulong hdc,ulong nCount,ref string lpFacename) LIBRARY "gdi32.dll" ALIAS FOR "GetTextFaceA;Ansi"
  203. FUNCTION ulong GetTextMetrics(ulong hdc,ref TEXTMETRIC lpMetrics) LIBRARY "gdi32.dll" ALIAS FOR "GetTextMetricsA;Ansi"
  204. FUNCTION ulong CreateFontIndirect(ref LOGFONT lpLogFont) LIBRARY "gdi32.dll" ALIAS FOR "CreateFontIndirectA;Ansi"
  205. FUNCTION boolean DrawState(ulong hDC,ulong hBrush,ulong lpDrawStateProc,ulong lParam,ulong wParam,ulong n1,ulong n2,ulong n3,ulong n4,ulong un) LIBRARY "user32.dll" ALIAS FOR "DrawStateA"
  206. FUNCTION ulong DestroyIcon(ulong hIcon) LIBRARY "user32.dll"
  207. //Added by 王无敌
  208. FUNCTION ulong Rectangle(ulong hdc,ulong X1,ulong Y1,ulong X2,ulong Y2) LIBRARY "gdi32.dll"
  209. //Added by bluetlck
  210. //computes the width and height of the specified string of text
  211. FUNCTION ulong GetTextExtentPoint32(ulong hdc,ref string lpsz,ulong cbString,ref TEXTSIZE lpSize) LIBRARY "gdi32.dll" ALIAS FOR "GetTextExtentPoint32A;Ansi"
  212. //changes information about a menu item
  213. FUNCTION boolean SetMenuItemInfo(ulong hMenu,ulong un,boolean bool,ref MENUITEMINFOA lpcMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "SetMenuItemInfoA;Ansi"
  214. //retrieves information about a menu item.
  215. FUNCTION boolean GetMenuItemInfo(ulong hMenu,ulong un,boolean b,ref MENUITEMINFOA lpMenuItemInfo1) LIBRARY "user32.dll" ALIAS FOR "GetMenuItemInfoA;Ansi"
  216. FUNCTION ulong GetMenuItemCount(ulong hMenu) LIBRARY "user32.dll"
  217. FUNCTION ulong GetSystemMetrics(ulong nIndex) LIBRARY "user32.dll"
  218. FUNCTION ulong GetSystemMenu(ulong hwnd,boolean bRevert) LIBRARY "user32.dll"
  219. FUNCTION ulong DeleteMenu(ulong hMenu,ulong nPosition,ulong wFlags) LIBRARY "user32.dll"
  220. function long LoadLibrary( ref string lpLibFileName2 ) LIBRARY "KERNEL32" Alias For "LoadLibraryA;Ansi"
  221. function long FreeLibrary( long hinstance ) LIBRARY "KERNEL32"
  222. FUNCTION ulong LoadBitmap(ulong hInstance, long lpBitmapName) LIBRARY "user32.dll" ALIAS FOR "LoadBitmapA"
  223. FUNCTION ulong CreateDC(string lpDriverName,string lpDeviceName, string lpOutput, long lpInitData) LIBRARY "gdi32.dll" ALIAS FOR "CreateDCA;Ansi"
  224. FUNCTION ulong CreateCompatibleDC(ulong hdc) LIBRARY "gdi32.dll"
  225. FUNCTION ulong GetPixel(ulong hdc,ulong x,ulong y) LIBRARY "gdi32.dll"
  226. FUNCTION ulong LoadImage(ulong hInst,long lpsz,ulong un1,ulong n1,ulong n2,ulong un2) LIBRARY "user32.dll" ALIAS FOR "LoadImageA"
  227. //if it's use in other version ,please modify by hand.
  228. FUNCTION long FN_ResGetIconID(string lpLibFileName) LIBRARY "PBVM80.dll" alias for "FN_ResGetIconID;Ansi"
  229. FUNCTION long FN_ResGetBitmapID(string lpLibFileName) LIBRARY "PBVM80.dll" alias for "FN_ResGetBitmapID;Ansi"
  230. FUNCTION string FN_ResGetBitmapName(long lpLibFileName) LIBRARY "PBVM80.dll" alias for "FN_ResGetBitmapName;Ansi"
  231. Function Long ImageList_Create (Long MinCx , Long MinCy , Long flags ,Long cInitial ,Long cGrow) Library "PBVM80.dll" ALIAS FOR "PBImageList_Create"
  232. Function Long ImageList_AddMasked(Long hImageList ,Long hbmImage , Long crMask ) Library "PBVM80.dll" ALIAS FOR "PBImageList_AddMasked"
  233. Function Long ImageList_GetIcon(Long hImageList , Long ImgIndex , Long hbmMask ) Library "PBVM80.dll" ALIAS FOR "PBImageList_GetIcon"
  234. Function Long ImageList_Destroy(Long hImageList) Library "PBVM80.dll" ALIAS FOR "PBImageList_Destroy"
  235. //ImageList 函数
  236. //Function Long ImageList_Create (Long MinCx , Long MinCy , Long flags ,Long cInitial ,Long cGrow) Library "COMCTL32.DLL"
  237. //Function Long ImageList_AddMasked(Long hImageList ,Long hbmImage , Long crMask ) Library "COMCTL32.DLL"
  238. //Function Long ImageList_GetIcon(Long hImageList , Long ImgIndex , Long hbmMask ) Library "COMCTL32.DLL"
  239. FUNCTION ulong RoundRect(ulong hdc,ulong X1,ulong Y1,ulong X2,ulong Y2,ulong X3,ulong Y3) LIBRARY "gdi32.dll"
  240. FUNCTION ulong GetStockObject(ulong nIndex) LIBRARY "gdi32.dll"
  241. end prototypes
  242. type variables
  243. //------------------------------------------------------------------
  244. Public:
  245. //------------------------------------------------------------------
  246. Integer MenuStyle = 1
  247. CONSTANT INTEGER STYLE_NORMAL = 1
  248. CONSTANT INTEGER STYLE_OFFICE2K = 2
  249. CONSTANT INTEGER STYLE_STYLE3 = 3
  250. CONSTANT INTEGER STYLE_GRADIENT = 4
  251. CONSTANT INTEGER STYLE_VGRADIENT = 5
  252. CONSTANT INTEGER STYLE_VHEADERGRADIENT = 6
  253. CONSTANT INTEGER STYLE_VEDGEGRADIENT = 7
  254. CONSTANT INTEGER STYLE_OFFICEXP = 8
  255. CONSTANT INTEGER STYLE_OFFICEXP2 = 9
  256. CONSTANT INTEGER STYLE_TERMINAL_XP = 10
  257. CONSTANT INTEGER STYLE_COLOR_INFOBK = 11
  258. //background style:
  259. //============= bluetlck add. =========================
  260. Integer MenuBKStyle = 0
  261. CONSTANT INTEGER STYLE_BKNORMAL = 0
  262. CONSTANT INTEGER STYLE_BKWhite = 1
  263. CONSTANT INTEGER STYLE_BKGRAY = 2
  264. CONSTANT INTEGER STYLE_BKGRAY_XP = 3
  265. CONSTANT INTEGER STYLE_BKAMB = 4
  266. //Gradient style:
  267. //============= rjh add. =========================
  268. LONG COLOR_START = 0
  269. LONG COLOR_END = 0
  270. //------------------------------------------------------------------
  271. Private:
  272. //------------------------------------------------------------------
  273. MENUITEMINFOA lpMenuItemInfo
  274. long il_winhandle
  275. window iw_win
  276. ust_menuinfo ist_menuinfo[]
  277. integer ii_num
  278. //=========== Constant ============
  279. //SetBkMode
  280. CONSTANT ulong TRANSPARENT = 1
  281. //DrawEdge
  282. CONSTANT uLong BDR_RAISEDOUTER = 1
  283. CONSTANT uLong BDR_SUNKENOUTER = 2
  284. CONSTANT uLong BDR_RAISEDINNER = 4
  285. CONSTANT uLong BDR_SUNKENINNER = 8
  286. CONSTANT uLong BDR_OUTER = 3
  287. CONSTANT uLong BDR_INNER = 12
  288. CONSTANT uLong BF_LEFT = 1
  289. CONSTANT uLong BF_RIGHT = 4
  290. CONSTANT uLong BF_TOP = 2
  291. CONSTANT uLong BF_BOTTOM = 8
  292. CONSTANT uLong BF_RECT = 1
  293. //GetSysColor GetSysColorBrush
  294. CONSTANT uLong COLOR_BACKGROUND=1
  295. CONSTANT uLong COLOR_HIGHLIGHT= 13
  296. CONSTANT uLong COLOR_HIGHLIGHTTEXT = 14
  297. CONSTANT uLong COLOR_MENU = 4
  298. CONSTANT uLong COLOR_WINDOW = 5
  299. CONSTANT uLong COLOR_MENUTEXT = 7
  300. CONSTANT uLong COLOR_WINDOWTEXT = 8
  301. CONSTANT uLong COLOR_ACTIVECAPTION = 2
  302. CONSTANT uLong COLOR_BTNFACE = 15
  303. CONSTANT uLong COLOR_INFOBK = 24
  304. Constant integer COLOR_BTNHIGHLIGHT = 20
  305. Constant integer COLOR_BTNSHADOW = 16
  306. //ModifyMenu,Get
  307. CONSTANT uLong MF_BITMAP = 4
  308. CONSTANT uLong MF_BYCOMMAND = 0
  309. CONSTANT uLong MF_BYPOSITION = 1024
  310. CONSTANT uLong MF_CHECKED = 8
  311. CONSTANT uLong MF_DISABLED = 2
  312. CONSTANT uLong MF_ENABLED = 0
  313. CONSTANT uLong MF_GRAYED = 1
  314. CONSTANT uLong MF_MENUBARBREAK = 32
  315. CONSTANT uLong MF_MENUBREAK = 64
  316. CONSTANT uLong MF_OWNERDRAW = 256
  317. CONSTANT uLong MF_POPUP = 16
  318. CONSTANT uLong MF_SEPARATOR = 2048
  319. CONSTANT uLong MF_STRING = 0
  320. CONSTANT uLong MF_UNCHECKED = 0
  321. //LoadImage
  322. CONSTANT uLong IMAGE_BITMAP = 0
  323. CONSTANT uLong IMAGE_ICON = 1
  324. CONSTANT uLong IMAGE_CURSOR = 2
  325. CONSTANT uLong IMAGE_ENHMETAFILE = 3
  326. CONSTANT uLong LR_DEFAULTCOLOR = 0
  327. CONSTANT uLong LR_MONOCHROME = 1
  328. CONSTANT uLong LR_COLOR = 2
  329. CONSTANT uLong LR_COPYRETURNORG = 4
  330. CONSTANT uLong LR_COPYDELETEORG = 8
  331. CONSTANT uLong LR_LOADFROMFILE = 16
  332. CONSTANT uLong LR_LOADTRANSPARENT = 32
  333. CONSTANT uLong LR_DEFAULTSIZE = 64
  334. CONSTANT uLong LR_VGACOLOR = 128
  335. CONSTANT uLong LR_LOADMAP3DCOLORS = 4096
  336. CONSTANT uLong LR_CREATEDIBSECTION = 8192
  337. CONSTANT uLong LR_COPYFROMRESOURCE = 16384
  338. CONSTANT uLong LR_SHARED = 32768
  339. //CreatePen
  340. CONSTANT uLong PS_SOLID = 0
  341. //
  342. CONSTANT uLong SRCCOPY = 13369376
  343. //DrawText
  344. CONSTANT uLong DT_LEFT = 0
  345. CONSTANT uLong DT_CENTER = 1
  346. CONSTANT uLong DT_RIGHT = 2
  347. CONSTANT uLong DT_VCENTER = 4
  348. CONSTANT uLong DT_SINGLELINE = 32
  349. CONSTANT uLong DT_CALCRECT = 1024
  350. Constant integer DST_ICON = 3
  351. Constant integer DST_BITMAP =4
  352. Constant integer DSS_NORMAL =0
  353. Constant integer DSS_DISABLED = 32
  354. Constant int SM_CYMENU = 15
  355. Constant int SM_CXMENUCHECK = 71
  356. //use in GetStockObject
  357. Constant int WHITE_BRUSH=0
  358. Constant int GRAY_BRUSH =1
  359. Constant int LTGRAY_BRUSH=2
  360. Constant int DKGRAY_BRUSH=3
  361. Constant int BLACK_BRUSH=4
  362. Constant int NULL_BRUSH=5
  363. Constant int WHITE_PEN=6
  364. Constant int BLACK_PEN=7
  365. Constant int NULL_PEN=8
  366. Constant int OEM_FIXED_FONT=10
  367. Constant int ANSI_FIXED_FONT=11
  368. Constant int ANSI_VAR_FONT=12
  369. Constant int SYSTEM_FONT=13
  370. end variables
  371. forward prototypes
  372. public subroutine of_color2rgb (long lg_color, ref integer r, ref integer g, ref integer b)
  373. public function long of_getstockicon (string as_stockbitmap, ref integer ai_imagetype)
  374. private function unsignedlong of_getmenufont (long hdc)
  375. public subroutine of_xprect (unsignedlong hdc, tagrect rect, long al_pencolor, long al_brushcolor)
  376. public function long of_geticonhandle (string as_iconname)
  377. private function integer of_find_bymenuid (string as_itemname)
  378. private function integer of_find_byid (long al_itemid)
  379. private function integer of_find_byname (string as_itemname)
  380. public subroutine of_setmenuicon (string as_type, string as_itemname, string as_icon)
  381. public function long of_getmaskcolor (long al_bitmaphandle)
  382. private function integer of_add (long al_itemid, string as_text, ref menu am_menu, integer ai_level)
  383. public subroutine of_registermenu (integer ai_level, long al_hmenu, long al_hsysmenu)
  384. public subroutine of_drawitem (ref unsignedlong childid, ref long drawitemstruct)
  385. private subroutine of_drawtext (unsignedlong hdc, string as_text, string as_shortcutkey, tagrect ast_rect, boolean ab_enabled)
  386. public subroutine of_registermenu (ref menu am_menu, integer ai_level, long al_hmenu, long al_hsysmenu)
  387. public subroutine of_drawchecked (long hdc, ref tagrect rect)
  388. private function unsignedlong of_createverticalfont (long hdc)
  389. public function boolean of_containselement (long al_src, long al_exponent)
  390. public subroutine of_fillwithgradient (unsignedlong hdc, tagrect rect, long colorfrom, long colorto)
  391. private subroutine of_drawfirstlevelmenu (ref zdrawitemstruct ast_drawitemstruct, ref ust_menuinfo ast_menuinfo)
  392. private subroutine of_drawnormalitem (integer ai_menubkstyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo)
  393. public function decimal of_getshortcutkeyrate (menu am_menu)
  394. public subroutine of_setvisible (menu am_menu, boolean ab_visible)
  395. public subroutine of_registerwindow (readonly window aw_win)
  396. public function boolean of_iswhitespace (string as_source)
  397. public subroutine of_measureitem (ref unsignedlong childid, ref long measureitemstruct)
  398. private subroutine of_drawselectitem (integer ai_menustyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo)
  399. end prototypes
  400. public subroutine of_color2rgb (long lg_color, ref integer r, ref integer g, ref integer b);//长整型颜色值,转为RGB型,需要三个ref参数
  401. b = lg_color / 65536
  402. g = (lg_color - b * 65536) / 256
  403. r = lg_color - g * 256 - b * 65536
  404. end subroutine
  405. public function long of_getstockicon (string as_stockbitmap, ref integer ai_imagetype);//////////////////////////////////////////////////////////////////////////////
  406. //
  407. // 函数名称: Of_getstockicon
  408. // 访问级别: Public
  409. // 参数: as_stockbitmap stock位图名称
  410. // ai_imagetype 位图 or 图标标示
  411. // 返回值: Long
  412. // 功能描述: 得到系统stock位图相应的标识符
  413. // 补充说明:
  414. //
  415. //////////////////////////////////////////////////////////////////////////////
  416. // 修改记录:2001-11-15
  417. // 设计:何锐
  418. // 编码:何锐
  419. // 审核:何锐
  420. ////////////////////////////////////////////////////////////////////////////
  421. Long ll_Identifier
  422. //检查参数
  423. If IsNull(as_StockBitmap) Or as_StockBitmap="" Then Return -1
  424. ll_Identifier = FN_ResGetBitmapID(as_stockbitmap)
  425. if ll_Identifier<=0 then
  426. ll_Identifier = FN_ResGetIconID(as_stockbitmap)
  427. ai_imagetype= IMAGE_ICON
  428. else //位图
  429. ai_imagetype = IMAGE_BITMAP
  430. end if
  431. return ll_Identifier
  432. end function
  433. private function unsignedlong of_getmenufont (long hdc);//-------------------------------------------------------*
  434. // FUNCTION: of_getmenufont *
  435. // Description: *
  436. //-------------------------------------------------------*
  437. // Arguments:
  438. //
  439. // long hdc
  440. // *
  441. //-------------------------------------------------------*
  442. // Author(s) Date Remark *
  443. // Rain 2003.03.10 *
  444. //-------------------------------------------------------*
  445. long ll_menufont
  446. long ll_textlen = 255
  447. string ls_text = space(255)
  448. LOGFONT ltLF_FONT
  449. TEXTMETRIC ltTM
  450. //IF il_menufont = 0 THEN
  451. ll_textlen = GetTextFace(hdc, ll_TextLen, ls_Text)
  452. GetTextMetrics(hdc,ltTm)
  453. ltLF_FONT.lfFaceName = Left(ls_text, ll_textlen+1 )
  454. ltLF_FONT.lfHeight = ltTM.tmHeight
  455. ltLF_FONT.lfWeight = ltTM.tmWeight
  456. ll_menufont = CreateFontIndirect(ltLF_FONT)
  457. //END IF
  458. RETURN ll_menufont
  459. end function
  460. public subroutine of_xprect (unsignedlong hdc, tagrect rect, long al_pencolor, long al_brushcolor);//--------------------------------------------------------------------
  461. // The function was added By: 王无敌 Date: 2003.03.02
  462. // Modified By: 王无敌 Date: 2003.03.16
  463. //--------------------------------------------------------------------
  464. uLong hOldPen, hPen
  465. uLong xp1,yp1,xp2,yp2
  466. uLong hNewBrush,hOldBrush
  467. xp1 = rect.Left
  468. yp1 = rect.top
  469. xp2 = rect.Right
  470. yp2 = rect.bottom
  471. hPen = CreatePen(PS_SOLID, 1, al_PenColor)
  472. hOldPen = SelectObject(hdc, hPen)
  473. hNewBrush =CreateSolidBrush(al_BrushColor)
  474. hOldBrush =SelectObject(hdc, hNewBrush)
  475. rectangle(hdc,xp1,yp1,xp2,yp2)
  476. SelectObject(hdc, hOldPen)
  477. DeleteObject(hPen)
  478. SelectObject(hdc, hOldBrush)
  479. DeleteObject(hNewBrush)
  480. end subroutine
  481. public function long of_geticonhandle (string as_iconname);//====================================================================
  482. // Function: of_geticonhandle()
  483. //--------------------------------------------------------------------
  484. // Description: Get the handle of icon from the toolbaritemname of the menu
  485. //--------------------------------------------------------------------
  486. // Arguments:
  487. // value string as_iconname
  488. //--------------------------------------------------------------------
  489. // Returns: long IconHandle
  490. //--------------------------------------------------------------------
  491. // Author: Dale Zheng Date: 2003.05.07
  492. //--------------------------------------------------------------------
  493. // Modify History:
  494. //
  495. //====================================================================
  496. Long ll_BitmapHandle , ll_IconHandle , ll_Library , ll_Index=-1
  497. Environment env
  498. Integer rtn,li_imagetype
  499. String ls_File
  500. Long ll_identier
  501. long ll_hIml
  502. if pos(lower(as_iconname),'.ico')>0 then
  503. ll_IconHandle= LoadImage(0,as_iconname,IMAGE_ICON,0,0,LR_LOADFROMFILE + LR_DEFAULTSIZE)
  504. elseif pos(lower(as_iconname),'.bmp')>0 then
  505. ll_BitmapHandle = LoadImage(0,as_iconname,IMAGE_BITMAP,16,16,LR_LOADFROMFILE)
  506. ll_hIml = ImageList_Create (16 , 16 , 33, 4, 4)
  507. ll_Index = ImageList_AddMasked(ll_hIml , ll_BitmapHandle , Of_GetMaskColor(ll_BitmapHandle))
  508. ll_IconHandle= ImageList_GetIcon( ll_hIml , ll_Index , 1)
  509. //DeleteObject(ll_hIml)
  510. ImageList_Destroy(ll_hIml)
  511. DeleteObject(ll_BitmapHandle)
  512. elseif pos(as_iconname,'!')>0 then
  513. rtn = GetEnvironment(env)
  514. IF rtn <> 1 THEN
  515. MessageBox("TIP","Get the value is wrrong in the PowerBuilder Environment.",StopSign!,Ok!)
  516. Return -1
  517. End If
  518. ls_File = "PBVM" + String(env.PBMajorRevision) + "0.DLL"
  519. ll_Library = LoadLibrary(ls_File)
  520. ll_identier = Of_GetStockicon(as_iconname,li_imagetype)
  521. If ll_identier >0 and li_imagetype = IMAGE_BITMAP Then
  522. ll_BitmapHandle = LoadBitmap ( ll_Library , ll_identier)
  523. ll_hIml = ImageList_Create (16 , 16 , 33, 4, 4)
  524. ll_Index = ImageList_AddMasked(ll_hIml , ll_BitmapHandle , Of_GetMaskColor(ll_BitmapHandle))
  525. ll_IconHandle= ImageList_GetIcon( ll_hIml , ll_Index , 1)
  526. //DeleteObject(ll_hIml)
  527. ImageList_Destroy(ll_hIml)
  528. DeleteObject(ll_BitmapHandle)
  529. elseIf ll_identier >0 and li_imagetype = IMAGE_ICON Then
  530. ll_IconHandle= LoadImage(ll_Library,ll_identier,IMAGE_ICON,0,0, LR_DEFAULTSIZE )
  531. Else
  532. ll_index = -1
  533. End If
  534. FreeLibrary ( ll_Library )
  535. else
  536. return 0
  537. end if
  538. return ll_IconHandle
  539. end function
  540. private function integer of_find_bymenuid (string as_itemname);INTEGER li_loop,li_ret = 0
  541. FOR li_loop = 1 TO UpperBound(ist_menuinfo)
  542. IF isvalid(ist_menuinfo[li_loop].Menupt) then
  543. IF ist_menuinfo[li_loop].Menupt.classname() = as_ItemName THEN
  544. li_ret = li_loop
  545. EXIT
  546. END IF
  547. end if
  548. NEXT
  549. RETURN li_ret
  550. end function
  551. private function integer of_find_byid (long al_itemid);INTEGER li_loop,li_upper,li_ret = 0
  552. if al_ItemID <= 0 then return 0
  553. li_upper = UpperBound(ist_menuinfo)
  554. IF li_upper>al_ItemID then //一般情况下,数组中位置和al_ItemID一致
  555. if ist_menuinfo[al_ItemID].ItemID = al_ItemID THEN return al_ItemID
  556. end if
  557. FOR li_loop = 1 TO li_upper
  558. IF ist_menuinfo[li_loop].ItemID = al_ItemID THEN
  559. li_ret = li_loop
  560. EXIT
  561. END IF
  562. NEXT
  563. RETURN li_ret
  564. end function
  565. private function integer of_find_byname (string as_itemname);INTEGER li_loop,li_pos,li_ret = 0
  566. string ls_menuText
  567. li_pos = POS(as_ItemName,"~t")
  568. IF li_pos > 0 THEN
  569. as_ItemName= LEFT(as_ItemName,li_pos - 1)
  570. END IF
  571. FOR li_loop = 1 TO UpperBound(ist_menuinfo)
  572. ls_menuText =ist_menuinfo[li_loop].ItemName
  573. IF trim(ls_menuText) = trim(as_ItemName) THEN
  574. li_ret = li_loop
  575. EXIT
  576. END IF
  577. NEXT
  578. RETURN li_ret
  579. end function
  580. public subroutine of_setmenuicon (string as_type, string as_itemname, string as_icon);//-------------------------------------------------------*
  581. // FUNCTION: of_setmenuicon *
  582. // Description: *
  583. //-------------------------------------------------------*
  584. // Parameters: string as_type *
  585. // string as_itemname *
  586. // string as_icon *
  587. //-------------------------------------------------------*
  588. // Author(s) Date Remark *
  589. // 贱客无名 2003.02.27 Develop *
  590. // Rain 2003.03.10 load icon immediately, *
  591. // add item by 'ID' or 'TEXT' *
  592. //-------------------------------------------------------*
  593. integer li_menupos
  594. IF Upper(as_type)='BYID' OR upper(as_type) = 'ID' THEN
  595. li_menupos = of_find_bymenuid(as_itemname)
  596. ELSE
  597. li_menupos = of_find_byname(as_itemname)
  598. END IF
  599. IF li_menupos <>0 THEN
  600. IF ist_menuinfo[li_menupos].hIcon= 0 THEN
  601. //ist_menuinfo[li_menupos].hIcon = LoadImage(0,as_icon,IMAGE_ICON,16,16,LR_LOADFROMFILE + LR_DEFAULTSIZE)
  602. ist_menuinfo[li_menupos].hIcon=of_GetIconHandle(as_icon)
  603. // else
  604. // DestroyIcon(ist_menuinfo[li_menupos].hIcon)
  605. // ist_menuinfo[li_menupos].hIcon=of_GetIconHandle(as_icon)
  606. END IF
  607. END IF
  608. end subroutine
  609. public function long of_getmaskcolor (long al_bitmaphandle);//////////////////////////////////////////////////////////////////////////////
  610. // 函数名称: Of_GetMaskColor
  611. // 访问级别: Public
  612. // 参数: al_BitmapHandle 位图句柄
  613. // 返回值: Long
  614. // 功能描述: 获得指定位图文件的Mask颜色,返回值为Mask颜色
  615. // 补充说明:
  616. //
  617. //////////////////////////////////////////////////////////////////////////////
  618. //
  619. // 修改记录:2001-11-15
  620. //
  621. //////////////////////////////////////////////////////////////////////////////
  622. // 编码:何锐
  623. ////////////////////////////////////////////////////////////////////////////
  624. String ls_Null
  625. Long ll_Hdc,ll_HDCTemp,ll_HbmpTemp
  626. Long ll_MaskColor = -1
  627. ll_HDC = CreateDC("DISPLAY",ls_Null,ls_Null,0)
  628. If ll_HDC<>0 Then
  629. //创建一个与指定设备兼容的内存上下文环境
  630. ll_HDCTemp = CreateCompatibleDC(ll_HDC)
  631. If ll_HDCTemp<>0 Then
  632. //选择一个对象到指定的设备上下文环境
  633. ll_HbmpTemp = SelectObject(ll_HDCTemp, al_BitMapHandle)
  634. //获得位图坐标(0,0)颜色值
  635. ll_MaskColor = GetPixel(ll_HDCTemp,0,0)
  636. SelectObject(ll_HDCTemp,ll_HbmpTemp)
  637. DeleteDC(ll_HDCTemp)
  638. End If
  639. DeleteDC(ll_HDC)
  640. End If
  641. Return ll_MaskColor
  642. end function
  643. private function integer of_add (long al_itemid, string as_text, ref menu am_menu, integer ai_level);//-------------------------------------------------------*
  644. // FUNCTION: of_add *
  645. // Description: register a menuitem *
  646. //-------------------------------------------------------*
  647. // Parameters: long al_itemid *
  648. // string as_text *
  649. // menu am_menu *
  650. //-------------------------------------------------------*
  651. // Author(s) Date Remark *
  652. // Rain 2003.03.10 Develop *
  653. //-------------------------------------------------------*
  654. //Modify History: Add:Get the icon by Dale Zheng.
  655. int li_newpos,li_pos
  656. string ls_shortcutkey
  657. li_pos = POS(as_text,"~t")
  658. IF li_pos > 0 THEN
  659. ls_shortcutkey = MID(as_text,li_pos + 1)
  660. as_text = LEFT(as_text,li_pos - 1)
  661. END IF
  662. li_newpos = upperbound(ist_menuinfo) + 1
  663. ist_menuinfo[li_newpos].ItemID = al_Itemid
  664. ist_menuinfo[li_newpos].ItemName = as_text
  665. ist_menuinfo[li_newpos].ShortcutKey = ls_ShortcutKey
  666. ist_menuinfo[li_newpos].menupt = am_menu
  667. ist_menuinfo[li_newpos].level = ai_level
  668. if am_menu.ToolbarItemName<>'' then ist_menuinfo[li_newpos].hIcon=of_GetIconHandle(am_menu.ToolbarItemName)
  669. RETURN li_newpos
  670. end function
  671. public subroutine of_registermenu (integer ai_level, long al_hmenu, long al_hsysmenu);//-------------------------------------------------------*
  672. // FUNCTION: of_registermenu *
  673. // Description: 注册未知名的菜单 *
  674. //-------------------------------------------------------*
  675. // Parameters: *
  676. // int ai_level *
  677. // long al_hmenu
  678. // long al_hsysmenu
  679. //-------------------------------------------------------*
  680. // Author(s) Date Remark *
  681. // bluetlck
  682. //-------------------------------------------------------*
  683. Constant int MIIM_STATE = 1
  684. Constant int MIIM_ID = 2
  685. Constant int MIIM_SUBMENU = 4
  686. Constant int MIIM_CHECKMARKS = 8
  687. Constant int MIIM_TYPE = 16
  688. Constant int MIIM_DATA = 32
  689. Constant int MFS_CHECKED = 8
  690. //Constant int MF_DISABLED = 2
  691. //Constant int MF_GRAYED = 1
  692. Integer li_index,li_row,li_count
  693. uLong hSubMenu
  694. if al_hmenu<=0 then return
  695. li_count= GetMenuItemCount(al_hmenu)
  696. string ls_menuText
  697. ls_menuText=space(255)
  698. For li_index = 1 to li_count
  699. hSubMenu = GetSubMenu(al_hmenu,li_index - 1)
  700. if al_hsysmenu = hSubMenu then
  701. li_index ++
  702. hSubMenu = GetSubMenu(al_hmenu,li_index - 1)
  703. end if
  704. if ai_level > 0 then
  705. lpMenuItemInfo.cbsize=44
  706. lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA +MIIM_STATE
  707. GetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
  708. //not ownerdraw menuitem
  709. If lpMenuItemInfo.dwItemData=0 or not of_containselement(lpMenuItemInfo.fType,MF_OWNERDRAW)then
  710. GetMenuString(al_hmenu,li_index - 1,ls_menuText,255,MF_BYPOSITION )
  711. lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA
  712. lpMenuItemInfo.fType= lpMenuItemInfo.fType+MF_OWNERDRAW
  713. if lpMenuItemInfo.dwItemData >0 then
  714. li_row = of_find_byid(lpMenuItemInfo.dwItemData)
  715. else
  716. li_row = of_find_byname(ls_menuText)
  717. end if
  718. if li_row>0 then
  719. lpMenuItemInfo.dwItemData = ist_menuinfo[li_row].ItemID
  720. if ist_menuinfo[li_row].menupt.text<>"-" then ist_menuinfo[li_row].menupt.text=ls_menuText
  721. if of_containselement(lpMenuItemInfo.fstate,MFS_CHECKED) then
  722. ist_menuinfo[li_row].menupt.checked = true
  723. else
  724. ist_menuinfo[li_row].menupt.checked = false
  725. end if
  726. if of_containselement(lpMenuItemInfo.fstate,MF_GRAYED) then
  727. ist_menuinfo[li_row].menupt.enabled = false
  728. else
  729. ist_menuinfo[li_row].menupt.enabled = true
  730. end if
  731. SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
  732. else
  733. ii_num++
  734. menu m_temp
  735. m_temp=create menu
  736. if ls_menuText="" then
  737. m_temp.enabled =false
  738. m_temp.text="-"
  739. else
  740. m_temp.text=ls_menuText
  741. if of_containselement(lpMenuItemInfo.fstate,MFS_CHECKED) then
  742. m_temp.checked = true
  743. else
  744. m_temp.checked = false
  745. end if
  746. if of_containselement(lpMenuItemInfo.fstate,MF_GRAYED) then
  747. m_temp.enabled = false
  748. else
  749. m_temp.enabled = true
  750. end if
  751. end if
  752. of_add(ii_num,ls_menuText,m_temp,ai_level)
  753. lpMenuItemInfo.dwItemData = ii_num
  754. SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
  755. end if
  756. else
  757. li_row = of_find_byid(lpMenuItemInfo.dwItemData)
  758. if li_row>0 then
  759. if of_Containselement(lpMenuItemInfo.fstate,MFS_CHECKED) then
  760. ist_menuinfo[li_row].menupt.checked = true
  761. else
  762. ist_menuinfo[li_row].menupt.checked = false
  763. end if
  764. if of_containselement(lpMenuItemInfo.fstate,MF_GRAYED) then
  765. ist_menuinfo[li_row].menupt.enabled = false
  766. else
  767. ist_menuinfo[li_row].menupt.enabled = true
  768. end if
  769. end if
  770. end if
  771. end if
  772. if hSubMenu>0 then of_registermenu(ai_level + 1,hsubMenu,al_hsysmenu)
  773. next
  774. end subroutine
  775. public subroutine of_drawitem (ref unsignedlong childid, ref long drawitemstruct);//-------------------------------------------------------*
  776. // FUNCTION: of_drawitem *
  777. // Description: draw menuitem *
  778. //-------------------------------------------------------*
  779. // Parameters: ulong childid *
  780. // long drawitemstruct *
  781. //-------------------------------------------------------*
  782. // Author(s) Date Remark *
  783. // 贱客无名 2003.02.27 Develop *
  784. // Addison lu 2003.03.03 *
  785. // Rain 2003.03.10 Draw disalbed state
  786. // Bluetlck 2003.05 modify
  787. //-------------------------------------------------------*
  788. zDrawItemStruct tDrawItemStruct
  789. uLong hdc,hIcon
  790. Integer li_row,li_level
  791. tagrect rTmp
  792. CopyMemory(tDrawItemStruct,drawitemstruct,48)
  793. hdc = tDrawItemStruct.hdc
  794. rTmp = tDrawItemStruct.rcItem
  795. li_row = of_find_byid(tDrawItemStruct.itemdata)
  796. if li_row<= 0 then return
  797. li_level = ist_menuinfo[li_row].level
  798. //if MenuBKStyle = STYLE_BKWhite and ls_ItemName<>"-" then ls_ItemName=" "+ls_ItemName
  799. IF of_containselement(tDrawItemStruct.ItemState,1) then
  800. //selected state
  801. if ist_menuinfo[li_row].menupt.enabled then
  802. of_drawselectitem(Menustyle,hdc,rTmp,ist_menuinfo[li_row])
  803. end if
  804. else
  805. of_drawnormalitem(MenuBKStyle,hdc,rTmp,ist_menuinfo[li_row])
  806. End If
  807. end subroutine
  808. private subroutine of_drawtext (unsignedlong hdc, string as_text, string as_shortcutkey, tagrect ast_rect, boolean ab_enabled);//-------------------------------------------------------*
  809. // FUNCTION: of_drawtext *
  810. // Description: *
  811. //-------------------------------------------------------*
  812. // Parameters: ulong hdc *
  813. // string as_text *
  814. // tagrect ast_rect *
  815. // boolean ab_enabled *
  816. //-------------------------------------------------------*
  817. // Author(s) Date Remark *
  818. // Rain 2003.03.10 *
  819. //-------------------------------------------------------*
  820. SetBkMode(hdc,TRANSPARENT)
  821. long lhdc_temp,MenuFont,OldFont
  822. IF ab_enabled THEN
  823. SetTextColor(hdc,GetSysColor(COLOR_MENUTEXT))
  824. DrawText(hdc,as_text,Len(as_text),ast_rect,DT_LEFT)
  825. ast_rect.Right =ast_rect.Right - 12
  826. DrawText(hdc,as_shortcutkey,Len(as_shortcutkey),ast_rect,DT_RIGHT)
  827. ELSE
  828. SetTextColor( hdc , GetSysColor( COLOR_BTNHIGHLIGHT))
  829. ast_rect.Left = ast_rect.Left + 1
  830. ast_rect.Top = ast_rect.Top + 1
  831. DrawText( hdc , as_text , len(as_text) , ast_rect, DT_VCENTER)
  832. SetTextColor( hdc,GetSysColor( COLOR_BTNSHADOW ) )
  833. ast_rect.Left = ast_rect.Left -1
  834. ast_rect.Top = ast_rect.Top -1
  835. DrawText( hdc , as_text , len(as_text) , ast_rect , DT_VCENTER)
  836. //// rjh added.
  837. SetTextColor( hdc , GetSysColor( COLOR_BTNHIGHLIGHT))
  838. //ast_rect.Left = (ast_rect.Right - 22) * ad_rate + 22 + 1
  839. ast_rect.Right =ast_rect.Right - 12
  840. ast_rect.Top += 1
  841. DrawText( hdc , as_shortcutkey , len(as_shortcutkey) , ast_rect, DT_RIGHT)
  842. SetTextColor( hdc,GetSysColor( COLOR_BTNSHADOW ) )
  843. ast_rect.Left = ast_rect.Left - 1
  844. ast_rect.Top = ast_rect.Top -1
  845. DrawText( hdc , as_shortcutkey , len(as_shortcutkey) , ast_rect , DT_RIGHT)
  846. END IF
  847. end subroutine
  848. public subroutine of_registermenu (ref menu am_menu, integer ai_level, long al_hmenu, long al_hsysmenu);//-------------------------------------------------------*
  849. // FUNCTION: of_registermenu *
  850. // Description: 注册知名的菜单 *
  851. //-------------------------------------------------------*
  852. // Parameters: menu am_menu *
  853. // int ai_level *
  854. // long al_hmenu
  855. // long al_hsysmenu
  856. //-------------------------------------------------------*
  857. // Author(s) Date Remark *
  858. // 贱客无名 2003.02.27 Develop *
  859. // Rain 2003.03.10 use array instead of ds
  860. // bluetlck 2003.04.25 use SetMenuItemInfo instead of ModifyMenu
  861. //-------------------------------------------------------*
  862. Constant int MIIM_STATE = 1
  863. Constant int MIIM_ID = 2
  864. Constant int MIIM_SUBMENU = 4
  865. //Constant int MIIM_CHECKMARKS = 8
  866. Constant int MIIM_TYPE = 16
  867. Constant int MIIM_DATA = 32
  868. Constant int MFS_CHECKED = 8
  869. Integer li_countitem,li_index,li_row,li_count
  870. Integer li_itempos //由于不可见菜单项的影响,li_index不等于menu item position
  871. uLong hSubMenu
  872. if al_hmenu<=0 then return
  873. li_countitem = UpperBound(am_menu.Item[])
  874. For li_index = 1 To li_countitem
  875. if am_menu.Item[li_index].visible=false then
  876. continue
  877. end if
  878. li_itempos++
  879. hSubMenu = GetSubMenu(al_hmenu,li_itempos - 1)
  880. if al_hsysmenu = hSubMenu then //if it's system menu
  881. li_itempos++
  882. hSubMenu = GetSubMenu(al_hmenu,li_itempos - 1)
  883. end if
  884. If am_menu.Item[li_index].Text = "-" Then am_menu.Item[li_index].Enabled = false
  885. If ai_level > 0 Then
  886. lpMenuItemInfo.cbsize=44
  887. lpMenuItemInfo.fMask = MIIM_TYPE+MIIM_DATA
  888. boolean lb_return
  889. lb_return = GetMenuItemInfo(al_hmenu,li_itempos - 1,true,lpMenuItemInfo)
  890. if lpMenuItemInfo.dwItemData=0 or not of_Containselement(lpMenuItemInfo.fType,MF_OWNERDRAW) then
  891. lpMenuItemInfo.fType= lpMenuItemInfo.fType + MF_OWNERDRAW
  892. lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA
  893. //li_row = of_find_bymenuId(am_menu.Item[li_index].classname())
  894. if lpMenuItemInfo.dwItemData>0 then li_row = of_find_byId(lpMenuItemInfo.dwItemData)
  895. if li_row<=0 then
  896. ii_num++ //菜单的唯一标示,舍弃了以前利用ItemID的方法
  897. lpMenuItemInfo.dwItemData = ii_num
  898. SetMenuItemInfo(al_hmenu,li_itempos - 1,true,lpMenuItemInfo)
  899. of_add(ii_num,am_menu.Item[li_index].Text,am_menu.item[li_index],ai_level)
  900. else
  901. lpMenuItemInfo.dwItemData = ist_menuinfo[li_row].ItemID
  902. SetMenuItemInfo(al_hmenu,li_itempos - 1,true,lpMenuItemInfo)
  903. end if
  904. end if
  905. end if
  906. if hSubMenu>0 then of_registermenu(am_menu.Item[li_index],ai_level + 1,hsubMenu,al_hsysmenu)
  907. Next
  908. //以下处理由于sheet窗口而动态生成的菜单,有一定问题!~
  909. li_count= GetMenuItemCount(al_hmenu)
  910. if li_itempos<li_count - 1 and ai_level>0 then
  911. string ls_menuText
  912. ls_menuText=space(255)
  913. For li_index = li_count to li_itempos + 1 step - 1
  914. lpMenuItemInfo.cbsize=44
  915. lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA +MIIM_STATE
  916. lb_return = GetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
  917. if lpMenuItemInfo.dwItemData=0 or not of_containselement(lpMenuItemInfo.fType,MF_OWNERDRAW) then //not ownerdraw menuitem
  918. GetMenuString(al_hmenu,li_index - 1,ls_menuText,255,MF_BYPOSITION )
  919. lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA
  920. lpMenuItemInfo.fType= lpMenuItemInfo.fType+MF_OWNERDRAW
  921. li_row = of_find_byname(ls_menuText)
  922. if li_row>0 then
  923. lpMenuItemInfo.dwItemData = ist_menuinfo[li_row].ItemID
  924. if lpMenuItemInfo.fState= MFS_CHECKED then
  925. ist_menuinfo[li_row].menupt.checked = true
  926. else
  927. ist_menuinfo[li_row].menupt.checked = false
  928. end if
  929. SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
  930. else
  931. ii_num++
  932. menu m_temp
  933. m_temp=create menu
  934. if ls_menuText="" then
  935. m_temp.enabled =false
  936. m_temp.text="-"
  937. else
  938. m_temp.text=ls_menuText
  939. if lpMenuItemInfo.fState= MFS_CHECKED then m_temp.checked = true
  940. end if
  941. of_add(ii_num,ls_menuText,m_temp,ai_level)
  942. lpMenuItemInfo.dwItemData = ii_num
  943. SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
  944. end if
  945. end if
  946. next
  947. end if
  948. end subroutine
  949. public subroutine of_drawchecked (long hdc, ref tagrect rect);long hpen,holdpen
  950. //hPen = CreatePen(PS_SOLID,2,RGB(0,0,147))
  951. //holdPen=SelectObject(hdc,hPen)
  952. //MoveToEx(hdc,rect.Left+6,rect.Top+10,0)
  953. //LineTo(hdc,rect.Left+8,rect.Top+14)
  954. //LineTo(hdc,rect.Left + 14,rect.top+ 6)
  955. tagrect fillrect
  956. fillrect.left = rect.left +8
  957. fillrect.right = rect.left +14
  958. fillrect.top = rect.top +9
  959. fillrect.bottom = rect.top +14
  960. hPen = CreatePen(PS_SOLID,1,GetSysColor(COLOR_ACTIVECAPTION))
  961. holdpen = SelectObject(hdc,hPen)
  962. RoundRect(hdc,fillrect.Left - 2,fillrect.Top - 2,fillrect.right +2,fillrect.bottom+2,4,4)
  963. SelectObject(hdc,holdPen)
  964. deleteobject(hPen)
  965. FillRect(hdc,fillrect,GetSysColorBrush(COLOR_HIGHLIGHT))
  966. end subroutine
  967. private function unsignedlong of_createverticalfont (long hdc);//-------------------------------------------------------*
  968. // FUNCTION: of_CreateVerticalFont *
  969. // Description: *
  970. //-------------------------------------------------------*
  971. // Arguments:
  972. //
  973. // long hdc
  974. // *
  975. //-------------------------------------------------------*
  976. // Author(s) Date Remark *
  977. // Rain 2003.03.10 *
  978. //-------------------------------------------------------*
  979. long ll_font
  980. long ll_textlen = 255
  981. string ls_text = space(255)
  982. LOGFONT VerticalFont
  983. ll_textlen = GetTextFace(hdc, ll_TextLen, ls_Text)
  984. VerticalFont.lfFaceName = Left(ls_text, ll_textlen+1 )
  985. VerticalFont.lfWeight = 700
  986. VerticalFont.lfEscapement = 900
  987. VerticalFont.lfOrientation = 900
  988. VerticalFont.lfHeight = - 16;
  989. ll_font = CreateFontIndirect(VerticalFont)
  990. RETURN ll_font
  991. //Type LOGFONT
  992. //lfHeight As Integer ' 字体的高度
  993. //lfWidth As Integer ' 字体的宽度
  994. //lfEscapement As Integer ' 字体旋转的角度
  995. //lfOrientation As Integer
  996. //lfWeight As Integer ' 字体的轻重
  997. //lfItalic As String * 1 ' 是否为斜体
  998. //lfUnderline As String * 1 ' 是否有下划线
  999. //lfStrikeOut As String * 1 ' 是否有强调线
  1000. //lfCharSet As String * 1 ' 字符集
  1001. //lfOutPrecision As String * 1 ' 输出精度
  1002. //lfClipPrecision As String * 1 ' 剪裁精度
  1003. //lfQuality As String * 1 ' 输出质量
  1004. //lfPitchAndFamily As String * 1 ' 间距和字体族
  1005. //lfFaceName As String * LF_FACESIZE ' 字体名,如“宋体”
  1006. //End Type
  1007. end function
  1008. public function boolean of_containselement (long al_src, long al_exponent);//判断一个数中的某个二进制位是否是1,也就是两个数求逻辑or后是否仍然是第一个数
  1009. //al_dst必须为2的整数次方(这个整数次方就是al_src的某一位,出于效率不作判断),否则结果不能预料
  1010. al_src = al_src/al_exponent
  1011. if mod(al_src,2) = 1 then
  1012. return true
  1013. else
  1014. return false
  1015. end if
  1016. end function
  1017. public subroutine of_fillwithgradient (unsignedlong hdc, tagrect rect, long colorfrom, long colorto);//--------------------------------------------------------------------
  1018. // Write By: 贱客无名 Date: 2003.02.27
  1019. // Modified by : Addison Lu Sunday, 2/3/3
  1020. //--------------------------------------------------------------------
  1021. int li_height, li_width, li, li_steps,li_halfwidth
  1022. int li_ori_left, li_ori_right
  1023. long ll_rgb
  1024. ulong hBrush, hOldBrush
  1025. int r1,r2,g1,g2,b1,b2,vr,vg,vb
  1026. IF Menustyle = STYLE_VGRADIENT THEN
  1027. GOTO VGRADIENT
  1028. END IF
  1029. IF Menustyle = STYLE_VEDGEGRADIENT THEN
  1030. GOTO VEDGEGRADIENT
  1031. END IF
  1032. IF Menustyle = STYLE_VHEADERGRADIENT THEN
  1033. GOTO VHEADERGRADIENT
  1034. END IF
  1035. li_steps = 30 - 1
  1036. li_width = (rect.right - rect.left) / li_steps
  1037. of_color2rgb(colorfrom,r1,g1,b1)
  1038. of_color2rgb(colorto,r2,g2,b2)
  1039. vr = abs(r1 - r2) / li_steps
  1040. vg = abs(g1 - g2) / li_steps
  1041. vb = abs(b1 - b2) / li_steps
  1042. IF r2<r1 THEN vr = vr * -1
  1043. IF g2<g1 THEN vg = vg * -1
  1044. IF b2<b1 THEN vb = vb * -1
  1045. SetBkMode(hdc,TRANSPARENT)
  1046. li_ori_left = rect.left
  1047. li_ori_right = rect.right
  1048. FOR li = 1 TO li_steps
  1049. r2 = r1 + vr * li
  1050. g2 = g1 + vg * li
  1051. b2 = b1 + vb * li
  1052. ll_RGB = RGB( r2, g2, b2)
  1053. rect.left = li_ori_left + (li - 1) *li_width
  1054. rect.right = rect.left + li_width
  1055. hBrush = CreateSolidBrush(ll_rgb)
  1056. FillRect(hdc,rect,hBrush)
  1057. DeleteObject(hBrush)
  1058. NEXT
  1059. rect.left = li_ori_left + (li - 1) *li_width
  1060. rect.right = li_ori_right
  1061. hBrush = CreateSolidBrush(ll_rgb)
  1062. FillRect(hdc,rect,hBrush)
  1063. DeleteObject(hBrush)
  1064. RETURN
  1065. VGRADIENT:
  1066. li_steps = 20 - 1
  1067. li_width = (rect.bottom - rect.top) / li_steps
  1068. of_color2rgb(colorfrom,r1,g1,b1)
  1069. of_color2rgb(colorto,r2,g2,b2)
  1070. vr = abs(r1 - r2) / li_steps
  1071. vg = abs(g1 - g2) / li_steps
  1072. vb = abs(b1 - b2) / li_steps
  1073. IF r2<r1 THEN vr = vr * -1
  1074. IF g2<g1 THEN vg = vg * -1
  1075. IF b2<b1 THEN vb = vb * -1
  1076. SetBkMode(hdc,TRANSPARENT)
  1077. li_ori_left = rect.top
  1078. li_ori_right = rect.bottom
  1079. FOR li = 1 TO li_steps
  1080. r2 = r1 + vr * li
  1081. g2 = g1 + vg * li
  1082. b2 = b1 + vb * li
  1083. ll_RGB = RGB( r2, g2, b2)
  1084. rect.top = li_ori_left + (li - 1) * li_width
  1085. rect.bottom = rect.top + li_width
  1086. hBrush = CreateSolidBrush(ll_rgb)
  1087. FillRect(hdc,rect,hBrush)
  1088. DeleteObject(hBrush)
  1089. NEXT
  1090. rect.top = li_ori_left + (li - 1) * li_width
  1091. rect.bottom = li_ori_right
  1092. hBrush = CreateSolidBrush(ll_rgb)
  1093. FillRect(hdc,rect,hBrush)
  1094. DeleteObject(hBrush)
  1095. return
  1096. VEDGEGRADIENT:
  1097. tagrect rect2
  1098. rect2=rect
  1099. li_steps = 11 - 1
  1100. li_halfwidth= (rect.bottom - rect.top) /2
  1101. li_ori_left = rect.top
  1102. li_ori_right = rect.bottom
  1103. rect.bottom = li_halfwidth + rect.top
  1104. rect2.top=rect2.bottom - li_halfwidth
  1105. li_width = (rect.bottom - rect.top) / li_steps
  1106. of_color2rgb(colorto,r1,g1,b1)
  1107. of_color2rgb(colorfrom,r2,g2,b2)
  1108. vr = abs(r1 - r2) / li_steps
  1109. vg = abs(g1 - g2) / li_steps
  1110. vb = abs(b1 - b2) / li_steps
  1111. IF r2<r1 THEN vr = vr * -1
  1112. IF g2<g1 THEN vg = vg * -1
  1113. IF b2<b1 THEN vb = vb * -1
  1114. SetBkMode(hdc,TRANSPARENT)
  1115. FOR li = 1 TO li_steps
  1116. r2 = r1 + vr * li
  1117. g2 = g1 + vg * li
  1118. b2 = b1 + vb * li
  1119. ll_RGB = RGB( r2, g2, b2)
  1120. rect.top = li_ori_left + (li - 1) * li_width
  1121. rect.bottom = rect.top + li_width
  1122. rect2.top = li_ori_Right - (li - 1) * li_width
  1123. rect2.bottom = rect.bottom - li_width
  1124. hBrush = CreateSolidBrush(ll_rgb)
  1125. FillRect(hdc,rect,hBrush)
  1126. FillRect(hdc,rect2,hBrush)
  1127. DeleteObject(hBrush)
  1128. NEXT
  1129. return
  1130. VHEADERGRADIENT:
  1131. li_steps = 11 - 1
  1132. li_halfwidth= (rect.bottom - rect.top) /2
  1133. li_ori_left = rect.top
  1134. li_ori_right = rect.bottom
  1135. rect.bottom = li_halfwidth + rect.top
  1136. rect2.top=rect2.bottom - li_halfwidth
  1137. li_width = (rect.bottom - rect.top) / li_steps
  1138. of_color2rgb(colorto,r1,g1,b1)
  1139. of_color2rgb(colorfrom,r2,g2,b2)
  1140. vr = abs(r1 - r2) / li_steps
  1141. vg = abs(g1 - g2) / li_steps
  1142. vb = abs(b1 - b2) / li_steps
  1143. IF r2<r1 THEN vr = vr * -1
  1144. IF g2<g1 THEN vg = vg * -1
  1145. IF b2<b1 THEN vb = vb * -1
  1146. SetBkMode(hdc,TRANSPARENT)
  1147. FOR li = 1 TO li_steps
  1148. r2 = r1 + vr * li
  1149. g2 = g1 + vg * li
  1150. b2 = b1 + vb * li
  1151. ll_RGB = RGB( r2, g2, b2)
  1152. rect.top = li_ori_left + (li - 1) * li_width
  1153. rect.bottom = rect.top + li_width
  1154. hBrush = CreateSolidBrush(ll_rgb)
  1155. FillRect(hdc,rect,hBrush)
  1156. DeleteObject(hBrush)
  1157. NEXT
  1158. rect.top = li_ori_left + (li - 1) * li_width
  1159. rect.bottom = li_ori_right
  1160. hBrush = CreateSolidBrush(ll_rgb)
  1161. FillRect(hdc,rect,hBrush)
  1162. DeleteObject(hBrush)
  1163. return
  1164. end subroutine
  1165. private subroutine of_drawfirstlevelmenu (ref zdrawitemstruct ast_drawitemstruct, ref ust_menuinfo ast_menuinfo);//not complete!
  1166. end subroutine
  1167. private subroutine of_drawnormalitem (integer ai_menubkstyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo);string ls_ItemName,ls_shortcutkey
  1168. long hIcon
  1169. tagrect rTmp
  1170. menu lm_menupt
  1171. long hBrush,hOldBrush,hPen,hOldPen
  1172. ls_ItemName = ast_menuinfo.menupt.text
  1173. if MenuBKStyle = STYLE_BKWhite and ls_ItemName<>"-" then ls_ItemName=" "+ls_ItemName
  1174. lm_menupt = ast_menuinfo.menupt
  1175. hIcon = ast_menuinfo.hIcon
  1176. ls_shortcutkey = ast_menuinfo.shortcutkey
  1177. int li_pos
  1178. li_pos = POS(ls_ItemName,"~t")
  1179. IF li_pos > 0 THEN
  1180. ls_ItemName = LEFT(ls_ItemName,li_pos - 1)
  1181. END IF
  1182. choose case ai_MenuBKStyle
  1183. case STYLE_BKWhite
  1184. FillRect(hdc,ast_rect,GetStockObject(WHITE_BRUSH))
  1185. rTmp.Left = ast_rect.Left
  1186. rTmp.top= ast_rect.top
  1187. rTmp.Right = ast_rect.Left+20
  1188. rTmp.bottom = ast_rect.bottom
  1189. hBrush = CreateSolidBrush(RGB(240, 240,240))
  1190. FillRect(hdc,rTmp,hBrush)
  1191. DeleteObject(hBrush)
  1192. hPen = CreatePen(PS_SOLID,0,RGB(200,200,200))
  1193. hOldPen = SelectObject(hdc,hPen)
  1194. MoveToEx(hdc,rTmp.Left,rTmp.Top,0)
  1195. LineTo(hdc,rTmp.Left,rTmp.Bottom)
  1196. MoveToEx(hdc,rTmp.Right,rTmp.Top,0)
  1197. LineTo(hdc,rTmp.Right,rTmp.Bottom)
  1198. SelectObject(hdc, hOldPen)
  1199. DeleteObject(hPen)
  1200. case STYLE_BKGRAY
  1201. hBrush = CreateSolidBrush(RGB(221, 227,235))
  1202. FillRect(hdc,ast_rect,hBrush)
  1203. DeleteObject(hBrush)
  1204. rTmp.Left = ast_rect.Left
  1205. rTmp.top= ast_rect.top
  1206. rTmp.Right = ast_rect.Left+20
  1207. rTmp.bottom = ast_rect.bottom
  1208. hBrush = CreateSolidBrush(RGB(156, 171,186))
  1209. FillRect(hdc,rTmp,hBrush)
  1210. DeleteObject(hBrush)
  1211. hPen = CreatePen(PS_SOLID,0,RGB(127,136,147))
  1212. holdPen=SelectObject(hdc,hPen)
  1213. MoveToEx(hdc,rTmp.Left,rTmp.Top,0)
  1214. LineTo(hdc,rTmp.Left,rTmp.Bottom)
  1215. MoveToEx(hdc,rTmp.Left,0,0)
  1216. LineTo(hdc,rTmp.Right - 1,0)
  1217. MoveToEx(hdc,rTmp.Left+20,rTmp.Top,0)
  1218. LineTo(hdc,rTmp.Left+20,rTmp.Bottom)
  1219. SelectObject(hdc, hOldPen)
  1220. DeleteObject(hPen)
  1221. case STYLE_BKGRAY_XP
  1222. FillRect(hdc,ast_rect,GetStockObject(WHITE_BRUSH))
  1223. rTmp.Left = ast_rect.Left
  1224. rTmp.top= ast_rect.top
  1225. rTmp.Right = ast_rect.Left+20
  1226. rTmp.bottom = ast_rect.bottom
  1227. FillRect(hdc,rTmp,GetStockObject(GRAY_BRUSH))
  1228. hPen = CreatePen(PS_SOLID,0,RGB(127,136,147))
  1229. holdPen=SelectObject(hdc,hPen)
  1230. MoveToEx(hdc,rTmp.Left,rTmp.Top,0)
  1231. LineTo(hdc,rTmp.Left,rTmp.Bottom)
  1232. MoveToEx(hdc,rTmp.Left,0,0)
  1233. LineTo(hdc,rTmp.Right - 1,0)
  1234. MoveToEx(hdc,rTmp.Left+20,rTmp.Top,0)
  1235. LineTo(hdc,rTmp.Left+20,rTmp.Bottom)
  1236. SelectObject(hdc, hOldPen)
  1237. DeleteObject(hPen)
  1238. case STYLE_BKAMB
  1239. FillRect(hdc,ast_rect, GetStockObject(WHITE_BRUSH))
  1240. rTmp.Left = ast_rect.Left
  1241. rTmp.top= ast_rect.top
  1242. rTmp.Right = ast_rect.Left+22
  1243. rTmp.bottom = ast_rect.bottom
  1244. FillRect(hdc,rTmp,GetSysColorBrush(COLOR_BTNFACE))
  1245. SelectObject(hdc, hOldBrush)
  1246. DeleteObject(hBrush)
  1247. case else
  1248. FillRect(hdc,ast_rect,GetSysColorBrush(COLOR_MENU))
  1249. end choose
  1250. //draw text and ico
  1251. IF lm_menupt.enabled THEN
  1252. if lm_menupt.checked then
  1253. of_drawchecked(hdc,ast_rect)
  1254. elseif hIcon>0 then
  1255. DrawIconEx(hdc,ast_rect.Left + 3,ast_rect.Top + 3,hIcon,16,16,0,0,3)
  1256. end if
  1257. ast_rect.Left = ast_rect.Left + 24
  1258. ast_rect.Top = ast_rect.Top + 4
  1259. of_drawtext(hdc,ls_itemname,ls_shortcutkey,ast_rect,true)
  1260. ELSE
  1261. if ls_ItemName="-" then
  1262. if MenuBKStyle = STYLE_BKWhite or MenuBKStyle = STYLE_BKGRAY or MenuBKStyle = STYLE_BKGRAY_XP then
  1263. hPen = CreatePen(PS_SOLID,0,RGB(172,168,153))
  1264. hOldPen = SelectObject(hdc,hPen)
  1265. int li_middpos
  1266. li_middpos = (ast_rect.Top+ast_rect.Bottom)/2
  1267. MoveToEx(hdc,ast_rect.Left+22,li_middpos,0)
  1268. LineTo(hdc,ast_rect.Right,li_middpos)
  1269. SelectObject(hdc,hOldPen)
  1270. DeleteObject(hPen)
  1271. else
  1272. hPen = CreatePen(PS_SOLID,0,RGB(128,128,128))
  1273. hOldPen = SelectObject(hdc,hPen)
  1274. li_middpos = (ast_rect.Top+ast_rect.Bottom)/2
  1275. MoveToEx(hdc,ast_rect.Left - 4,li_middpos,0)
  1276. LineTo(hdc,ast_rect.Right - 1,li_middpos)
  1277. SelectObject(hdc,hOldPen)
  1278. DeleteObject(hPen)
  1279. hPen = GetStockObject(WHITE_PEN)
  1280. SelectObject(hdc,hPen)
  1281. li_middpos = li_middpos+1
  1282. MoveToEx(hdc,ast_rect.Left - 4,li_middpos,0)
  1283. LineTo(hdc,ast_rect.Right - 1,li_middpos)
  1284. SelectObject(hdc,hOldPen)
  1285. end if
  1286. end if
  1287. if hIcon>0 then DrawState(hdc, 0, 0, hIcon, 0, ast_rect.Left + 3, ast_rect.Top + 3,16, 16, DST_ICON + DSS_DISABLED)
  1288. ast_rect.Left = ast_rect.Left + 24
  1289. ast_rect.Top = ast_rect.Top + 4
  1290. of_drawtext(hdc,ls_itemname,ls_shortcutkey,ast_rect,False)
  1291. END IF
  1292. end subroutine
  1293. public function decimal of_getshortcutkeyrate (menu am_menu);string ls_text
  1294. long lhdc_temp,MenuFont,OldFont
  1295. tagrect rc,tmp
  1296. integer li_for,li_pos,li_tmp,li_width1,li_width2
  1297. Dec ld_rate,ld_this
  1298. lhdc_temp = GetDC(il_winhandle)
  1299. MenuFont = of_GetmenuFont(lhdc_temp)
  1300. OldFont = SelectObject(lhdc_temp,MenuFont)
  1301. FOR li_for = 1 TO UpperBound(am_menu.Item)
  1302. ls_text = am_menu.Item[li_for].Text
  1303. li_pos = POS(ls_text,"~t")
  1304. IF li_pos > 0 THEN
  1305. rc = tmp
  1306. DrawText(lhdc_temp,LEFT(ls_text,li_pos - 1),li_pos - 1,rc,DT_CALCRECT)
  1307. li_tmp = rc.right - rc.left
  1308. IF li_tmp > li_width1 THEN
  1309. li_width1 = li_tmp
  1310. END IF
  1311. rc = tmp
  1312. DrawText(lhdc_temp,MID(ls_text,li_pos + 1),Len(ls_text) - li_pos,rc,DT_CALCRECT)
  1313. li_tmp = rc.right - rc.left
  1314. IF li_tmp > li_width2 THEN
  1315. li_width2 = li_tmp
  1316. END IF
  1317. END IF
  1318. NEXT
  1319. SelectObject(lhdc_temp,OldFont)
  1320. IF li_width1 + li_width2 > 0 THEN
  1321. ld_rate = li_width1 / ( li_width1 + li_width2 )
  1322. END IF
  1323. ReleaseDc(il_winhandle,lhdc_temp)
  1324. RETURN ld_rate
  1325. end function
  1326. public subroutine of_setvisible (menu am_menu, boolean ab_visible);//NOW CAN IMPLEMENT!
  1327. am_menu.visible=ab_visible
  1328. of_registerwindow(iw_win)
  1329. end subroutine
  1330. public subroutine of_registerwindow (readonly window aw_win);//-------------------------------------------------------*
  1331. // FUNCTION: of_registerwindow *
  1332. // Description: *
  1333. //-------------------------------------------------------*
  1334. // Parameters: window aw_win *
  1335. //-------------------------------------------------------*
  1336. // Author(s) Date Remark *
  1337. // Rain 2003.03.10 Develop *
  1338. //-------------------------------------------------------*
  1339. uLong hMenu,ll_hsysmenu
  1340. menu smenu
  1341. String sMenuName
  1342. Integer li_level = 0
  1343. il_winhandle = handle(aw_win)
  1344. iw_win = aw_win
  1345. hMenu = GetMenu(il_winhandle)
  1346. smenu = aw_win.menuid
  1347. if hMenu>0 then
  1348. ll_hsysmenu = GetSystemMenu(il_winhandle,false)
  1349. of_registermenu(smenu,li_level,hMenu,ll_hsysmenu)
  1350. end if
  1351. end subroutine
  1352. public function boolean of_iswhitespace (string as_source);//////////////////////////////////////////////////////////////////////////////
  1353. //
  1354. // Function: of_IsWhiteSpace
  1355. //
  1356. // Access: public
  1357. //
  1358. // Arguments:
  1359. // as_source The source string.
  1360. //
  1361. // Returns: Boolean
  1362. // True if the string only contains White Space characters.
  1363. // If any argument's value is NULL, function returns NULL.
  1364. //
  1365. // Description: Determines whether a string contains only White Space
  1366. // characters. White Space characters include Newline, Tab,
  1367. // Vertical tab, Carriage return, Formfeed, and Backspace.
  1368. //
  1369. //////////////////////////////////////////////////////////////////////////////
  1370. //
  1371. // Revision History
  1372. //
  1373. // Version
  1374. // 5.0 Initial version
  1375. //
  1376. //////////////////////////////////////////////////////////////////////////////
  1377. //
  1378. // Copyright ?1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
  1379. // Any distribution of the PowerBuilder Foundation Classes (PFC)
  1380. // source code by other than Sybase, Inc. and its subsidiaries is prohibited.
  1381. //
  1382. //////////////////////////////////////////////////////////////////////////////
  1383. long ll_count=0
  1384. long ll_length
  1385. char lc_char[]
  1386. integer li_ascii
  1387. //Check parameters
  1388. If IsNull(as_source) Then
  1389. boolean lb_null
  1390. SetNull(lb_null)
  1391. Return lb_null
  1392. End If
  1393. //Get the length
  1394. ll_length = Len (as_source)
  1395. //Check for at least one character
  1396. If ll_length=0 Then
  1397. Return False
  1398. End If
  1399. //Move string into array of chars
  1400. lc_char = as_source
  1401. //Perform loop around all characters
  1402. //Quit loop if Non WhiteSpace character is found
  1403. do while ll_count<ll_length
  1404. ll_count ++
  1405. //Get ASC code of character.
  1406. li_ascii = Asc (lc_char[ll_count])
  1407. If li_ascii=8 or /* BackSpae */ &
  1408. li_ascii=9 or /* Tab */ &
  1409. li_ascii=10 or /* NewLine */ &
  1410. li_ascii=11 or /* Vertical Tab */ &
  1411. li_ascii=12 or /* Form Feed */ &
  1412. li_ascii=13 or /* Carriage Return */ &
  1413. li_ascii=32 Then /* Space */
  1414. //Character is a WhiteSpace.
  1415. //Continue with the next character.
  1416. Else
  1417. /* Character is Not a White Space. */
  1418. Return False
  1419. End If
  1420. loop
  1421. // Entire string is White Space.
  1422. return True
  1423. end function
  1424. public subroutine of_measureitem (ref unsignedlong childid, ref long measureitemstruct);//-------------------------------------------------------*
  1425. // FUNCTION: of_measureitem *
  1426. // Description: *
  1427. //-------------------------------------------------------*
  1428. // Parameters: ulong childid *
  1429. // long measureitemstruct *
  1430. //-------------------------------------------------------*
  1431. // Author(s) Date Remark *
  1432. // 贱客无名 2003.02.27 Develop *
  1433. // Rain 2003.03.10 calc width of menuitem
  1434. // Bluetlck use GetTextExtentpoint32 instead of drawtext
  1435. //-------------------------------------------------------*
  1436. string ls_text
  1437. long lhdc_temp,holdfont
  1438. tagrect rc
  1439. int li_row,rcWidth,li_return
  1440. long Itemwidth
  1441. MeasureItemStruct tMeasureItemStruct
  1442. CopyMemory(tMeasureItemStruct,MeasureItemStruct,24)
  1443. IF tMeasureItemStruct.CtlType <> 1 THEN // <> ODT_MENU
  1444. RETURN
  1445. END IF
  1446. if tMeasureItemStruct.itemdata=0 then return
  1447. li_row = of_find_byid(tMeasureItemStruct.itemdata)
  1448. IF li_row =0 THEN
  1449. RETURN //none of our business
  1450. ELSE
  1451. //get menuitem's text to measure width
  1452. ls_text = trim(ist_menuinfo[li_row].menupt.text)
  1453. int li_pos,li_lenght
  1454. li_pos = POS(ls_text,"~t")
  1455. IF li_pos = 0 THEN
  1456. ls_text = ls_text +ist_menuinfo[li_row].ShortcutKey
  1457. END IF
  1458. END IF
  1459. If ist_menuinfo[li_row].menupt.text="-" then
  1460. tMeasureItemStruct.Itemheight = GetSystemMetrics(SM_CYMENU)/3
  1461. tMeasureItemStruct.ItemWidth = 0
  1462. else
  1463. tMeasureItemStruct.ItemHeight = GetSystemMetrics(SM_CYMENU) +3
  1464. lhdc_temp = GetDC(il_winhandle)
  1465. TextSize lstr_Size
  1466. // Get the size of the text.
  1467. holdfont = SelectObject(lhdc_temp,GetStockObject(SYSTEM_FONT))
  1468. GetTextExtentpoint32(lhdc_temp, ls_text, len(ls_text), lstr_Size )
  1469. SelectObject(lhdc_temp,holdfont)
  1470. rcWidth = lstr_Size.l_cx
  1471. if ist_menuinfo[li_row].level <> 0 then
  1472. itemwidth = rcWidth+22
  1473. else
  1474. itemwidth = rcWidth
  1475. END IF
  1476. tMeasureItemStruct.ItemWidth = itemwidth
  1477. ReleaseDc(il_winhandle,lhdc_temp)
  1478. end if
  1479. CopyMemory(MeasureItemStruct,tMeasureItemStruct,24)
  1480. end subroutine
  1481. private subroutine of_drawselectitem (integer ai_menustyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo);string ls_ItemName,ls_shortcutkey
  1482. long hIcon
  1483. tagrect rTmp
  1484. menu lm_menupt
  1485. ls_ItemName = ast_menuinfo.menupt.text
  1486. if MenuBKStyle = STYLE_BKWhite and ls_ItemName<>"-" then ls_ItemName=" "+ls_ItemName
  1487. lm_menupt = ast_menuinfo.menupt
  1488. hIcon = ast_menuinfo.hIcon
  1489. ls_shortcutkey = ast_menuinfo.shortcutkey
  1490. int li_pos
  1491. li_pos = POS(ls_ItemName,"~t")
  1492. IF li_pos > 0 THEN
  1493. ls_ItemName = LEFT(ls_ItemName,li_pos - 1)
  1494. END IF
  1495. Choose Case ai_Menustyle
  1496. Case 1
  1497. FillRect(hdc,ast_rect,GetSysColorBrush(COLOR_HIGHLIGHT))
  1498. if lm_menupt.checked then
  1499. of_drawchecked(hdc,ast_rect)
  1500. elseif hIcon>0 then
  1501. DrawIconEx(hdc,ast_rect.Left + 3,ast_rect.Top + 3,hIcon,16,16,0,0,3)
  1502. end if
  1503. SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
  1504. Case 2
  1505. //draw border
  1506. rTmp.Top = ast_rect.Top
  1507. rTmp.Left = ast_rect.Left + 1
  1508. rTmp.Bottom = ast_rect.Bottom
  1509. rTmp.Right = ast_rect.Left + 21
  1510. DrawEdge(hdc,rTmp,BDR_RAISEDINNER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
  1511. rTmp.Left = rTmp.Left + 22
  1512. rTmp.Right = ast_rect.Right - 1
  1513. DrawEdge(hdc,rTmp,BDR_SUNKENOUTER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
  1514. If hIcon<=0 and not lm_menupt.Checked Then
  1515. rTmp.Left = ast_rect.Left
  1516. end if
  1517. FillRect(hdc,rTmp,GetSysColorBrush(COLOR_HIGHLIGHT))
  1518. SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
  1519. Case 3
  1520. rTmp.Top = ast_rect.Top
  1521. rTmp.Left = ast_rect.Left + 1
  1522. rTmp.Bottom = ast_rect.Bottom
  1523. rTmp.Right = ast_rect.Left + 21
  1524. DrawEdge(hdc,rTmp,BDR_RAISEDINNER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
  1525. rTmp.Left = rTmp.Left + 22
  1526. rTmp.Right = ast_rect.Right - 1
  1527. If hIcon<=0 and not lm_menupt.Checked Then rTmp.Left = 0
  1528. FillRect(hdc,rTmp,GetSysColorBrush(COLOR_BACKGROUND ))
  1529. SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
  1530. Case 4,5,6,7
  1531. rTmp.Top = ast_rect.Top
  1532. rTmp.Left = ast_rect.Left + 1
  1533. rTmp.Bottom = ast_rect.bottom
  1534. rTmp.Right = ast_rect.Left + 21
  1535. DrawEdge(hdc,rTmp,BDR_RAISEDINNER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
  1536. rTmp.Right = ast_rect.Right - 1
  1537. If hIcon<=0 and not lm_menupt.Checked Then
  1538. rTmp.Left = ast_rect.Left
  1539. else
  1540. rTmp.Left = rTmp.Left + 22
  1541. end if
  1542. of_FillWithGradient(hdc,rTmp,COLOR_START,COLOR_END)
  1543. SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
  1544. Case 8,9,10 //XPSTYLE
  1545. //--------------------------------------------------------------------
  1546. // Write By: 王无敌 Date: 2003.03.02
  1547. // Modified date : 2003.03.16
  1548. //--------------------------------------------------------------------
  1549. if Menustyle=8 then of_xprect(hdc,ast_rect,RGB(80, 80, 165),RGB(185,185,215))
  1550. if Menustyle=9 then of_xprect(hdc,ast_rect,RGB(255, 131, 6),RGB(255,196,136))
  1551. if Menustyle=10 then of_xprect(hdc,ast_rect,RGB(0, 0, 0),RGB(192,192,192))
  1552. if lm_menupt.checked then
  1553. of_drawchecked(hdc,ast_rect)
  1554. elseif hIcon>0 then
  1555. DrawIconEx(hdc,ast_rect.Left + 2,ast_rect.Top + 2,hIcon,16,16,0,0,3)
  1556. end if
  1557. Case STYLE_COLOR_INFOBK
  1558. rtmp.left = ast_rect.left+22
  1559. rtmp.right = ast_rect.right - 2
  1560. rtmp.top = ast_rect.top +1
  1561. rtmp.bottom = ast_rect.bottom - 1
  1562. of_xprect(hdc,rtmp,RGB(0, 0, 0), GetSysColor(COLOR_INFOBK))
  1563. if lm_menupt.checked then
  1564. of_drawchecked(hdc,ast_rect)
  1565. elseif hIcon>0 then
  1566. DrawIconEx(hdc,ast_rect.Left + 2,ast_rect.Top + 2,hIcon,16,16,0,0,3)
  1567. end if
  1568. End Choose
  1569. //draw text
  1570. ast_rect.Left = ast_rect.Left + 24
  1571. ast_rect.Top = ast_rect.Top + 4
  1572. SetBkMode(hdc,TRANSPARENT)
  1573. DrawText(hdc,ls_ItemName,Len(ls_ItemName),ast_rect,DT_VCENTER)
  1574. ast_rect.Right =ast_rect.Right - 12
  1575. DrawText(hdc,ls_shortcutkey,Len(ls_shortcutkey),ast_rect,DT_RIGHT)
  1576. end subroutine
  1577. on nvo_supermenu_class.create
  1578. call super::create
  1579. TriggerEvent( this, "constructor" )
  1580. end on
  1581. on nvo_supermenu_class.destroy
  1582. TriggerEvent( this, "destructor" )
  1583. call super::destroy
  1584. end on
  1585. event destructor;integer li_loop
  1586. //IF il_menufont<>0 THEN DeleteObject(il_menufont)
  1587. FOR li_loop =1 TO UpperBound(ist_menuinfo)
  1588. IF ist_menuinfo[li_loop].hIcon<>0 THEN
  1589. DestroyIcon(ist_menuinfo[li_loop].hIcon)
  1590. END IF
  1591. if isValid(ist_menuinfo[li_loop].menupt) then
  1592. destroy ist_menuinfo[li_loop].menupt
  1593. end if
  1594. NEXT
  1595. end event
  1596. event constructor;//----------------------------------------------------------------*
  1597. // UserObject: nvo_supermenu_class *
  1598. // Description: icon menu (ONLY WINDOW MENU SUPPORTED) *
  1599. //----------------------------------------------------------------*
  1600. // Author(s): Date Remark *
  1601. // 贱客无名 2003.02.27 Develop *
  1602. // Addison Lu 2003.03.02 fixed a few bugs *
  1603. // 王无敌 2003.03.02 new "xp rectangle" style *
  1604. // Rain 2003.03.10 as below *
  1605. // *
  1606. // I made a lot of changed on this object,such as *
  1607. // 1.Encapsulates all code in one userobjet,since PB does not *
  1608. // support "Address of Function" , so we can not set new *
  1609. // WndProc, just makes the object more easy to use. *
  1610. // 2.Uses structure array instead of Datastore *
  1611. // 3.Calc width of menuitem at runtime(MEASUREITEM) *
  1612. // 4.Draw disabled status *
  1613. // 5.Performance enhanced,fixed Memorey Leak bugs ... *
  1614. // *
  1615. // it's a great pity that some bugs/functions are still not*
  1616. // fixed/implemented. *
  1617. // 1. submenu available when parent set disabled *
  1618. // 2. can not modify visible property at runtime *
  1619. //----------------------------------------------------------------*
  1620. //============================================*
  1621. // HOW TO USE *
  1622. //============================================*
  1623. // ---- 1.Declare INSTANCE Variable ----
  1624. //
  1625. // nvo_supermenu_class inv_supermenu // autoinstantiate
  1626. //
  1627. // ---- 2.Window Open Event ----
  1628. //
  1629. // inv_SuperMenu.MenuStyle = inv_SuperMenu.STYLE_STYLE3
  1630. // inv_SuperMenu.of_registerwindow(this)
  1631. // inv_SuperMenu.of_SetMenuIcon('BYID',"m_5","打开.ICO")
  1632. // inv_SuperMenu.of_SetMenuIcon('BYTEXT',"新建","新建.ICO")
  1633. // inv_SuperMenu.of_SetMenuIcon('BYID',"m_6","保存.ICO")
  1634. //
  1635. // ---- 3.ue_drawmenuitem(PBM_DRAWMENUITEM) ----
  1636. // inv_SuperMenu.of_drawitem(childid,drawitemstruct)
  1637. //
  1638. // ---- 4.ue_measureitem(PBM_MEASUREITEM) ----
  1639. // inv_SuperMenu.of_measureitem(childid,measureitemstruct)
  1640. // more style
  1641. //CONSTANT INTEGER STYLE_NORMAL = 1
  1642. //CONSTANT INTEGER STYLE_OFFICE2K = 2
  1643. //CONSTANT INTEGER STYLE_STYLE3 = 3
  1644. //CONSTANT INTEGER STYLE_GRADIENT = 4
  1645. ////Gradient style does not work well under Win98 ,
  1646. ////and it's slow in PB. (My Computer : PIII 650,TNT2)
  1647. //CONSTANT INTEGER STYLE_OFFICEXP = 5
  1648. /* Bluetlck 2003.04.25 as below
  1649. 两种设置visible属性的方法,取其一即可
  1650. 1:利用inv_SuperMenu的内部函数of_setvisible
  1651. 2:在菜单所在窗口中自定义事件pbm_initmenu,加入script:
  1652. if hmenu <> inv_supermenu.GetMenu(handle(this)) then
  1653. inv_supermenu.of_registermenu(m_dmm0200,1,hmenu)
  1654. else
  1655. inv_supermenu.of_registermenu(m_dmm0200,0,hmenu)
  1656. end if
  1657. 然后就可以直接更改菜单的visible属性
  1658. */
  1659. /* ATTENTION!!!
  1660. if your pb version is not pb8 ,please modify some extelnal functions by hand.
  1661. */
  1662. if COLOR_START = 0 then COLOR_START = GetSysColor(COLOR_HIGHLIGHT)
  1663. if COLOR_END =0 then COLOR_END =GetSysColor(COLOR_MENU)
  1664. end event