哈,想起一个问题,如何吧一个控件,作为一个引用来使用?

tanyx 2003-06-02 01:59:05
我自己作的控件,但在IIS工程里不允许使用控件,智能增加引用,有办法解决吗?
...全文
36 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
900126 2003-09-28
  • 打赏
  • 举报
回复
做成DLL,在DLL中增加窗体,在窗体中布置控件,然后不让窗体显示。
flyingscv 2003-07-21
  • 打赏
  • 举报
回复
你的控件放服务端?
那样就和dll一样,没什么意义
道素 2003-07-21
  • 打赏
  • 举报
回复
这是我理解错误,我的意思你可以不在加入组件但是在程序运行是动态生成
CreateWindowEx可以办到
windows标准的控件都可以动态生成

比如(实际应用修改CName为相应的名称,如STATIC,EDIT,SysTabControl32....)
创建label控件
Private Sub CreateLabel()
h = CreateWindowEx(WS_EX_WINDOWEDGE, CName, WText, WS_CHILD Or WS_VISIBLE Or SS_CENTER Or WS_THICKFRAME, 170, 20, 160, 120, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
End Sub
创建TextBox
Private Sub CreateTextBox()
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, WText, WS_CHILD Or WS_BORDER Or WS_VISIBLE Or ES_MULTILINE Or WS_VSCROLL, 170, 20, 160, 120, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
End Sub
创建命令按钮
Private Sub CreateCommandButton()
h = CreateWindowEx(WS_EX_WINDOWEDGE, CName, WText, BS_MULTILINE Or BS_LEFT Or BS_BOTTOM Or WS_CHILD Or WS_VISIBLE, 170, 20, 160, 120, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
End Sub
创建tab
Private Sub CreateTabControl()
h = CreateWindowEx(WS_EX_CONTROLPARENT, CName, "", TCS_FOCUSONBUTTONDOWN Or WS_CHILD Or WS_VISIBLE, 170, 20, 200, 120, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
w = Array("Infantry", "Mechanized", "Nukes && biobombs", "Sticks and stones")
For f = 1 To 4
With tie
.mask = TCIF_TEXT 'Or TCIF_IMAGE
.pszText = "WW " & f & "-" & w(f - 1)
.cchTextMax = 6
.iImage = -1 'no ImageList set for this td control
End With
SendMessage h, TCM_INSERTITEMA, f, tie 'add this button
Next f
End Sub
创建日期控件
Private Sub CreateMonthCal()
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, "", WS_BORDER Or WS_CHILD Or WS_VISIBLE Or MCS_DAYSTATE, 170, 20, 200, 160, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
End Sub
创建进度条
Private Sub CreateProgressBar()
'here I surely can define the range using SendMessage h, PBM_SETRANGE, 0, MakeDWord (min,max), but
'for some reason, though, I cannot make it to work properly. Please tell me how it can be done, if you manage to do it
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, "", PBS_SMOOTH Or WS_CHILD Or WS_VISIBLE, 170, 20, 200, 20, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
SendMessage h, PBM_SETSTEP, 1, 0&
f = 0
Do Until f = 60
DoEvents
SendMessage h, PBM_SETPOS, ByVal f, ByVal 0&
SendMessage h, WM_SETTEXT, 0, ByVal CStr(f)
f = f + 1
Sleep 10
Loop
End Sub
创建状态栏
Private Sub CreateStatusBar()
Dim SBPartsWidths(3) As Long
SBPartsWidths(0) = 100 'width=100: 100 pixels to the right of the sb left margin
SBPartsWidths(1) = 200 'width=100: the right of this panel is 100 pixels to the right of the right of the previous panel :P
SBPartsWidths(2) = 380 'width=180: the right of this panel is 180 pixels to the right of the right of the previous panel :P
'^for this last panel, one may set its width to the right margin of the parent window by putting -1 instead of a positive value
DestroyWindow h
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, "", SBT_TOOLTIPS Or WS_CHILD Or WS_VISIBLE, 170, 20, 200, 20, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
SendMessage h, SB_SETPARTS, ByVal 3, SBPartsWidths(0)
For f = 0 To 2
SendMessage h, SB_SETTEXTA, ByVal f Or SBT_POPOUT, ByVal CStr("Put mouse pointer over this panel") 'SBT_POPOUT is OR-ed with f to raise the text
If f < 2 Then SendMessage h, SB_SETTIPTEXTA, ByVal f, ByVal CStr("Panel " & f + 1 & " is too short to display all text; otherwise, this tooltip wouldn't appear")
'^panel 3 won't display tooltips in Tahoma(size=8), because all its text fits inside it
Next f
Erase SBPartsWidths
End Sub
创建comboBox
Private Sub CreateComboBox()
h = CreateWindowEx(WS_EX_WINDOWEDGE, CName, "", CBS_DROPDOWNLIST Or WS_VSCROLL Or WS_CHILD Or WS_VISIBLE, 170, 20, 160, 140, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
AddItemsToList h, CB_ADDSTRING
End Sub
创建listBox
Private Sub CreateListBox()
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, "", WS_BORDER Or WS_VSCROLL Or WS_CHILD Or WS_VISIBLE, 170, 20, 160, 120, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
AddItemsToList h, LB_ADDSTRING
End Sub
创建水平滚动条
Private Sub CreateHSBar()
h = CreateWindowEx(WS_EX_WINDOWEDGE, CName, "", SBS_HORZ Or WS_CHILD Or WS_VISIBLE, 170, 20, 200, 20, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
With si
.cbSize = Len(si)
.nMax = 10
.nMin = 0
.nPos = 3
End With
SetScrollInfo h, SB_HORZ, si, True
SendMessage h, SBM_SETRANGE, ByVal 0, ByVal 10
SendMessage h, SBM_SETRANGEREDRAW, ByVal 0, ByVal 10
For f = 1 To 10
DoEvents
SendMessage h, SBM_SETPOS, f, True
Sleep 100
Next f
'this scroll bar won't respond to clicks...
End Sub
创建treeview
Private Sub CreateTreeView()
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, "", TVS_HASBUTTONS Or TVS_HASLINES Or TVS_LINESATROOT Or WS_BORDER Or WS_CHILD Or WS_VISIBLE, 170, 20, 200, 200, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
SendMessage h, TVM_SETINDENT, 40, 0 'self-explanatory; negative values considered as 0
Dim ti As TVITEM, tis As tagTVINSERTSTRUCT
Dim hPrevNode As Long 'to know below which node to insert new nodes
For f = 0 To 10
With ti
.mask = TVIF_TEXT Or TVIF_PARAM
.pszText = IIf((f < 1), "Parent node", "Child #" & f)
.cchTextMax = IIf((f < 1), Len("Parent node"), Len("Child #" & f))
.lParam = f + 1
End With
With tis
.item = ti
.hInsertAfter = TVI_FIRST
'if f<5, then each new node will be a child of the previous one;
'if greater, then put it below the TVI_ROOT level:
.hParent = IIf((f < 6), hPrevNode, TVI_ROOT)
End With
hPrevNode = SendMessage(h, TVM_INSERTITEMA, 0, tis) 'set the new item insertion position
SendMessage h, TVM_SETITEMHEIGHT, ByVal 16, 0 'set the height of ALL nodes; 16 or something else, play with it...
Next f
End Sub
创建ip文本框
Private Sub CreateIPAd()
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, "", WS_BORDER Or WS_CHILD Or WS_VISIBLE, 170, 20, 160, 22, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
End Sub
创建UpDown
Private Sub CreateUpDown()
h = CreateWindowEx(WS_EX_CLIENTEDGE, CName, "", WS_CHILD Or WS_VISIBLE, 170, 20, 30, 100, Form1.hwnd, vbNull, App.hInstance, ByVal 0&)
'^the width of 30 is arbitrary - you may as well set it to 0
End Sub
道素 2003-06-20
  • 打赏
  • 举报
回复
不给分无所谓我并不缺分
道素 2003-06-20
  • 打赏
  • 举报
回复
我在C++ builder中用过,使用com技术可以实现。vb没做过,但是我见过
Alicky 2003-06-20
  • 打赏
  • 举报
回复
将ocx封装在DLL里。
tanyx 2003-06-20
  • 打赏
  • 举报
回复
说不可以的应该得分,说可以的需要例子。
rappercn 2003-06-05
  • 打赏
  • 举报
回复
引用的只能是类库吧?不是类库也可以引用吗?谁能引用一个button给我看看?
道素 2003-06-05
  • 打赏
  • 举报
回复
既然是你自己做的,你在做一个dll版本的好了,但是我认为你的要求应该还是可以实现的,因为C++builder中可以
道素 2003-06-05
  • 打赏
  • 举报
回复
首先控件必须放在容器中
tanyx 2003-06-05
  • 打赏
  • 举报
回复
哈,没人回答吗?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧