'给菜单加图片
'yMenu   菜单句柄
'cID     命令ID或位置
'TbmpStr 图像库里的图像预览字符串,必须是 BMP 格式
'x       将图像里何处位置画到菜单中
'y 
'uFlags  标=MF_BYCOMMAND  cID 是命令 
'          =MF_BYPOSITION  cID 是位置，从0开始
Dim Shared MenuLoadImag_Str() As String,MenuLoadImag_B() As HBITMAP '避免重复加载，而没销毁句柄
Sub MenuLoadImag( yMenu As HMENU,cID As UInteger  , TbmpStr As String,x As Long=0,y As Long=0  ,ByVal uFlags As UINT=MF_BYCOMMAND )  '
  Dim U As Long  ,t As ZString *50,i As Long,ai As Long,confu As String 
  Dim As Long w,h
  confu=TbmpStr & x & "," & y
  u=UBound(MenuLoadImag_Str)
  ai=-1
  If u>-1 Then
      For i=0 To u
          If MenuLoadImag_Str(i)=confu Then
              ai=i
              Exit For
          End If
      Next
  End If
  If ai=-1 Then
      ai=u+1
      ReDim Preserve MenuLoadImag_Str(ai),MenuLoadImag_B(ai)
      MenuLoadImag_Str(ai)=confu
      t= TbmpStr
      Dim aa As HANDLE = LoadImage(App.hInstance,t, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR)
      w=AfxGetBitmapWidth(aa)
      h=AfxGetBitmapHeight(aa)
      Dim bb As CMemBmp =CMemBmp(w,h)
      DrawState bb.GetMemDC,0,0,Cast(Integer,aa),0,0,0,w,h,DST_BITMAP
      DeleteObject aa
      MenuLoadImag_B(ai)=CreatNewBitmap(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK),bb.GetMemDC ,x,y,GetSysColor(COLOR_MENU))

  End If
  SetMenuItemBitmaps( yMenu, cID, uFlags,MenuLoadImag_B(ai), MenuLoadImag_B(ai))
  
End Sub