ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

EH搜索     
EH云课堂-专业的职场技能充电站 Excel转在线管理系统,怎么做看这里 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
Excel不给力? 何不试试FoxTable! Excel 2016函数公式学习大典 高效办公必会的Office实战技巧 免费下载Excel行业应用视频
300集Office 2010微视频教程 Tableau-数据可视化工具 精品推荐-800套精选PPT模板,点击获取 ExcelHome出品 - VBA代码宝免费下载
你的Excel 2010实战技巧学习锦囊 欲罢不能, 过目难忘的 Office 新界面 Excel VBA经典代码实践指南
查看: 670|回复: 0

[求助] 都说frame控件不能设置成透明的,但网上也有高手给发了一段代码,可是不知怎么用

[复制链接]

TA的精华主题

TA的得分主题

发表于 2016-9-15 07:47 | 显示全部楼层 |阅读模式
请网上高手给看看怎么用这段代码让frame控件变透明
  1. Option Explicit
  2. Private Declare Function CreateWindowEx Lib "use*****" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal HwndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
  3. Private Declare Function LoadIcon Lib "use*****" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As String) As Long
  4. Private Declare Function LoadCursor Lib "use*****" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
  5. Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
  6. Private Declare Function RegisterClassEx Lib "use*****" Alias "RegisterClassExA" (pcWndClassEx As WNDCLASSEX) As Integer
  7. Private Declare Function ShowWindow Lib "use*****" (ByVal lHwnd As Long, ByVal nCmdShow As Long) As Long
  8. Private Declare Function UpdateWindow Lib "use*****" (ByVal lHwnd As Long) As Long
  9. Private Declare Function SetFocus Lib "use*****" (ByVal lHwnd As Long) As Long
  10. Private Declare Function PostMessage Lib "use*****" Alias "PostMessageA" (ByVal lHwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  11. Private Declare Function DefWindowProc Lib "use*****" Alias "DefWindowProcA" (ByVal lHwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  12. Private Declare Function GetMessage Lib "use*****" Alias "GetMessageA" (lpMsg As MSG, ByVal lHwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
  13. Private Declare Function TranslateMessage Lib "use*****" (lpMsg As MSG) As Long
  14. Private Declare Function DispatchMessage Lib "use*****" Alias "DispatchMessageA" (lpMsg As MSG) As Long
  15. Private Declare Sub PostQuitMessage Lib "use*****" (ByVal nExitCode As Long)
  16. Private Declare Function BeginPaint Lib "use*****" (ByVal lHwnd As Long, lpPaint As PAINTSTRUCT) As Long
  17. Private Declare Function EndPaint Lib "use*****" (ByVal lHwnd As Long, lpPaint As PAINTSTRUCT) As Long
  18. Private Declare Function GetClientRect Lib "use*****" (ByVal lHwnd As Long, lpRect As RECT) As Long
  19. Private Declare Function DrawText Lib "use*****" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long

  20. Private Type WNDCLASSEX
  21.      cbSize As Long
  22.      style As Long
  23.      lpfnWndProc As Long
  24.      cbClsExtra As Long
  25.      cbWndExtra As Long
  26.      hInstance As Long
  27.      hIcon As Long
  28.      hCursor As Long
  29.      hbrBackground As Long
  30.      lpszMenuName As String
  31.      lpszClassName As String
  32.      hIconSm As Long
  33. End Type

  34. Private Type CREATESTRUCT
  35.      lpCreateParams As Long
  36.      hInstance As Long
  37.      hMenu As Long
  38.      HwndParent As Long
  39.      cy As Long
  40.      cx As Long
  41.      y As Long
  42.      x As Long
  43.      style As Long
  44.      lpszName As String
  45.      lpszClass As String
  46.      ExStyle As Long
  47. End Type

  48. Private Type POINTAPI
  49.      x As Long
  50.      y As Long
  51. End Type

  52. Private Type MSG
  53.      lHwnd As Long
  54.      tMessage As Long
  55.      wParam As Long
  56.      lParam As Long
  57.      time As Long
  58.      pt As POINTAPI
  59. End Type

  60. Private Type RECT
  61.      Left As Long
  62.      Top As Long
  63.      Right As Long
  64.      Bottom As Long
  65. End Type

  66. Private Type PAINTSTRUCT
  67.      hdc As Long
  68.      fErase As Long
  69.      rcPaint As RECT
  70.      fRestore As Long
  71.      fIncUpdate As Long
  72.      rgbReserved(32) As Byte 'this was declared incorrectly in VB API viewer
  73. End Type

  74. Private Const WS_VISIBLE As Long = &H10000000
  75. Private Const WS_VSCROLL As Long = &H200000
  76. Private Const WS_TABSTOP As Long = &H10000
  77. Private Const WS_THICKFRAME As Long = &H40000
  78. Private Const WS_MAXIMIZE As Long = &H1000000
  79. Private Const WS_MAXIMIZEBOX As Long = &H10000
  80. Private Const WS_MINIMIZE As Long = &H20000000
  81. Private Const WS_MINIMIZEBOX As Long = &H20000
  82. Private Const WS_SYSMENU As Long = &H80000
  83. Private Const WS_BORDER As Long = &H800000
  84. Private Const WS_CAPTION As Long = &HC00000                  '  WS_BORDER Or WS_DLGFRAME
  85. Private Const WS_CHILD As Long = &H40000000
  86. Private Const WS_CHILDWINDOW As Long = (WS_CHILD)
  87. Private Const WS_CLIPCHILDREN As Long = &H2000000
  88. Private Const WS_CLIPSIBLINGS As Long = &H4000000
  89. Private Const WS_DISABLED As Long = &H8000000
  90. Private Const WS_DLGFRAME As Long = &H400000
  91. Private Const WS_EX_ACCEPTFILES As Long = &H10&
  92. Private Const WS_EX_DLGMODALFRAME As Long = &H1&
  93. Private Const WS_EX_NOPARENTNOTIFY As Long = &H4&
  94. Private Const WS_EX_TOPMOST As Long = &H8&
  95. Private Const WS_EX_TRANSPARENT As Long = &H20&
  96. Private Const WS_GROUP As Long = &H20000
  97. Private Const WS_HSCROLL As Long = &H100000
  98. Private Const WS_ICONIC As Long = WS_MINIMIZE
  99. Private Const WS_OVERLAPPED As Long = &H0&
  100. Private Const WS_OVERLAPPEDWINDOW As Long = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
  101. Private Const WS_POPUP As Long = &H80000000
  102. Private Const WS_POPUPWINDOW As Long = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
  103. Private Const WS_SIZEBOX As Long = WS_THICKFRAME
  104. Private Const WS_TILED As Long = WS_OVERLAPPED
  105. Private Const WS_TILEDWINDOW As Long = WS_OVERLAPPEDWINDOW
  106. Private Const CW_USEDEFAULT As Long = &H80000000
  107. Private Const CS_HREDRAW As Long = &H2
  108. Private Const CS_VREDRAW As Long = &H1
  109. Private Const IDI_APPLICATION As Long = 32512&
  110. Private Const IDC_ARROW As Long = 32512&
  111. Private Const WHITE_BRUSH As Integer = 0
  112. Private Const BLACK_BRUSH As Integer = 4
  113. Private Const WM_KEYDOWN As Long = &H100
  114. Private Const WM_CLOSE As Long = &H10
  115. Private Const WM_DESTROY As Long = &H2
  116. Private Const WM_PAINT As Long = &HF
  117. Private Const SW_SHOWNORMAL As Long = 1
  118. Private Const DT_CENTER As Long = &H1
  119. Private Const DT_SINGLELINE As Long = &H20
  120. Private Const DT_VCENTER As Long = &H4
  121. Private Const WS_EX_STATICEDGE = &H20000
  122. Private Const SW_NORMAL = 1
  123. Private Const BS_GROUPBOX = &H7&


  124. Public Sub MyFrame(HwndParent As Long)
  125.      Dim tCreate As CREATESTRUCT
  126.      Dim lHwnd As Long
  127. '    lHwnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, _
  128. '                    "STATIC", "Label Created on Window", WS_CHILD, _
  129. '                     200, 0, 300, 50, HwndParent, 0, App.hInstance, tCreate)
  130.      
  131.      lHwnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, _
  132.                      "BUTTON", "dd", WS_CHILD Or BS_GROUPBOX, _
  133.                       200, 0, 300, 50, HwndParent, 0, App.hInstance, tCreate)
  134.      ShowWindow lHwndLabel, SW_NORMAL
  135. End Sub
复制代码


您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

关注官方微信,每天学会一个新技能

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2019-8-25 08:51 , Processed in 0.062375 second(s), 15 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2020 Wooffice Inc.

   

沪公网安备 31011702000001号 沪ICP备11019229号

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:徐怀玉律师 李志群律师

快速回复 返回顶部 返回列表