123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971 |
- $PBExportHeader$nvo_supermenu_class.sru
- $PBExportComments$超级菜单对象
- forward
- global type nvo_supermenu_class from nonvisualobject
- end type
- type ust_menuinfo from structure within nvo_supermenu_class
- end type
- type tagrect from structure within nvo_supermenu_class
- end type
- type measureitemstruct from structure within nvo_supermenu_class
- end type
- type logfont from structure within nvo_supermenu_class
- end type
- type textmetric from structure within nvo_supermenu_class
- end type
- type zdrawitemstruct from structure within nvo_supermenu_class
- end type
- type us_bitmap from structure within nvo_supermenu_class
- end type
- type textsize from structure within nvo_supermenu_class
- end type
- type menuiteminfoa from structure within nvo_supermenu_class
- end type
- end forward
- type ust_menuinfo from structure
- unsignedlong itemid
- string itemname
- string shortcutkey
- menu menupt
- unsignedlong hicon
- integer level
- end type
- type tagrect from structure
- long left
- long top
- long right
- long bottom
- end type
- type measureitemstruct from structure
- long ctltype
- long ctlid
- long itemid
- long itemwidth
- long itemheight
- long itemdata
- end type
- type logfont from structure
- long lfHeight
- long lfWidth
- long lfEscapement
- long lfOrientation
- long lfWeight
- character lfItalic
- character lfUnderline
- character lfStrikeOut
- character lfCharSet
- character lfOutPrecision
- character lfClipPrecision
- character lfQuality
- character lfPitchAndFamily
- string lfFaceName
- end type
- type textmetric from structure
- long tmheight
- long tmascent
- long tmdescent
- long tminternalleading
- long tmexternalleading
- long tmavecharwidth
- long tmmaxcharwidth
- long tmweight
- long tmoverhang
- long tmdigitizedaspectx
- long tmdigitizedaspecty
- character tmfirstchar
- character tmlastchar
- character tmdefaultchar
- character tmbreakchar
- character tmitalic
- character tmunderlined
- character tmstruckout
- character tmpitchandfamily
- character tmcharset
- end type
- type zdrawitemstruct from structure
- long ctltype
- long ctlid
- long itemid
- long itemaction
- long itemstate
- long hwnditem
- long hdc
- tagrect rcitem
- long itemdata
- end type
- type us_bitmap from structure
- long bmtype
- long bmwidth
- long bmheight
- long bmwidthbytes
- long bmplanes
- long bmbitspixel
- blob bmbits
- end type
- type textsize from structure
- integer l_cx
- integer l_cy
- end type
- type menuiteminfoa from structure
- unsignedlong cbsize
- unsignedlong fmask
- unsignedlong ftype
- unsignedlong fstate
- unsignedlong wid
- unsignedlong hsubmenu
- unsignedlong hbmpchecked
- unsignedlong hbmpunchecked
- unsignedlong dwitemdata
- long dwtypedata
- unsignedlong cch
- end type
- global type nvo_supermenu_class from nonvisualobject autoinstantiate
- end type
- type prototypes
- //从指定窗口的结构中取得信息
- //FUNCTION uLong GetWindowLong(uLong hwnd, uLong nIndex) Alias For GetWindowLongA LIBRARY "USER32.DLL"
- //在窗口结构中为指定的窗口设置信息
- //FUNCTION uLong SetWindowLong(uLong hwnd, uLong nIndex,uLong dwNewLong) Alias For SetWindowLongA LIBRARY "USER32.DLL"
- //将消息信息传送给指定的窗口过程
- //FUNCTION ulong CallWindowProc(ulong lpPrevWndFunc,ulong hWnd,ulong Msg,ulong wParam,ulong lParam) LIBRARY "user32.dll" ALIAS FOR "CallWindowProcA"
- //在指定窗口的属性表中增加一个新项,或者修改一个现有项。如果指定的字符串不在属性表中,那么就增加该新的项,新项中包含该字符串和句柄,否则就用指定的句柄替换该字符串的全前句柄
- //FUNCTION ulong SetProp(ulong hwnd,ref string lpString,ulong hData) LIBRARY "user32.dll" ALIAS FOR "SetPropA"
- //从给定窗口的属性列表中检索数据句柄。给定的字符串标识了要检索的句柄。该字符串和句柄必须在前一次调用SetProp函数时已经加到属性表中
- //FUNCTION ulong GetProp(ulong hwnd,ref string lpString) LIBRARY "user32.dll" ALIAS FOR "GetPropA"
- //返回位于菜单中指定位置处的条目的菜单ID
- FUNCTION ulong GetMenuItemID(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
- //取得分配给指定窗口的菜单的句柄
- FUNCTION ulong GetMenu(ulong hwnd) LIBRARY "user32.dll"
- //取得被指定菜单激活的下拉式菜单或子菜单的句柄
- FUNCTION ulong GetSubMenu(ulong hMenu,ulong nPos) LIBRARY "user32.dll"
- //将指定菜单项的正文字符串拷贝到指定缓冲区
- FUNCTION ulong GetMenuString(ulong hMenu,ulong wIDItem,ref string lpString,ulong nMaxCount,ulong wFlag) LIBRARY "user32.dll" ALIAS FOR "GetMenuStringA;Ansi"
- //改变菜单条目
- FUNCTION ulong ModifyMenu(ulong hMenu,ulong nPosition,ulong wFlags,ulong wIDNewItem,string lpString) LIBRARY "user32.dll" ALIAS FOR "ModifyMenuA;Ansi"
- //文本绘图函数
- //FUNCTION ulong TextOut(ulong hdc,ulong x,ulong y,ref string lpString,ulong nCount) LIBRARY "gdi32.dll" ALIAS FOR "TextOutA"
- //内存拷贝
- SUBROUTINE CopyMemory(ref measureitemstruct pDesc, ulong pSource,ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
- SUBROUTINE CopyMemory(ref zdrawitemstruct pDesc, ulong pSource,ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
- SUBROUTINE CopyMemory(ulong pDesc, ref measureitemstruct pSource, ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
- SUBROUTINE CopyMemory(ulong pDesc, ref zdrawitemstruct pSource,ulong size) LIBRARY "kernel32" ALIAS FOR "RtlMoveMemory;Ansi"
- //用指定的刷子填充一个矩形
- FUNCTION ulong FillRect(ulong hdc,ref tagrect lpRect,ulong hBrush) LIBRARY "user32.dll" alias for "FillRect;Ansi"
- //用纯色创建一个刷子
- FUNCTION ulong CreateSolidBrush(ulong crColor) LIBRARY "gdi32.dll"
- //为任何一种标准系统颜色取得一个刷子
- FUNCTION ulong GetSysColorBrush(ulong nIndex) LIBRARY "user32.dll"
- //判断指定windows显示对象的颜色
- FUNCTION ulong GetSysColor(ulong nIndex) LIBRARY "user32.dll"
- //指定阴影刷子、虚线画笔以及字符中的空隙的填充方式
- FUNCTION ulong SetBkMode(ulong hdc,ulong nBkMode) LIBRARY "gdi32.dll"
- //为指定的设备场景设置背景颜色。背景颜色用于填充阴影刷子、虚线画笔以及字符(如背景模式为OPAQUE)中的空隙。也在位图颜色转换期间使用
- FUNCTION ulong SetBkColor(ulong hdc,ulong crColor) LIBRARY "gdi32.dll"
- //设置当前文本颜色。这种颜色也称为“前景色”
- FUNCTION ulong SetTextColor(ulong hdc,ulong crColor) LIBRARY "gdi32.dll"
- //将一幅位图从一个设备场景复制到另一个。源和目标DC相互间必须兼容。这个函数会在设备场景中定义一个目标矩形,并在位图中定义一个源图象。源矩形会根据需要进行伸缩,以便与目标矩形的大小相符
- //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"
- //将文本描绘到指定的矩形中
- FUNCTION ulong DrawText(ulong hdc,string lpStr,ulong nCount,ref tagrect lpRect,ulong wFormat) LIBRARY "user32.dll" ALIAS FOR "DrawTextA;Ansi"
- //用指定的样式描绘一个矩形的边框
- FUNCTION boolean DrawEdge(ulong hdc,ref tagrect qrc,ulong edge,ulong grfFlags) LIBRARY "user32.dll" alias for "DrawEdge;Ansi"
- //释放由调用GetDC或GetWindowDC函数获取的指定设备场景。它对类或私有设备场景无效(但这样的调用不会造成损害)
- FUNCTION ulong ReleaseDC(ulong hwnd,ulong hdc) LIBRARY "user32.dll"
- //删除专用设备场景或信息场景,释放所有相关窗口资源
- FUNCTION ulong DeleteDC(ulong hdc) LIBRARY "gdi32.dll"
- //每个设备场景都可能有选入其中的图形对象。其中包括位图、刷子、字体、画笔以及区域等等。一次选入设备场景的只能有一个对象。选定的对象会在设备场景的绘图操作中使用。例如,当前选定的画笔决定了在设备场景中描绘的线段颜色及样式
- FUNCTION ulong SelectObject(ulong hdc,ulong hObject) LIBRARY "gdi32.dll"
- //用这个函数删除GDI对象,比如画笔、刷子、字体、位图、区域以及调色板等等。对象使用的所有系统资源都会被释放
- FUNCTION ulong DeleteObject(ulong hObject) LIBRARY "gdi32.dll"
- //用指定的样式、宽度和颜色创建一个画笔
- FUNCTION ulong CreatePen(ulong nPenStyle,ulong nWidth,ulong crColor) LIBRARY "gdi32.dll"
- //为指定的设备场景指定一个新的当前画笔位置。前一个位置保存在lpPoint中
- FUNCTION ulong MoveToEx(ulong hdc,ulong x,ulong y,ulong lpPoint) LIBRARY "gdi32.dll"
- //用当前画笔画一条线,从当前位置连到一个指定的点。这个函数调用完毕,当前位置变成x,y点
- FUNCTION ulong LineTo(ulong hdc,ulong x,ulong y) LIBRARY "gdi32.dll"
- //校验窗口的全部或部分客户区。这样便可告之windows指定的区域不需要重画
- //FUNCTION ulong ValidateRect(ulong hwnd,ref tagrect lpRect) LIBRARY "user32.dll"
- //取回与某一设备场景相关的窗口的句柄
- //FUNCTION ulong WindowFromDC(ulong hdc) LIBRARY "user32.dll"
- //获取指定窗口的设备场景
- FUNCTION ulong GetDC(ulong hwnd) LIBRARY "user32.dll"
- //载入一个位图、图标或指针
- FUNCTION ulong LoadImage(ulong hInst,string lpsz,ulong un1,ulong n1,ulong n2,ulong un2) LIBRARY "user32.dll" ALIAS FOR "LoadImageA;Ansi"
- //在指定的位置画一个图标
- //FUNCTION ulong DrawIcon(ulong hdc,ulong x,ulong y,ulong hIcon) LIBRARY "user32.dll"
- FUNCTION boolean DrawIconEx(ulong hdc,ulong xLeft,ulong yTop,ulong hIcon,ulong cxWidth,ulong cyWidth,ulong istepIfAniCur,ulong hbrFlickerFreeDraw,ulong diFlags) LIBRARY "user32.dll"
- //创建一幅与设备有关位图,它与指定的设备场景兼容
- //FUNCTION ulong CreateCompatibleBitmap(ulong hdc,ulong nWidth,ulong nHeight) LIBRARY "gdi32.dll"
- //在指定的设备场景中设置一个像素的RGB值
- //FUNCTION ulong SetPixel(ulong hdc,ulong x,ulong y,ulong crColor) LIBRARY "gdi32.dll"
-
- //Function Long GetMenuItemRect (long hWnd,long hMenu, long uItem, tagrect lprcItem)Library "user32"
- FUNCTION ulong GetTextFace(ulong hdc,ulong nCount,ref string lpFacename) LIBRARY "gdi32.dll" ALIAS FOR "GetTextFaceA;Ansi"
- FUNCTION ulong GetTextMetrics(ulong hdc,ref TEXTMETRIC lpMetrics) LIBRARY "gdi32.dll" ALIAS FOR "GetTextMetricsA;Ansi"
- FUNCTION ulong CreateFontIndirect(ref LOGFONT lpLogFont) LIBRARY "gdi32.dll" ALIAS FOR "CreateFontIndirectA;Ansi"
- 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"
- FUNCTION ulong DestroyIcon(ulong hIcon) LIBRARY "user32.dll"
- //Added by 王无敌
- FUNCTION ulong Rectangle(ulong hdc,ulong X1,ulong Y1,ulong X2,ulong Y2) LIBRARY "gdi32.dll"
- //Added by bluetlck
- //computes the width and height of the specified string of text
- FUNCTION ulong GetTextExtentPoint32(ulong hdc,ref string lpsz,ulong cbString,ref TEXTSIZE lpSize) LIBRARY "gdi32.dll" ALIAS FOR "GetTextExtentPoint32A;Ansi"
- //changes information about a menu item
- FUNCTION boolean SetMenuItemInfo(ulong hMenu,ulong un,boolean bool,ref MENUITEMINFOA lpcMenuItemInfo) LIBRARY "user32.dll" ALIAS FOR "SetMenuItemInfoA;Ansi"
- //retrieves information about a menu item.
- FUNCTION boolean GetMenuItemInfo(ulong hMenu,ulong un,boolean b,ref MENUITEMINFOA lpMenuItemInfo1) LIBRARY "user32.dll" ALIAS FOR "GetMenuItemInfoA;Ansi"
- FUNCTION ulong GetMenuItemCount(ulong hMenu) LIBRARY "user32.dll"
- FUNCTION ulong GetSystemMetrics(ulong nIndex) LIBRARY "user32.dll"
- FUNCTION ulong GetSystemMenu(ulong hwnd,boolean bRevert) LIBRARY "user32.dll"
- FUNCTION ulong DeleteMenu(ulong hMenu,ulong nPosition,ulong wFlags) LIBRARY "user32.dll"
- function long LoadLibrary( ref string lpLibFileName2 ) LIBRARY "KERNEL32" Alias For "LoadLibraryA;Ansi"
- function long FreeLibrary( long hinstance ) LIBRARY "KERNEL32"
- FUNCTION ulong LoadBitmap(ulong hInstance, long lpBitmapName) LIBRARY "user32.dll" ALIAS FOR "LoadBitmapA"
- FUNCTION ulong CreateDC(string lpDriverName,string lpDeviceName, string lpOutput, long lpInitData) LIBRARY "gdi32.dll" ALIAS FOR "CreateDCA;Ansi"
- FUNCTION ulong CreateCompatibleDC(ulong hdc) LIBRARY "gdi32.dll"
- FUNCTION ulong GetPixel(ulong hdc,ulong x,ulong y) LIBRARY "gdi32.dll"
- FUNCTION ulong LoadImage(ulong hInst,long lpsz,ulong un1,ulong n1,ulong n2,ulong un2) LIBRARY "user32.dll" ALIAS FOR "LoadImageA"
- //if it's use in other version ,please modify by hand.
- FUNCTION long FN_ResGetIconID(string lpLibFileName) LIBRARY "PBVM80.dll" alias for "FN_ResGetIconID;Ansi"
- FUNCTION long FN_ResGetBitmapID(string lpLibFileName) LIBRARY "PBVM80.dll" alias for "FN_ResGetBitmapID;Ansi"
- FUNCTION string FN_ResGetBitmapName(long lpLibFileName) LIBRARY "PBVM80.dll" alias for "FN_ResGetBitmapName;Ansi"
- Function Long ImageList_Create (Long MinCx , Long MinCy , Long flags ,Long cInitial ,Long cGrow) Library "PBVM80.dll" ALIAS FOR "PBImageList_Create"
- Function Long ImageList_AddMasked(Long hImageList ,Long hbmImage , Long crMask ) Library "PBVM80.dll" ALIAS FOR "PBImageList_AddMasked"
- Function Long ImageList_GetIcon(Long hImageList , Long ImgIndex , Long hbmMask ) Library "PBVM80.dll" ALIAS FOR "PBImageList_GetIcon"
- Function Long ImageList_Destroy(Long hImageList) Library "PBVM80.dll" ALIAS FOR "PBImageList_Destroy"
- //ImageList 函数
- //Function Long ImageList_Create (Long MinCx , Long MinCy , Long flags ,Long cInitial ,Long cGrow) Library "COMCTL32.DLL"
- //Function Long ImageList_AddMasked(Long hImageList ,Long hbmImage , Long crMask ) Library "COMCTL32.DLL"
- //Function Long ImageList_GetIcon(Long hImageList , Long ImgIndex , Long hbmMask ) Library "COMCTL32.DLL"
- FUNCTION ulong RoundRect(ulong hdc,ulong X1,ulong Y1,ulong X2,ulong Y2,ulong X3,ulong Y3) LIBRARY "gdi32.dll"
- FUNCTION ulong GetStockObject(ulong nIndex) LIBRARY "gdi32.dll"
- end prototypes
- type variables
- //------------------------------------------------------------------
- Public:
- //------------------------------------------------------------------
- Integer MenuStyle = 1
- CONSTANT INTEGER STYLE_NORMAL = 1
- CONSTANT INTEGER STYLE_OFFICE2K = 2
- CONSTANT INTEGER STYLE_STYLE3 = 3
- CONSTANT INTEGER STYLE_GRADIENT = 4
- CONSTANT INTEGER STYLE_VGRADIENT = 5
- CONSTANT INTEGER STYLE_VHEADERGRADIENT = 6
- CONSTANT INTEGER STYLE_VEDGEGRADIENT = 7
- CONSTANT INTEGER STYLE_OFFICEXP = 8
- CONSTANT INTEGER STYLE_OFFICEXP2 = 9
- CONSTANT INTEGER STYLE_TERMINAL_XP = 10
- CONSTANT INTEGER STYLE_COLOR_INFOBK = 11
- //background style:
- //============= bluetlck add. =========================
- Integer MenuBKStyle = 0
- CONSTANT INTEGER STYLE_BKNORMAL = 0
- CONSTANT INTEGER STYLE_BKWhite = 1
- CONSTANT INTEGER STYLE_BKGRAY = 2
- CONSTANT INTEGER STYLE_BKGRAY_XP = 3
- CONSTANT INTEGER STYLE_BKAMB = 4
- //Gradient style:
- //============= rjh add. =========================
- LONG COLOR_START = 0
- LONG COLOR_END = 0
- //------------------------------------------------------------------
- Private:
- //------------------------------------------------------------------
- MENUITEMINFOA lpMenuItemInfo
- long il_winhandle
- window iw_win
- ust_menuinfo ist_menuinfo[]
- integer ii_num
- //=========== Constant ============
- //SetBkMode
- CONSTANT ulong TRANSPARENT = 1
- //DrawEdge
- CONSTANT uLong BDR_RAISEDOUTER = 1
- CONSTANT uLong BDR_SUNKENOUTER = 2
- CONSTANT uLong BDR_RAISEDINNER = 4
- CONSTANT uLong BDR_SUNKENINNER = 8
- CONSTANT uLong BDR_OUTER = 3
- CONSTANT uLong BDR_INNER = 12
- CONSTANT uLong BF_LEFT = 1
- CONSTANT uLong BF_RIGHT = 4
- CONSTANT uLong BF_TOP = 2
- CONSTANT uLong BF_BOTTOM = 8
- CONSTANT uLong BF_RECT = 1
- //GetSysColor GetSysColorBrush
- CONSTANT uLong COLOR_BACKGROUND=1
- CONSTANT uLong COLOR_HIGHLIGHT= 13
- CONSTANT uLong COLOR_HIGHLIGHTTEXT = 14
- CONSTANT uLong COLOR_MENU = 4
- CONSTANT uLong COLOR_WINDOW = 5
- CONSTANT uLong COLOR_MENUTEXT = 7
- CONSTANT uLong COLOR_WINDOWTEXT = 8
- CONSTANT uLong COLOR_ACTIVECAPTION = 2
- CONSTANT uLong COLOR_BTNFACE = 15
- CONSTANT uLong COLOR_INFOBK = 24
- Constant integer COLOR_BTNHIGHLIGHT = 20
- Constant integer COLOR_BTNSHADOW = 16
- //ModifyMenu,Get
- CONSTANT uLong MF_BITMAP = 4
- CONSTANT uLong MF_BYCOMMAND = 0
- CONSTANT uLong MF_BYPOSITION = 1024
- CONSTANT uLong MF_CHECKED = 8
- CONSTANT uLong MF_DISABLED = 2
- CONSTANT uLong MF_ENABLED = 0
- CONSTANT uLong MF_GRAYED = 1
- CONSTANT uLong MF_MENUBARBREAK = 32
- CONSTANT uLong MF_MENUBREAK = 64
- CONSTANT uLong MF_OWNERDRAW = 256
- CONSTANT uLong MF_POPUP = 16
- CONSTANT uLong MF_SEPARATOR = 2048
- CONSTANT uLong MF_STRING = 0
- CONSTANT uLong MF_UNCHECKED = 0
- //LoadImage
- CONSTANT uLong IMAGE_BITMAP = 0
- CONSTANT uLong IMAGE_ICON = 1
- CONSTANT uLong IMAGE_CURSOR = 2
- CONSTANT uLong IMAGE_ENHMETAFILE = 3
- CONSTANT uLong LR_DEFAULTCOLOR = 0
- CONSTANT uLong LR_MONOCHROME = 1
- CONSTANT uLong LR_COLOR = 2
- CONSTANT uLong LR_COPYRETURNORG = 4
- CONSTANT uLong LR_COPYDELETEORG = 8
- CONSTANT uLong LR_LOADFROMFILE = 16
- CONSTANT uLong LR_LOADTRANSPARENT = 32
- CONSTANT uLong LR_DEFAULTSIZE = 64
- CONSTANT uLong LR_VGACOLOR = 128
- CONSTANT uLong LR_LOADMAP3DCOLORS = 4096
- CONSTANT uLong LR_CREATEDIBSECTION = 8192
- CONSTANT uLong LR_COPYFROMRESOURCE = 16384
- CONSTANT uLong LR_SHARED = 32768
- //CreatePen
- CONSTANT uLong PS_SOLID = 0
- //
- CONSTANT uLong SRCCOPY = 13369376
- //DrawText
- CONSTANT uLong DT_LEFT = 0
- CONSTANT uLong DT_CENTER = 1
- CONSTANT uLong DT_RIGHT = 2
- CONSTANT uLong DT_VCENTER = 4
- CONSTANT uLong DT_SINGLELINE = 32
- CONSTANT uLong DT_CALCRECT = 1024
- Constant integer DST_ICON = 3
- Constant integer DST_BITMAP =4
- Constant integer DSS_NORMAL =0
- Constant integer DSS_DISABLED = 32
- Constant int SM_CYMENU = 15
- Constant int SM_CXMENUCHECK = 71
- //use in GetStockObject
- Constant int WHITE_BRUSH=0
- Constant int GRAY_BRUSH =1
- Constant int LTGRAY_BRUSH=2
- Constant int DKGRAY_BRUSH=3
- Constant int BLACK_BRUSH=4
- Constant int NULL_BRUSH=5
- Constant int WHITE_PEN=6
- Constant int BLACK_PEN=7
- Constant int NULL_PEN=8
- Constant int OEM_FIXED_FONT=10
- Constant int ANSI_FIXED_FONT=11
- Constant int ANSI_VAR_FONT=12
- Constant int SYSTEM_FONT=13
- end variables
- forward prototypes
- public subroutine of_color2rgb (long lg_color, ref integer r, ref integer g, ref integer b)
- public function long of_getstockicon (string as_stockbitmap, ref integer ai_imagetype)
- private function unsignedlong of_getmenufont (long hdc)
- public subroutine of_xprect (unsignedlong hdc, tagrect rect, long al_pencolor, long al_brushcolor)
- public function long of_geticonhandle (string as_iconname)
- private function integer of_find_bymenuid (string as_itemname)
- private function integer of_find_byid (long al_itemid)
- private function integer of_find_byname (string as_itemname)
- public subroutine of_setmenuicon (string as_type, string as_itemname, string as_icon)
- public function long of_getmaskcolor (long al_bitmaphandle)
- private function integer of_add (long al_itemid, string as_text, ref menu am_menu, integer ai_level)
- public subroutine of_registermenu (integer ai_level, long al_hmenu, long al_hsysmenu)
- public subroutine of_drawitem (ref unsignedlong childid, ref long drawitemstruct)
- private subroutine of_drawtext (unsignedlong hdc, string as_text, string as_shortcutkey, tagrect ast_rect, boolean ab_enabled)
- public subroutine of_registermenu (ref menu am_menu, integer ai_level, long al_hmenu, long al_hsysmenu)
- public subroutine of_drawchecked (long hdc, ref tagrect rect)
- private function unsignedlong of_createverticalfont (long hdc)
- public function boolean of_containselement (long al_src, long al_exponent)
- public subroutine of_fillwithgradient (unsignedlong hdc, tagrect rect, long colorfrom, long colorto)
- private subroutine of_drawfirstlevelmenu (ref zdrawitemstruct ast_drawitemstruct, ref ust_menuinfo ast_menuinfo)
- private subroutine of_drawnormalitem (integer ai_menubkstyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo)
- public function decimal of_getshortcutkeyrate (menu am_menu)
- public subroutine of_setvisible (menu am_menu, boolean ab_visible)
- public subroutine of_registerwindow (readonly window aw_win)
- public function boolean of_iswhitespace (string as_source)
- public subroutine of_measureitem (ref unsignedlong childid, ref long measureitemstruct)
- private subroutine of_drawselectitem (integer ai_menustyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo)
- end prototypes
- public subroutine of_color2rgb (long lg_color, ref integer r, ref integer g, ref integer b);//长整型颜色值,转为RGB型,需要三个ref参数
- b = lg_color / 65536
- g = (lg_color - b * 65536) / 256
- r = lg_color - g * 256 - b * 65536
- end subroutine
- public function long of_getstockicon (string as_stockbitmap, ref integer ai_imagetype);//////////////////////////////////////////////////////////////////////////////
- //
- // 函数名称: Of_getstockicon
- // 访问级别: Public
- // 参数: as_stockbitmap stock位图名称
- // ai_imagetype 位图 or 图标标示
- // 返回值: Long
- // 功能描述: 得到系统stock位图相应的标识符
- // 补充说明:
- //
- //////////////////////////////////////////////////////////////////////////////
- // 修改记录:2001-11-15
- // 设计:何锐
- // 编码:何锐
- // 审核:何锐
- ////////////////////////////////////////////////////////////////////////////
- Long ll_Identifier
- //检查参数
- If IsNull(as_StockBitmap) Or as_StockBitmap="" Then Return -1
- ll_Identifier = FN_ResGetBitmapID(as_stockbitmap)
-
- if ll_Identifier<=0 then
- ll_Identifier = FN_ResGetIconID(as_stockbitmap)
- ai_imagetype= IMAGE_ICON
- else //位图
- ai_imagetype = IMAGE_BITMAP
- end if
- return ll_Identifier
- end function
- private function unsignedlong of_getmenufont (long hdc);//-------------------------------------------------------*
- // FUNCTION: of_getmenufont *
- // Description: *
- //-------------------------------------------------------*
- // Arguments:
- //
- // long hdc
- // *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // Rain 2003.03.10 *
- //-------------------------------------------------------*
- long ll_menufont
- long ll_textlen = 255
- string ls_text = space(255)
- LOGFONT ltLF_FONT
- TEXTMETRIC ltTM
- //IF il_menufont = 0 THEN
-
- ll_textlen = GetTextFace(hdc, ll_TextLen, ls_Text)
- GetTextMetrics(hdc,ltTm)
-
- ltLF_FONT.lfFaceName = Left(ls_text, ll_textlen+1 )
- ltLF_FONT.lfHeight = ltTM.tmHeight
- ltLF_FONT.lfWeight = ltTM.tmWeight
-
- ll_menufont = CreateFontIndirect(ltLF_FONT)
- //END IF
- RETURN ll_menufont
- end function
- public subroutine of_xprect (unsignedlong hdc, tagrect rect, long al_pencolor, long al_brushcolor);//--------------------------------------------------------------------
- // The function was added By: 王无敌 Date: 2003.03.02
- // Modified By: 王无敌 Date: 2003.03.16
- //--------------------------------------------------------------------
- uLong hOldPen, hPen
- uLong xp1,yp1,xp2,yp2
- uLong hNewBrush,hOldBrush
- xp1 = rect.Left
- yp1 = rect.top
- xp2 = rect.Right
- yp2 = rect.bottom
- hPen = CreatePen(PS_SOLID, 1, al_PenColor)
- hOldPen = SelectObject(hdc, hPen)
- hNewBrush =CreateSolidBrush(al_BrushColor)
- hOldBrush =SelectObject(hdc, hNewBrush)
- rectangle(hdc,xp1,yp1,xp2,yp2)
- SelectObject(hdc, hOldPen)
- DeleteObject(hPen)
- SelectObject(hdc, hOldBrush)
- DeleteObject(hNewBrush)
- end subroutine
- public function long of_geticonhandle (string as_iconname);//====================================================================
- // Function: of_geticonhandle()
- //--------------------------------------------------------------------
- // Description: Get the handle of icon from the toolbaritemname of the menu
- //--------------------------------------------------------------------
- // Arguments:
- // value string as_iconname
- //--------------------------------------------------------------------
- // Returns: long IconHandle
- //--------------------------------------------------------------------
- // Author: Dale Zheng Date: 2003.05.07
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Long ll_BitmapHandle , ll_IconHandle , ll_Library , ll_Index=-1
- Environment env
- Integer rtn,li_imagetype
- String ls_File
- Long ll_identier
- long ll_hIml
- if pos(lower(as_iconname),'.ico')>0 then
- ll_IconHandle= LoadImage(0,as_iconname,IMAGE_ICON,0,0,LR_LOADFROMFILE + LR_DEFAULTSIZE)
- elseif pos(lower(as_iconname),'.bmp')>0 then
- ll_BitmapHandle = LoadImage(0,as_iconname,IMAGE_BITMAP,16,16,LR_LOADFROMFILE)
- ll_hIml = ImageList_Create (16 , 16 , 33, 4, 4)
- ll_Index = ImageList_AddMasked(ll_hIml , ll_BitmapHandle , Of_GetMaskColor(ll_BitmapHandle))
- ll_IconHandle= ImageList_GetIcon( ll_hIml , ll_Index , 1)
- //DeleteObject(ll_hIml)
- ImageList_Destroy(ll_hIml)
- DeleteObject(ll_BitmapHandle)
- elseif pos(as_iconname,'!')>0 then
- rtn = GetEnvironment(env)
- IF rtn <> 1 THEN
- MessageBox("TIP","Get the value is wrrong in the PowerBuilder Environment.",StopSign!,Ok!)
- Return -1
- End If
-
- ls_File = "PBVM" + String(env.PBMajorRevision) + "0.DLL"
- ll_Library = LoadLibrary(ls_File)
- ll_identier = Of_GetStockicon(as_iconname,li_imagetype)
- If ll_identier >0 and li_imagetype = IMAGE_BITMAP Then
- ll_BitmapHandle = LoadBitmap ( ll_Library , ll_identier)
- ll_hIml = ImageList_Create (16 , 16 , 33, 4, 4)
- ll_Index = ImageList_AddMasked(ll_hIml , ll_BitmapHandle , Of_GetMaskColor(ll_BitmapHandle))
- ll_IconHandle= ImageList_GetIcon( ll_hIml , ll_Index , 1)
- //DeleteObject(ll_hIml)
- ImageList_Destroy(ll_hIml)
- DeleteObject(ll_BitmapHandle)
- elseIf ll_identier >0 and li_imagetype = IMAGE_ICON Then
- ll_IconHandle= LoadImage(ll_Library,ll_identier,IMAGE_ICON,0,0, LR_DEFAULTSIZE )
- Else
- ll_index = -1
- End If
-
- FreeLibrary ( ll_Library )
- else
- return 0
- end if
- return ll_IconHandle
- end function
- private function integer of_find_bymenuid (string as_itemname);INTEGER li_loop,li_ret = 0
- FOR li_loop = 1 TO UpperBound(ist_menuinfo)
- IF isvalid(ist_menuinfo[li_loop].Menupt) then
- IF ist_menuinfo[li_loop].Menupt.classname() = as_ItemName THEN
- li_ret = li_loop
- EXIT
- END IF
- end if
- NEXT
- RETURN li_ret
- end function
- private function integer of_find_byid (long al_itemid);INTEGER li_loop,li_upper,li_ret = 0
- if al_ItemID <= 0 then return 0
- li_upper = UpperBound(ist_menuinfo)
- IF li_upper>al_ItemID then //一般情况下,数组中位置和al_ItemID一致
- if ist_menuinfo[al_ItemID].ItemID = al_ItemID THEN return al_ItemID
- end if
- FOR li_loop = 1 TO li_upper
- IF ist_menuinfo[li_loop].ItemID = al_ItemID THEN
- li_ret = li_loop
- EXIT
- END IF
- NEXT
- RETURN li_ret
- end function
- private function integer of_find_byname (string as_itemname);INTEGER li_loop,li_pos,li_ret = 0
- string ls_menuText
- li_pos = POS(as_ItemName,"~t")
- IF li_pos > 0 THEN
- as_ItemName= LEFT(as_ItemName,li_pos - 1)
- END IF
- FOR li_loop = 1 TO UpperBound(ist_menuinfo)
- ls_menuText =ist_menuinfo[li_loop].ItemName
- IF trim(ls_menuText) = trim(as_ItemName) THEN
- li_ret = li_loop
- EXIT
- END IF
- NEXT
- RETURN li_ret
- end function
- public subroutine of_setmenuicon (string as_type, string as_itemname, string as_icon);//-------------------------------------------------------*
- // FUNCTION: of_setmenuicon *
- // Description: *
- //-------------------------------------------------------*
- // Parameters: string as_type *
- // string as_itemname *
- // string as_icon *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // 贱客无名 2003.02.27 Develop *
- // Rain 2003.03.10 load icon immediately, *
- // add item by 'ID' or 'TEXT' *
- //-------------------------------------------------------*
- integer li_menupos
- IF Upper(as_type)='BYID' OR upper(as_type) = 'ID' THEN
- li_menupos = of_find_bymenuid(as_itemname)
- ELSE
- li_menupos = of_find_byname(as_itemname)
- END IF
- IF li_menupos <>0 THEN
- IF ist_menuinfo[li_menupos].hIcon= 0 THEN
- //ist_menuinfo[li_menupos].hIcon = LoadImage(0,as_icon,IMAGE_ICON,16,16,LR_LOADFROMFILE + LR_DEFAULTSIZE)
- ist_menuinfo[li_menupos].hIcon=of_GetIconHandle(as_icon)
- // else
- // DestroyIcon(ist_menuinfo[li_menupos].hIcon)
- // ist_menuinfo[li_menupos].hIcon=of_GetIconHandle(as_icon)
- END IF
- END IF
- end subroutine
- public function long of_getmaskcolor (long al_bitmaphandle);//////////////////////////////////////////////////////////////////////////////
- // 函数名称: Of_GetMaskColor
- // 访问级别: Public
- // 参数: al_BitmapHandle 位图句柄
- // 返回值: Long
- // 功能描述: 获得指定位图文件的Mask颜色,返回值为Mask颜色
- // 补充说明:
- //
- //////////////////////////////////////////////////////////////////////////////
- //
- // 修改记录:2001-11-15
- //
- //////////////////////////////////////////////////////////////////////////////
- // 编码:何锐
- ////////////////////////////////////////////////////////////////////////////
- String ls_Null
- Long ll_Hdc,ll_HDCTemp,ll_HbmpTemp
- Long ll_MaskColor = -1
- ll_HDC = CreateDC("DISPLAY",ls_Null,ls_Null,0)
- If ll_HDC<>0 Then
- //创建一个与指定设备兼容的内存上下文环境
- ll_HDCTemp = CreateCompatibleDC(ll_HDC)
- If ll_HDCTemp<>0 Then
- //选择一个对象到指定的设备上下文环境
- ll_HbmpTemp = SelectObject(ll_HDCTemp, al_BitMapHandle)
- //获得位图坐标(0,0)颜色值
- ll_MaskColor = GetPixel(ll_HDCTemp,0,0)
- SelectObject(ll_HDCTemp,ll_HbmpTemp)
- DeleteDC(ll_HDCTemp)
- End If
-
- DeleteDC(ll_HDC)
- End If
- Return ll_MaskColor
- end function
- private function integer of_add (long al_itemid, string as_text, ref menu am_menu, integer ai_level);//-------------------------------------------------------*
- // FUNCTION: of_add *
- // Description: register a menuitem *
- //-------------------------------------------------------*
- // Parameters: long al_itemid *
- // string as_text *
- // menu am_menu *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // Rain 2003.03.10 Develop *
- //-------------------------------------------------------*
- //Modify History: Add:Get the icon by Dale Zheng.
- int li_newpos,li_pos
- string ls_shortcutkey
- li_pos = POS(as_text,"~t")
- IF li_pos > 0 THEN
- ls_shortcutkey = MID(as_text,li_pos + 1)
- as_text = LEFT(as_text,li_pos - 1)
- END IF
- li_newpos = upperbound(ist_menuinfo) + 1
- ist_menuinfo[li_newpos].ItemID = al_Itemid
- ist_menuinfo[li_newpos].ItemName = as_text
- ist_menuinfo[li_newpos].ShortcutKey = ls_ShortcutKey
- ist_menuinfo[li_newpos].menupt = am_menu
- ist_menuinfo[li_newpos].level = ai_level
- if am_menu.ToolbarItemName<>'' then ist_menuinfo[li_newpos].hIcon=of_GetIconHandle(am_menu.ToolbarItemName)
- RETURN li_newpos
- end function
- public subroutine of_registermenu (integer ai_level, long al_hmenu, long al_hsysmenu);//-------------------------------------------------------*
- // FUNCTION: of_registermenu *
- // Description: 注册未知名的菜单 *
- //-------------------------------------------------------*
- // Parameters: *
- // int ai_level *
- // long al_hmenu
- // long al_hsysmenu
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // bluetlck
- //-------------------------------------------------------*
- Constant int MIIM_STATE = 1
- Constant int MIIM_ID = 2
- Constant int MIIM_SUBMENU = 4
- Constant int MIIM_CHECKMARKS = 8
- Constant int MIIM_TYPE = 16
- Constant int MIIM_DATA = 32
- Constant int MFS_CHECKED = 8
- //Constant int MF_DISABLED = 2
- //Constant int MF_GRAYED = 1
- Integer li_index,li_row,li_count
- uLong hSubMenu
- if al_hmenu<=0 then return
- li_count= GetMenuItemCount(al_hmenu)
- string ls_menuText
- ls_menuText=space(255)
- For li_index = 1 to li_count
- hSubMenu = GetSubMenu(al_hmenu,li_index - 1)
- if al_hsysmenu = hSubMenu then
- li_index ++
- hSubMenu = GetSubMenu(al_hmenu,li_index - 1)
- end if
- if ai_level > 0 then
- lpMenuItemInfo.cbsize=44
- lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA +MIIM_STATE
- GetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
- //not ownerdraw menuitem
- If lpMenuItemInfo.dwItemData=0 or not of_containselement(lpMenuItemInfo.fType,MF_OWNERDRAW)then
- GetMenuString(al_hmenu,li_index - 1,ls_menuText,255,MF_BYPOSITION )
- lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA
- lpMenuItemInfo.fType= lpMenuItemInfo.fType+MF_OWNERDRAW
- if lpMenuItemInfo.dwItemData >0 then
- li_row = of_find_byid(lpMenuItemInfo.dwItemData)
- else
- li_row = of_find_byname(ls_menuText)
- end if
- if li_row>0 then
- lpMenuItemInfo.dwItemData = ist_menuinfo[li_row].ItemID
- if ist_menuinfo[li_row].menupt.text<>"-" then ist_menuinfo[li_row].menupt.text=ls_menuText
- if of_containselement(lpMenuItemInfo.fstate,MFS_CHECKED) then
- ist_menuinfo[li_row].menupt.checked = true
- else
- ist_menuinfo[li_row].menupt.checked = false
- end if
- if of_containselement(lpMenuItemInfo.fstate,MF_GRAYED) then
- ist_menuinfo[li_row].menupt.enabled = false
- else
- ist_menuinfo[li_row].menupt.enabled = true
- end if
- SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
- else
- ii_num++
- menu m_temp
- m_temp=create menu
- if ls_menuText="" then
- m_temp.enabled =false
- m_temp.text="-"
- else
- m_temp.text=ls_menuText
- if of_containselement(lpMenuItemInfo.fstate,MFS_CHECKED) then
- m_temp.checked = true
- else
- m_temp.checked = false
- end if
- if of_containselement(lpMenuItemInfo.fstate,MF_GRAYED) then
- m_temp.enabled = false
- else
- m_temp.enabled = true
- end if
- end if
- of_add(ii_num,ls_menuText,m_temp,ai_level)
- lpMenuItemInfo.dwItemData = ii_num
- SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
- end if
- else
- li_row = of_find_byid(lpMenuItemInfo.dwItemData)
- if li_row>0 then
- if of_Containselement(lpMenuItemInfo.fstate,MFS_CHECKED) then
- ist_menuinfo[li_row].menupt.checked = true
- else
- ist_menuinfo[li_row].menupt.checked = false
- end if
- if of_containselement(lpMenuItemInfo.fstate,MF_GRAYED) then
-
- ist_menuinfo[li_row].menupt.enabled = false
- else
- ist_menuinfo[li_row].menupt.enabled = true
- end if
- end if
- end if
-
- end if
- if hSubMenu>0 then of_registermenu(ai_level + 1,hsubMenu,al_hsysmenu)
- next
- end subroutine
- public subroutine of_drawitem (ref unsignedlong childid, ref long drawitemstruct);//-------------------------------------------------------*
- // FUNCTION: of_drawitem *
- // Description: draw menuitem *
- //-------------------------------------------------------*
- // Parameters: ulong childid *
- // long drawitemstruct *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // 贱客无名 2003.02.27 Develop *
- // Addison lu 2003.03.03 *
- // Rain 2003.03.10 Draw disalbed state
- // Bluetlck 2003.05 modify
- //-------------------------------------------------------*
- zDrawItemStruct tDrawItemStruct
- uLong hdc,hIcon
- Integer li_row,li_level
- tagrect rTmp
- CopyMemory(tDrawItemStruct,drawitemstruct,48)
- hdc = tDrawItemStruct.hdc
- rTmp = tDrawItemStruct.rcItem
- li_row = of_find_byid(tDrawItemStruct.itemdata)
- if li_row<= 0 then return
- li_level = ist_menuinfo[li_row].level
- //if MenuBKStyle = STYLE_BKWhite and ls_ItemName<>"-" then ls_ItemName=" "+ls_ItemName
- IF of_containselement(tDrawItemStruct.ItemState,1) then
- //selected state
- if ist_menuinfo[li_row].menupt.enabled then
- of_drawselectitem(Menustyle,hdc,rTmp,ist_menuinfo[li_row])
- end if
- else
- of_drawnormalitem(MenuBKStyle,hdc,rTmp,ist_menuinfo[li_row])
- End If
- end subroutine
- private subroutine of_drawtext (unsignedlong hdc, string as_text, string as_shortcutkey, tagrect ast_rect, boolean ab_enabled);//-------------------------------------------------------*
- // FUNCTION: of_drawtext *
- // Description: *
- //-------------------------------------------------------*
- // Parameters: ulong hdc *
- // string as_text *
- // tagrect ast_rect *
- // boolean ab_enabled *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // Rain 2003.03.10 *
- //-------------------------------------------------------*
- SetBkMode(hdc,TRANSPARENT)
- long lhdc_temp,MenuFont,OldFont
- IF ab_enabled THEN
- SetTextColor(hdc,GetSysColor(COLOR_MENUTEXT))
- DrawText(hdc,as_text,Len(as_text),ast_rect,DT_LEFT)
- ast_rect.Right =ast_rect.Right - 12
- DrawText(hdc,as_shortcutkey,Len(as_shortcutkey),ast_rect,DT_RIGHT)
- ELSE
- SetTextColor( hdc , GetSysColor( COLOR_BTNHIGHLIGHT))
- ast_rect.Left = ast_rect.Left + 1
- ast_rect.Top = ast_rect.Top + 1
- DrawText( hdc , as_text , len(as_text) , ast_rect, DT_VCENTER)
- SetTextColor( hdc,GetSysColor( COLOR_BTNSHADOW ) )
- ast_rect.Left = ast_rect.Left -1
- ast_rect.Top = ast_rect.Top -1
- DrawText( hdc , as_text , len(as_text) , ast_rect , DT_VCENTER)
- //// rjh added.
- SetTextColor( hdc , GetSysColor( COLOR_BTNHIGHLIGHT))
- //ast_rect.Left = (ast_rect.Right - 22) * ad_rate + 22 + 1
- ast_rect.Right =ast_rect.Right - 12
- ast_rect.Top += 1
- DrawText( hdc , as_shortcutkey , len(as_shortcutkey) , ast_rect, DT_RIGHT)
- SetTextColor( hdc,GetSysColor( COLOR_BTNSHADOW ) )
- ast_rect.Left = ast_rect.Left - 1
- ast_rect.Top = ast_rect.Top -1
- DrawText( hdc , as_shortcutkey , len(as_shortcutkey) , ast_rect , DT_RIGHT)
- END IF
- end subroutine
- public subroutine of_registermenu (ref menu am_menu, integer ai_level, long al_hmenu, long al_hsysmenu);//-------------------------------------------------------*
- // FUNCTION: of_registermenu *
- // Description: 注册知名的菜单 *
- //-------------------------------------------------------*
- // Parameters: menu am_menu *
- // int ai_level *
- // long al_hmenu
- // long al_hsysmenu
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // 贱客无名 2003.02.27 Develop *
- // Rain 2003.03.10 use array instead of ds
- // bluetlck 2003.04.25 use SetMenuItemInfo instead of ModifyMenu
- //-------------------------------------------------------*
- Constant int MIIM_STATE = 1
- Constant int MIIM_ID = 2
- Constant int MIIM_SUBMENU = 4
- //Constant int MIIM_CHECKMARKS = 8
- Constant int MIIM_TYPE = 16
- Constant int MIIM_DATA = 32
- Constant int MFS_CHECKED = 8
- Integer li_countitem,li_index,li_row,li_count
- Integer li_itempos //由于不可见菜单项的影响,li_index不等于menu item position
- uLong hSubMenu
- if al_hmenu<=0 then return
- li_countitem = UpperBound(am_menu.Item[])
- For li_index = 1 To li_countitem
-
- if am_menu.Item[li_index].visible=false then
- continue
- end if
-
- li_itempos++
-
- hSubMenu = GetSubMenu(al_hmenu,li_itempos - 1)
- if al_hsysmenu = hSubMenu then //if it's system menu
- li_itempos++
- hSubMenu = GetSubMenu(al_hmenu,li_itempos - 1)
- end if
- If am_menu.Item[li_index].Text = "-" Then am_menu.Item[li_index].Enabled = false
- If ai_level > 0 Then
- lpMenuItemInfo.cbsize=44
- lpMenuItemInfo.fMask = MIIM_TYPE+MIIM_DATA
- boolean lb_return
-
- lb_return = GetMenuItemInfo(al_hmenu,li_itempos - 1,true,lpMenuItemInfo)
- if lpMenuItemInfo.dwItemData=0 or not of_Containselement(lpMenuItemInfo.fType,MF_OWNERDRAW) then
- lpMenuItemInfo.fType= lpMenuItemInfo.fType + MF_OWNERDRAW
- lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA
-
- //li_row = of_find_bymenuId(am_menu.Item[li_index].classname())
- if lpMenuItemInfo.dwItemData>0 then li_row = of_find_byId(lpMenuItemInfo.dwItemData)
- if li_row<=0 then
- ii_num++ //菜单的唯一标示,舍弃了以前利用ItemID的方法
- lpMenuItemInfo.dwItemData = ii_num
- SetMenuItemInfo(al_hmenu,li_itempos - 1,true,lpMenuItemInfo)
- of_add(ii_num,am_menu.Item[li_index].Text,am_menu.item[li_index],ai_level)
- else
- lpMenuItemInfo.dwItemData = ist_menuinfo[li_row].ItemID
- SetMenuItemInfo(al_hmenu,li_itempos - 1,true,lpMenuItemInfo)
- end if
- end if
-
- end if
- if hSubMenu>0 then of_registermenu(am_menu.Item[li_index],ai_level + 1,hsubMenu,al_hsysmenu)
- Next
-
-
- //以下处理由于sheet窗口而动态生成的菜单,有一定问题!~
- li_count= GetMenuItemCount(al_hmenu)
- if li_itempos<li_count - 1 and ai_level>0 then
-
- string ls_menuText
- ls_menuText=space(255)
- For li_index = li_count to li_itempos + 1 step - 1
- lpMenuItemInfo.cbsize=44
- lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA +MIIM_STATE
-
- lb_return = GetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
- if lpMenuItemInfo.dwItemData=0 or not of_containselement(lpMenuItemInfo.fType,MF_OWNERDRAW) then //not ownerdraw menuitem
- GetMenuString(al_hmenu,li_index - 1,ls_menuText,255,MF_BYPOSITION )
-
- lpMenuItemInfo.fMask = MIIM_TYPE +MIIM_DATA
- lpMenuItemInfo.fType= lpMenuItemInfo.fType+MF_OWNERDRAW
- li_row = of_find_byname(ls_menuText)
- if li_row>0 then
- lpMenuItemInfo.dwItemData = ist_menuinfo[li_row].ItemID
- if lpMenuItemInfo.fState= MFS_CHECKED then
- ist_menuinfo[li_row].menupt.checked = true
- else
- ist_menuinfo[li_row].menupt.checked = false
- end if
- SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
- else
- ii_num++
- menu m_temp
- m_temp=create menu
- if ls_menuText="" then
- m_temp.enabled =false
- m_temp.text="-"
- else
- m_temp.text=ls_menuText
- if lpMenuItemInfo.fState= MFS_CHECKED then m_temp.checked = true
- end if
- of_add(ii_num,ls_menuText,m_temp,ai_level)
- lpMenuItemInfo.dwItemData = ii_num
- SetMenuItemInfo(al_hmenu,li_index - 1,true,lpMenuItemInfo)
- end if
- end if
- next
- end if
- end subroutine
- public subroutine of_drawchecked (long hdc, ref tagrect rect);long hpen,holdpen
- //hPen = CreatePen(PS_SOLID,2,RGB(0,0,147))
- //holdPen=SelectObject(hdc,hPen)
- //MoveToEx(hdc,rect.Left+6,rect.Top+10,0)
- //LineTo(hdc,rect.Left+8,rect.Top+14)
- //LineTo(hdc,rect.Left + 14,rect.top+ 6)
- tagrect fillrect
- fillrect.left = rect.left +8
- fillrect.right = rect.left +14
- fillrect.top = rect.top +9
- fillrect.bottom = rect.top +14
- hPen = CreatePen(PS_SOLID,1,GetSysColor(COLOR_ACTIVECAPTION))
- holdpen = SelectObject(hdc,hPen)
- RoundRect(hdc,fillrect.Left - 2,fillrect.Top - 2,fillrect.right +2,fillrect.bottom+2,4,4)
- SelectObject(hdc,holdPen)
- deleteobject(hPen)
- FillRect(hdc,fillrect,GetSysColorBrush(COLOR_HIGHLIGHT))
- end subroutine
- private function unsignedlong of_createverticalfont (long hdc);//-------------------------------------------------------*
- // FUNCTION: of_CreateVerticalFont *
- // Description: *
- //-------------------------------------------------------*
- // Arguments:
- //
- // long hdc
- // *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // Rain 2003.03.10 *
- //-------------------------------------------------------*
- long ll_font
- long ll_textlen = 255
- string ls_text = space(255)
- LOGFONT VerticalFont
- ll_textlen = GetTextFace(hdc, ll_TextLen, ls_Text)
-
- VerticalFont.lfFaceName = Left(ls_text, ll_textlen+1 )
- VerticalFont.lfWeight = 700
- VerticalFont.lfEscapement = 900
- VerticalFont.lfOrientation = 900
- VerticalFont.lfHeight = - 16;
- ll_font = CreateFontIndirect(VerticalFont)
- RETURN ll_font
- //Type LOGFONT
- //lfHeight As Integer ' 字体的高度
- //lfWidth As Integer ' 字体的宽度
- //lfEscapement As Integer ' 字体旋转的角度
- //lfOrientation As Integer
- //lfWeight As Integer ' 字体的轻重
- //lfItalic As String * 1 ' 是否为斜体
- //lfUnderline As String * 1 ' 是否有下划线
- //lfStrikeOut As String * 1 ' 是否有强调线
- //lfCharSet As String * 1 ' 字符集
- //lfOutPrecision As String * 1 ' 输出精度
- //lfClipPrecision As String * 1 ' 剪裁精度
- //lfQuality As String * 1 ' 输出质量
- //lfPitchAndFamily As String * 1 ' 间距和字体族
- //lfFaceName As String * LF_FACESIZE ' 字体名,如“宋体”
- //End Type
- end function
- public function boolean of_containselement (long al_src, long al_exponent);//判断一个数中的某个二进制位是否是1,也就是两个数求逻辑or后是否仍然是第一个数
- //al_dst必须为2的整数次方(这个整数次方就是al_src的某一位,出于效率不作判断),否则结果不能预料
- al_src = al_src/al_exponent
- if mod(al_src,2) = 1 then
- return true
- else
- return false
- end if
- end function
- public subroutine of_fillwithgradient (unsignedlong hdc, tagrect rect, long colorfrom, long colorto);//--------------------------------------------------------------------
- // Write By: 贱客无名 Date: 2003.02.27
- // Modified by : Addison Lu Sunday, 2/3/3
- //--------------------------------------------------------------------
- int li_height, li_width, li, li_steps,li_halfwidth
- int li_ori_left, li_ori_right
- long ll_rgb
- ulong hBrush, hOldBrush
- int r1,r2,g1,g2,b1,b2,vr,vg,vb
- IF Menustyle = STYLE_VGRADIENT THEN
- GOTO VGRADIENT
- END IF
- IF Menustyle = STYLE_VEDGEGRADIENT THEN
- GOTO VEDGEGRADIENT
- END IF
- IF Menustyle = STYLE_VHEADERGRADIENT THEN
- GOTO VHEADERGRADIENT
- END IF
- li_steps = 30 - 1
- li_width = (rect.right - rect.left) / li_steps
- of_color2rgb(colorfrom,r1,g1,b1)
- of_color2rgb(colorto,r2,g2,b2)
- vr = abs(r1 - r2) / li_steps
- vg = abs(g1 - g2) / li_steps
- vb = abs(b1 - b2) / li_steps
- IF r2<r1 THEN vr = vr * -1
- IF g2<g1 THEN vg = vg * -1
- IF b2<b1 THEN vb = vb * -1
- SetBkMode(hdc,TRANSPARENT)
- li_ori_left = rect.left
- li_ori_right = rect.right
- FOR li = 1 TO li_steps
- r2 = r1 + vr * li
- g2 = g1 + vg * li
- b2 = b1 + vb * li
- ll_RGB = RGB( r2, g2, b2)
- rect.left = li_ori_left + (li - 1) *li_width
- rect.right = rect.left + li_width
- hBrush = CreateSolidBrush(ll_rgb)
- FillRect(hdc,rect,hBrush)
- DeleteObject(hBrush)
- NEXT
- rect.left = li_ori_left + (li - 1) *li_width
- rect.right = li_ori_right
- hBrush = CreateSolidBrush(ll_rgb)
- FillRect(hdc,rect,hBrush)
- DeleteObject(hBrush)
- RETURN
- VGRADIENT:
- li_steps = 20 - 1
- li_width = (rect.bottom - rect.top) / li_steps
- of_color2rgb(colorfrom,r1,g1,b1)
- of_color2rgb(colorto,r2,g2,b2)
- vr = abs(r1 - r2) / li_steps
- vg = abs(g1 - g2) / li_steps
- vb = abs(b1 - b2) / li_steps
- IF r2<r1 THEN vr = vr * -1
- IF g2<g1 THEN vg = vg * -1
- IF b2<b1 THEN vb = vb * -1
- SetBkMode(hdc,TRANSPARENT)
- li_ori_left = rect.top
- li_ori_right = rect.bottom
- FOR li = 1 TO li_steps
- r2 = r1 + vr * li
- g2 = g1 + vg * li
- b2 = b1 + vb * li
- ll_RGB = RGB( r2, g2, b2)
- rect.top = li_ori_left + (li - 1) * li_width
- rect.bottom = rect.top + li_width
- hBrush = CreateSolidBrush(ll_rgb)
- FillRect(hdc,rect,hBrush)
- DeleteObject(hBrush)
- NEXT
- rect.top = li_ori_left + (li - 1) * li_width
- rect.bottom = li_ori_right
- hBrush = CreateSolidBrush(ll_rgb)
- FillRect(hdc,rect,hBrush)
- DeleteObject(hBrush)
- return
- VEDGEGRADIENT:
- tagrect rect2
- rect2=rect
- li_steps = 11 - 1
- li_halfwidth= (rect.bottom - rect.top) /2
- li_ori_left = rect.top
- li_ori_right = rect.bottom
- rect.bottom = li_halfwidth + rect.top
- rect2.top=rect2.bottom - li_halfwidth
- li_width = (rect.bottom - rect.top) / li_steps
- of_color2rgb(colorto,r1,g1,b1)
- of_color2rgb(colorfrom,r2,g2,b2)
- vr = abs(r1 - r2) / li_steps
- vg = abs(g1 - g2) / li_steps
- vb = abs(b1 - b2) / li_steps
- IF r2<r1 THEN vr = vr * -1
- IF g2<g1 THEN vg = vg * -1
- IF b2<b1 THEN vb = vb * -1
- SetBkMode(hdc,TRANSPARENT)
- FOR li = 1 TO li_steps
- r2 = r1 + vr * li
- g2 = g1 + vg * li
- b2 = b1 + vb * li
- ll_RGB = RGB( r2, g2, b2)
- rect.top = li_ori_left + (li - 1) * li_width
- rect.bottom = rect.top + li_width
-
- rect2.top = li_ori_Right - (li - 1) * li_width
- rect2.bottom = rect.bottom - li_width
-
- hBrush = CreateSolidBrush(ll_rgb)
- FillRect(hdc,rect,hBrush)
- FillRect(hdc,rect2,hBrush)
- DeleteObject(hBrush)
- NEXT
- return
- VHEADERGRADIENT:
- li_steps = 11 - 1
- li_halfwidth= (rect.bottom - rect.top) /2
- li_ori_left = rect.top
- li_ori_right = rect.bottom
- rect.bottom = li_halfwidth + rect.top
- rect2.top=rect2.bottom - li_halfwidth
- li_width = (rect.bottom - rect.top) / li_steps
- of_color2rgb(colorto,r1,g1,b1)
- of_color2rgb(colorfrom,r2,g2,b2)
- vr = abs(r1 - r2) / li_steps
- vg = abs(g1 - g2) / li_steps
- vb = abs(b1 - b2) / li_steps
- IF r2<r1 THEN vr = vr * -1
- IF g2<g1 THEN vg = vg * -1
- IF b2<b1 THEN vb = vb * -1
- SetBkMode(hdc,TRANSPARENT)
- FOR li = 1 TO li_steps
- r2 = r1 + vr * li
- g2 = g1 + vg * li
- b2 = b1 + vb * li
- ll_RGB = RGB( r2, g2, b2)
- rect.top = li_ori_left + (li - 1) * li_width
- rect.bottom = rect.top + li_width
-
- hBrush = CreateSolidBrush(ll_rgb)
- FillRect(hdc,rect,hBrush)
- DeleteObject(hBrush)
- NEXT
- rect.top = li_ori_left + (li - 1) * li_width
- rect.bottom = li_ori_right
- hBrush = CreateSolidBrush(ll_rgb)
- FillRect(hdc,rect,hBrush)
- DeleteObject(hBrush)
- return
- end subroutine
- private subroutine of_drawfirstlevelmenu (ref zdrawitemstruct ast_drawitemstruct, ref ust_menuinfo ast_menuinfo);//not complete!
- end subroutine
- private subroutine of_drawnormalitem (integer ai_menubkstyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo);string ls_ItemName,ls_shortcutkey
- long hIcon
- tagrect rTmp
- menu lm_menupt
- long hBrush,hOldBrush,hPen,hOldPen
- ls_ItemName = ast_menuinfo.menupt.text
- if MenuBKStyle = STYLE_BKWhite and ls_ItemName<>"-" then ls_ItemName=" "+ls_ItemName
- lm_menupt = ast_menuinfo.menupt
- hIcon = ast_menuinfo.hIcon
- ls_shortcutkey = ast_menuinfo.shortcutkey
- int li_pos
- li_pos = POS(ls_ItemName,"~t")
- IF li_pos > 0 THEN
- ls_ItemName = LEFT(ls_ItemName,li_pos - 1)
- END IF
- choose case ai_MenuBKStyle
- case STYLE_BKWhite
- FillRect(hdc,ast_rect,GetStockObject(WHITE_BRUSH))
- rTmp.Left = ast_rect.Left
- rTmp.top= ast_rect.top
- rTmp.Right = ast_rect.Left+20
- rTmp.bottom = ast_rect.bottom
- hBrush = CreateSolidBrush(RGB(240, 240,240))
- FillRect(hdc,rTmp,hBrush)
- DeleteObject(hBrush)
-
- hPen = CreatePen(PS_SOLID,0,RGB(200,200,200))
- hOldPen = SelectObject(hdc,hPen)
- MoveToEx(hdc,rTmp.Left,rTmp.Top,0)
- LineTo(hdc,rTmp.Left,rTmp.Bottom)
- MoveToEx(hdc,rTmp.Right,rTmp.Top,0)
- LineTo(hdc,rTmp.Right,rTmp.Bottom)
- SelectObject(hdc, hOldPen)
- DeleteObject(hPen)
-
-
- case STYLE_BKGRAY
- hBrush = CreateSolidBrush(RGB(221, 227,235))
- FillRect(hdc,ast_rect,hBrush)
- DeleteObject(hBrush)
-
- rTmp.Left = ast_rect.Left
- rTmp.top= ast_rect.top
- rTmp.Right = ast_rect.Left+20
- rTmp.bottom = ast_rect.bottom
- hBrush = CreateSolidBrush(RGB(156, 171,186))
- FillRect(hdc,rTmp,hBrush)
- DeleteObject(hBrush)
-
- hPen = CreatePen(PS_SOLID,0,RGB(127,136,147))
- holdPen=SelectObject(hdc,hPen)
- MoveToEx(hdc,rTmp.Left,rTmp.Top,0)
- LineTo(hdc,rTmp.Left,rTmp.Bottom)
-
- MoveToEx(hdc,rTmp.Left,0,0)
- LineTo(hdc,rTmp.Right - 1,0)
- MoveToEx(hdc,rTmp.Left+20,rTmp.Top,0)
- LineTo(hdc,rTmp.Left+20,rTmp.Bottom)
- SelectObject(hdc, hOldPen)
- DeleteObject(hPen)
- case STYLE_BKGRAY_XP
-
- FillRect(hdc,ast_rect,GetStockObject(WHITE_BRUSH))
-
- rTmp.Left = ast_rect.Left
- rTmp.top= ast_rect.top
- rTmp.Right = ast_rect.Left+20
- rTmp.bottom = ast_rect.bottom
- FillRect(hdc,rTmp,GetStockObject(GRAY_BRUSH))
-
- hPen = CreatePen(PS_SOLID,0,RGB(127,136,147))
- holdPen=SelectObject(hdc,hPen)
- MoveToEx(hdc,rTmp.Left,rTmp.Top,0)
- LineTo(hdc,rTmp.Left,rTmp.Bottom)
-
- MoveToEx(hdc,rTmp.Left,0,0)
- LineTo(hdc,rTmp.Right - 1,0)
- MoveToEx(hdc,rTmp.Left+20,rTmp.Top,0)
- LineTo(hdc,rTmp.Left+20,rTmp.Bottom)
-
- SelectObject(hdc, hOldPen)
- DeleteObject(hPen)
- case STYLE_BKAMB
-
- FillRect(hdc,ast_rect, GetStockObject(WHITE_BRUSH))
-
- rTmp.Left = ast_rect.Left
- rTmp.top= ast_rect.top
- rTmp.Right = ast_rect.Left+22
- rTmp.bottom = ast_rect.bottom
- FillRect(hdc,rTmp,GetSysColorBrush(COLOR_BTNFACE))
- SelectObject(hdc, hOldBrush)
- DeleteObject(hBrush)
-
- case else
- FillRect(hdc,ast_rect,GetSysColorBrush(COLOR_MENU))
- end choose
- //draw text and ico
- IF lm_menupt.enabled THEN
- if lm_menupt.checked then
- of_drawchecked(hdc,ast_rect)
- elseif hIcon>0 then
- DrawIconEx(hdc,ast_rect.Left + 3,ast_rect.Top + 3,hIcon,16,16,0,0,3)
- end if
- ast_rect.Left = ast_rect.Left + 24
- ast_rect.Top = ast_rect.Top + 4
- of_drawtext(hdc,ls_itemname,ls_shortcutkey,ast_rect,true)
-
- ELSE
- if ls_ItemName="-" then
- if MenuBKStyle = STYLE_BKWhite or MenuBKStyle = STYLE_BKGRAY or MenuBKStyle = STYLE_BKGRAY_XP then
- hPen = CreatePen(PS_SOLID,0,RGB(172,168,153))
- hOldPen = SelectObject(hdc,hPen)
- int li_middpos
- li_middpos = (ast_rect.Top+ast_rect.Bottom)/2
- MoveToEx(hdc,ast_rect.Left+22,li_middpos,0)
- LineTo(hdc,ast_rect.Right,li_middpos)
- SelectObject(hdc,hOldPen)
- DeleteObject(hPen)
- else
- hPen = CreatePen(PS_SOLID,0,RGB(128,128,128))
- hOldPen = SelectObject(hdc,hPen)
- li_middpos = (ast_rect.Top+ast_rect.Bottom)/2
- MoveToEx(hdc,ast_rect.Left - 4,li_middpos,0)
- LineTo(hdc,ast_rect.Right - 1,li_middpos)
- SelectObject(hdc,hOldPen)
- DeleteObject(hPen)
-
- hPen = GetStockObject(WHITE_PEN)
- SelectObject(hdc,hPen)
- li_middpos = li_middpos+1
- MoveToEx(hdc,ast_rect.Left - 4,li_middpos,0)
- LineTo(hdc,ast_rect.Right - 1,li_middpos)
- SelectObject(hdc,hOldPen)
- end if
- end if
- if hIcon>0 then DrawState(hdc, 0, 0, hIcon, 0, ast_rect.Left + 3, ast_rect.Top + 3,16, 16, DST_ICON + DSS_DISABLED)
- ast_rect.Left = ast_rect.Left + 24
- ast_rect.Top = ast_rect.Top + 4
- of_drawtext(hdc,ls_itemname,ls_shortcutkey,ast_rect,False)
- END IF
- end subroutine
- public function decimal of_getshortcutkeyrate (menu am_menu);string ls_text
- long lhdc_temp,MenuFont,OldFont
- tagrect rc,tmp
- integer li_for,li_pos,li_tmp,li_width1,li_width2
- Dec ld_rate,ld_this
- lhdc_temp = GetDC(il_winhandle)
- MenuFont = of_GetmenuFont(lhdc_temp)
- OldFont = SelectObject(lhdc_temp,MenuFont)
- FOR li_for = 1 TO UpperBound(am_menu.Item)
- ls_text = am_menu.Item[li_for].Text
- li_pos = POS(ls_text,"~t")
-
- IF li_pos > 0 THEN
-
- rc = tmp
- DrawText(lhdc_temp,LEFT(ls_text,li_pos - 1),li_pos - 1,rc,DT_CALCRECT)
- li_tmp = rc.right - rc.left
- IF li_tmp > li_width1 THEN
- li_width1 = li_tmp
- END IF
- rc = tmp
- DrawText(lhdc_temp,MID(ls_text,li_pos + 1),Len(ls_text) - li_pos,rc,DT_CALCRECT)
- li_tmp = rc.right - rc.left
- IF li_tmp > li_width2 THEN
- li_width2 = li_tmp
- END IF
-
- END IF
- NEXT
- SelectObject(lhdc_temp,OldFont)
- IF li_width1 + li_width2 > 0 THEN
- ld_rate = li_width1 / ( li_width1 + li_width2 )
- END IF
- ReleaseDc(il_winhandle,lhdc_temp)
- RETURN ld_rate
- end function
- public subroutine of_setvisible (menu am_menu, boolean ab_visible);//NOW CAN IMPLEMENT!
- am_menu.visible=ab_visible
- of_registerwindow(iw_win)
- end subroutine
- public subroutine of_registerwindow (readonly window aw_win);//-------------------------------------------------------*
- // FUNCTION: of_registerwindow *
- // Description: *
- //-------------------------------------------------------*
- // Parameters: window aw_win *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // Rain 2003.03.10 Develop *
- //-------------------------------------------------------*
- uLong hMenu,ll_hsysmenu
- menu smenu
- String sMenuName
- Integer li_level = 0
- il_winhandle = handle(aw_win)
- iw_win = aw_win
- hMenu = GetMenu(il_winhandle)
- smenu = aw_win.menuid
- if hMenu>0 then
- ll_hsysmenu = GetSystemMenu(il_winhandle,false)
- of_registermenu(smenu,li_level,hMenu,ll_hsysmenu)
- end if
- end subroutine
- public function boolean of_iswhitespace (string as_source);//////////////////////////////////////////////////////////////////////////////
- //
- // Function: of_IsWhiteSpace
- //
- // Access: public
- //
- // Arguments:
- // as_source The source string.
- //
- // Returns: Boolean
- // True if the string only contains White Space characters.
- // If any argument's value is NULL, function returns NULL.
- //
- // Description: Determines whether a string contains only White Space
- // characters. White Space characters include Newline, Tab,
- // Vertical tab, Carriage return, Formfeed, and Backspace.
- //
- //////////////////////////////////////////////////////////////////////////////
- //
- // Revision History
- //
- // Version
- // 5.0 Initial version
- //
- //////////////////////////////////////////////////////////////////////////////
- //
- // Copyright ?1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
- // Any distribution of the PowerBuilder Foundation Classes (PFC)
- // source code by other than Sybase, Inc. and its subsidiaries is prohibited.
- //
- //////////////////////////////////////////////////////////////////////////////
- long ll_count=0
- long ll_length
- char lc_char[]
- integer li_ascii
- //Check parameters
- If IsNull(as_source) Then
- boolean lb_null
- SetNull(lb_null)
- Return lb_null
- End If
- //Get the length
- ll_length = Len (as_source)
- //Check for at least one character
- If ll_length=0 Then
- Return False
- End If
- //Move string into array of chars
- lc_char = as_source
- //Perform loop around all characters
- //Quit loop if Non WhiteSpace character is found
- do while ll_count<ll_length
- ll_count ++
-
- //Get ASC code of character.
- li_ascii = Asc (lc_char[ll_count])
-
- If li_ascii=8 or /* BackSpae */ &
- li_ascii=9 or /* Tab */ &
- li_ascii=10 or /* NewLine */ &
- li_ascii=11 or /* Vertical Tab */ &
- li_ascii=12 or /* Form Feed */ &
- li_ascii=13 or /* Carriage Return */ &
- li_ascii=32 Then /* Space */
- //Character is a WhiteSpace.
- //Continue with the next character.
- Else
- /* Character is Not a White Space. */
- Return False
- End If
- loop
-
- // Entire string is White Space.
- return True
- end function
- public subroutine of_measureitem (ref unsignedlong childid, ref long measureitemstruct);//-------------------------------------------------------*
- // FUNCTION: of_measureitem *
- // Description: *
- //-------------------------------------------------------*
- // Parameters: ulong childid *
- // long measureitemstruct *
- //-------------------------------------------------------*
- // Author(s) Date Remark *
- // 贱客无名 2003.02.27 Develop *
- // Rain 2003.03.10 calc width of menuitem
- // Bluetlck use GetTextExtentpoint32 instead of drawtext
- //-------------------------------------------------------*
- string ls_text
- long lhdc_temp,holdfont
- tagrect rc
- int li_row,rcWidth,li_return
- long Itemwidth
- MeasureItemStruct tMeasureItemStruct
- CopyMemory(tMeasureItemStruct,MeasureItemStruct,24)
- IF tMeasureItemStruct.CtlType <> 1 THEN // <> ODT_MENU
- RETURN
- END IF
- if tMeasureItemStruct.itemdata=0 then return
- li_row = of_find_byid(tMeasureItemStruct.itemdata)
- IF li_row =0 THEN
- RETURN //none of our business
- ELSE
- //get menuitem's text to measure width
- ls_text = trim(ist_menuinfo[li_row].menupt.text)
- int li_pos,li_lenght
- li_pos = POS(ls_text,"~t")
- IF li_pos = 0 THEN
- ls_text = ls_text +ist_menuinfo[li_row].ShortcutKey
- END IF
- END IF
- If ist_menuinfo[li_row].menupt.text="-" then
- tMeasureItemStruct.Itemheight = GetSystemMetrics(SM_CYMENU)/3
- tMeasureItemStruct.ItemWidth = 0
- else
- tMeasureItemStruct.ItemHeight = GetSystemMetrics(SM_CYMENU) +3
- lhdc_temp = GetDC(il_winhandle)
- TextSize lstr_Size
- // Get the size of the text.
-
- holdfont = SelectObject(lhdc_temp,GetStockObject(SYSTEM_FONT))
- GetTextExtentpoint32(lhdc_temp, ls_text, len(ls_text), lstr_Size )
- SelectObject(lhdc_temp,holdfont)
- rcWidth = lstr_Size.l_cx
- if ist_menuinfo[li_row].level <> 0 then
- itemwidth = rcWidth+22
- else
- itemwidth = rcWidth
- END IF
- tMeasureItemStruct.ItemWidth = itemwidth
- ReleaseDc(il_winhandle,lhdc_temp)
- end if
- CopyMemory(MeasureItemStruct,tMeasureItemStruct,24)
- end subroutine
- private subroutine of_drawselectitem (integer ai_menustyle, long hdc, ref tagrect ast_rect, ref ust_menuinfo ast_menuinfo);string ls_ItemName,ls_shortcutkey
- long hIcon
- tagrect rTmp
- menu lm_menupt
- ls_ItemName = ast_menuinfo.menupt.text
- if MenuBKStyle = STYLE_BKWhite and ls_ItemName<>"-" then ls_ItemName=" "+ls_ItemName
- lm_menupt = ast_menuinfo.menupt
- hIcon = ast_menuinfo.hIcon
- ls_shortcutkey = ast_menuinfo.shortcutkey
- int li_pos
- li_pos = POS(ls_ItemName,"~t")
- IF li_pos > 0 THEN
- ls_ItemName = LEFT(ls_ItemName,li_pos - 1)
- END IF
- Choose Case ai_Menustyle
- Case 1
- FillRect(hdc,ast_rect,GetSysColorBrush(COLOR_HIGHLIGHT))
- if lm_menupt.checked then
- of_drawchecked(hdc,ast_rect)
- elseif hIcon>0 then
- DrawIconEx(hdc,ast_rect.Left + 3,ast_rect.Top + 3,hIcon,16,16,0,0,3)
- end if
- SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
- Case 2
- //draw border
- rTmp.Top = ast_rect.Top
- rTmp.Left = ast_rect.Left + 1
- rTmp.Bottom = ast_rect.Bottom
- rTmp.Right = ast_rect.Left + 21
- DrawEdge(hdc,rTmp,BDR_RAISEDINNER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
- rTmp.Left = rTmp.Left + 22
- rTmp.Right = ast_rect.Right - 1
- DrawEdge(hdc,rTmp,BDR_SUNKENOUTER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
- If hIcon<=0 and not lm_menupt.Checked Then
- rTmp.Left = ast_rect.Left
- end if
- FillRect(hdc,rTmp,GetSysColorBrush(COLOR_HIGHLIGHT))
- SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
- Case 3
- rTmp.Top = ast_rect.Top
- rTmp.Left = ast_rect.Left + 1
- rTmp.Bottom = ast_rect.Bottom
- rTmp.Right = ast_rect.Left + 21
- DrawEdge(hdc,rTmp,BDR_RAISEDINNER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
- rTmp.Left = rTmp.Left + 22
- rTmp.Right = ast_rect.Right - 1
- If hIcon<=0 and not lm_menupt.Checked Then rTmp.Left = 0
- FillRect(hdc,rTmp,GetSysColorBrush(COLOR_BACKGROUND ))
- SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
- Case 4,5,6,7
- rTmp.Top = ast_rect.Top
- rTmp.Left = ast_rect.Left + 1
- rTmp.Bottom = ast_rect.bottom
- rTmp.Right = ast_rect.Left + 21
- DrawEdge(hdc,rTmp,BDR_RAISEDINNER,BF_TOP + BF_LEFT + BF_BOTTOM + BF_RIGHT)
-
- rTmp.Right = ast_rect.Right - 1
- If hIcon<=0 and not lm_menupt.Checked Then
- rTmp.Left = ast_rect.Left
- else
- rTmp.Left = rTmp.Left + 22
- end if
- of_FillWithGradient(hdc,rTmp,COLOR_START,COLOR_END)
- SetTextColor(hdc,GetSysColor(COLOR_HIGHLIGHTTEXT))
- Case 8,9,10 //XPSTYLE
- //--------------------------------------------------------------------
- // Write By: 王无敌 Date: 2003.03.02
- // Modified date : 2003.03.16
- //--------------------------------------------------------------------
- if Menustyle=8 then of_xprect(hdc,ast_rect,RGB(80, 80, 165),RGB(185,185,215))
- if Menustyle=9 then of_xprect(hdc,ast_rect,RGB(255, 131, 6),RGB(255,196,136))
- if Menustyle=10 then of_xprect(hdc,ast_rect,RGB(0, 0, 0),RGB(192,192,192))
- if lm_menupt.checked then
- of_drawchecked(hdc,ast_rect)
- elseif hIcon>0 then
- DrawIconEx(hdc,ast_rect.Left + 2,ast_rect.Top + 2,hIcon,16,16,0,0,3)
- end if
- Case STYLE_COLOR_INFOBK
- rtmp.left = ast_rect.left+22
- rtmp.right = ast_rect.right - 2
- rtmp.top = ast_rect.top +1
- rtmp.bottom = ast_rect.bottom - 1
- of_xprect(hdc,rtmp,RGB(0, 0, 0), GetSysColor(COLOR_INFOBK))
- if lm_menupt.checked then
- of_drawchecked(hdc,ast_rect)
- elseif hIcon>0 then
- DrawIconEx(hdc,ast_rect.Left + 2,ast_rect.Top + 2,hIcon,16,16,0,0,3)
- end if
- End Choose
-
- //draw text
- ast_rect.Left = ast_rect.Left + 24
- ast_rect.Top = ast_rect.Top + 4
- SetBkMode(hdc,TRANSPARENT)
- DrawText(hdc,ls_ItemName,Len(ls_ItemName),ast_rect,DT_VCENTER)
- ast_rect.Right =ast_rect.Right - 12
- DrawText(hdc,ls_shortcutkey,Len(ls_shortcutkey),ast_rect,DT_RIGHT)
- end subroutine
- on nvo_supermenu_class.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on nvo_supermenu_class.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- event destructor;integer li_loop
- //IF il_menufont<>0 THEN DeleteObject(il_menufont)
- FOR li_loop =1 TO UpperBound(ist_menuinfo)
- IF ist_menuinfo[li_loop].hIcon<>0 THEN
- DestroyIcon(ist_menuinfo[li_loop].hIcon)
- END IF
- if isValid(ist_menuinfo[li_loop].menupt) then
- destroy ist_menuinfo[li_loop].menupt
- end if
- NEXT
- end event
- event constructor;//----------------------------------------------------------------*
- // UserObject: nvo_supermenu_class *
- // Description: icon menu (ONLY WINDOW MENU SUPPORTED) *
- //----------------------------------------------------------------*
- // Author(s): Date Remark *
- // 贱客无名 2003.02.27 Develop *
- // Addison Lu 2003.03.02 fixed a few bugs *
- // 王无敌 2003.03.02 new "xp rectangle" style *
- // Rain 2003.03.10 as below *
- // *
- // I made a lot of changed on this object,such as *
- // 1.Encapsulates all code in one userobjet,since PB does not *
- // support "Address of Function" , so we can not set new *
- // WndProc, just makes the object more easy to use. *
- // 2.Uses structure array instead of Datastore *
- // 3.Calc width of menuitem at runtime(MEASUREITEM) *
- // 4.Draw disabled status *
- // 5.Performance enhanced,fixed Memorey Leak bugs ... *
- // *
- // it's a great pity that some bugs/functions are still not*
- // fixed/implemented. *
- // 1. submenu available when parent set disabled *
- // 2. can not modify visible property at runtime *
- //----------------------------------------------------------------*
- //============================================*
- // HOW TO USE *
- //============================================*
- // ---- 1.Declare INSTANCE Variable ----
- //
- // nvo_supermenu_class inv_supermenu // autoinstantiate
- //
- // ---- 2.Window Open Event ----
- //
- // inv_SuperMenu.MenuStyle = inv_SuperMenu.STYLE_STYLE3
- // inv_SuperMenu.of_registerwindow(this)
- // inv_SuperMenu.of_SetMenuIcon('BYID',"m_5","打开.ICO")
- // inv_SuperMenu.of_SetMenuIcon('BYTEXT',"新建","新建.ICO")
- // inv_SuperMenu.of_SetMenuIcon('BYID',"m_6","保存.ICO")
- //
- // ---- 3.ue_drawmenuitem(PBM_DRAWMENUITEM) ----
- // inv_SuperMenu.of_drawitem(childid,drawitemstruct)
- //
- // ---- 4.ue_measureitem(PBM_MEASUREITEM) ----
- // inv_SuperMenu.of_measureitem(childid,measureitemstruct)
- // more style
- //CONSTANT INTEGER STYLE_NORMAL = 1
- //CONSTANT INTEGER STYLE_OFFICE2K = 2
- //CONSTANT INTEGER STYLE_STYLE3 = 3
- //CONSTANT INTEGER STYLE_GRADIENT = 4
- ////Gradient style does not work well under Win98 ,
- ////and it's slow in PB. (My Computer : PIII 650,TNT2)
- //CONSTANT INTEGER STYLE_OFFICEXP = 5
- /* Bluetlck 2003.04.25 as below
- 两种设置visible属性的方法,取其一即可
- 1:利用inv_SuperMenu的内部函数of_setvisible
- 2:在菜单所在窗口中自定义事件pbm_initmenu,加入script:
- if hmenu <> inv_supermenu.GetMenu(handle(this)) then
- inv_supermenu.of_registermenu(m_dmm0200,1,hmenu)
- else
- inv_supermenu.of_registermenu(m_dmm0200,0,hmenu)
- end if
- 然后就可以直接更改菜单的visible属性
- */
- /* ATTENTION!!!
- if your pb version is not pb8 ,please modify some extelnal functions by hand.
- */
- if COLOR_START = 0 then COLOR_START = GetSysColor(COLOR_HIGHLIGHT)
- if COLOR_END =0 then COLOR_END =GetSysColor(COLOR_MENU)
- end event
|