十万站长的理想国度,来寻找站长自己的梦想岛吧!

好站长论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
贴内随机文字广告征订中(500租金/月)E6600双核机器+2G内存+500G硬盘+10M独享带宽=399元/月1600M空间+100MMYSQL数据库+100M企业邮局=106元赶紧甩掉常去迪吧的女友
诚信合租网-服务器合租先锋梦想天堂招友情链接久久商务淘宝店打折没商量合租站长评合租
非法信息站长自查系统心里健康积分换空间久久商务联手拍拍网打折销售
查看: 6451|回复: 50

[推荐][分享]VB窗体技术资料集锦[请求加精]

[复制链接]
发表于 2008-8-13 13:49:16 | 显示全部楼层 |阅读模式
[推荐][分享]VB窗体技术资料集锦[请求加精]
. B4 Z5 I. ^) n. {, R" ?% G6 ~' a1 Q  z% N成组更新控件属性   
: l* Z5 X7 B  D6 g            
1 \6 I. O0 |: L/ o下面是成组更新 Enabled 属性的例子:
, _! g$ Q; N& D  C9 ASub EnableAll(Enabled As Boolean, ParamArray objs() As Variant)5 k5 k( q9 r" G& D% }; Q8 a9 [2 V) ?/ i
Dim obj As Variant
/ v2 ]/ B; u8 T4 g5 p0 O8 |For Each obj In objs' e7 S# p! M1 o% ?
obj.Enabled = Enabled: ?: S' a! Y% L2 v4 u1 a, B
Next obj
( X8 _" ^+ q, j2 G7 @; REnd Sub
8 B$ M7 \$ s  N5 n4 [$ N应用:0 l8 b. ]& y6 Y
EnableAll True, Text1, Text2, Command1, Command2 “绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
7 h: t" c( s) f# n2 M' B
发表于 2008-8-13 13:49:17 | 显示全部楼层
处理过程时的鼠标显示
# |9 I2 \3 u- L为让你的程序更加专业一点,我们往往需要在程序处理过程时的鼠标形状显示为“沙漏”状态。我们一般的方法是在子程序的开始及结尾编程来改变鼠标形状,这样十分烦琐且容易忘记。我们还可以以下面的方法来实现这一目标:
; y/ Y" `4 c& ?+ K# l. R1、创建一个新类,命名为:CHourGlass; : h% S8 @% e- ?, x0 Y2 [8 t' ?
2、在此类中加入以下代码: % P# _; y3 ?0 R$ v) I2 a# N7 \  u& m
Private Sub Class_Initialize() 2 v8 F: F: G; v
Screen.MousePointer = vbHourglass
' F% b3 n! x( r; E3 sEnd Sub
; I5 @$ a, C& D! ]! U- nPrivate Sub Class_Terminate() ' w' _4 G% b; o# a" o
Screen.MousePointer = vbDefault 9 J1 \7 d3 X' j" `3 t% W' Q) C
End Sub
% V' l; |# ^  w3 \7 \3、在子程序的开始加入下面代码: * b+ h3 r7 }8 k- ]' s; B4 j
Dim MyHourGlass As CHourGlass 7 g% }9 L1 J) `  R8 c
Set MyHourGlass = New CHourGlass  “绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... 0 T, ?& i; I" w) X) M
发表于 2008-8-13 13:49:19 | 显示全部楼层
窗口事件的发生顺序) |9 P1 A  J  y* k% Q9 q

, _+ ]4 N2 C" |: F; ]% i, P+ y1 Form_Initialize
7 ~" L/ @/ C* B" ^$ {2 Form_Load
1 ^0 _) d% l; a4 F' e) ^! {3 Form_Resize* L4 |$ O! R- p
4 Form_Activate
% [+ r  R' X8 D. f+ X' C5 Form_GotFocus
/ X5 C  Y& {( l6 ~) q4 r6 Form_Paint
. P& i2 ]- {2 z) l# B$ Y( z7 Form_Unload3 `0 i" f3 C: b# A/ T' D: i
8 Form_Terminate
' @  M( R- K8 o2 m9 c0 e& a, L
, X7 Y4 @! {/ w3 G3 t9 L/ Y) T, n2 }“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
" l+ h! m" j3 Q+ q& R
发表于 2008-8-13 13:49:21 | 显示全部楼层
窗体加入抖动背景0 S/ Y2 E. y1 n6 t+ B
Ever wonder how the SETUP.EXE screen gets its cool shaded background coloring? This color shading is called dithering, and you can easily incorporate it into your forms. Add the following routine to a form:" z7 _- W! s+ L# A- c( O9 ~
; T% Y" Q4 E' g
   Sub Dither(vForm As Form): S$ l  i4 K& ^; Y! J
   Dim intLoop As Integer" s9 _: ~1 }1 s! C9 q
      vForm.DrawStyle = vbInsideSolid
0 s" j& B: C" C% Y% s0 ?      vForm.DrawMode = vbCopyPen
: l/ S# J: ~' o8 G. D7 ]      vForm.ScaleMode = vbPixels
  e; E. Z/ c+ g2 g3 Z( g      vForm.DrawWidth = 2
& B; T3 q# K' u( r; t: s      vForm.ScaleHeight = 256
1 t$ Z$ l2 w: }( D1 T* R7 A7 p* ?      For intLoop = 0 To 255
/ s$ b8 }+ q$ Y/ r         vForm.Line (0, intLoop)-(Screen.Width, intLoop - 1), RGB(0, 0, 255 -intLoop), B
( J  S9 ?7 ?* E9 x      Next intLoop
$ Q+ H. f6 U( O& T7 }' \3 m3 J   End Sub ! n) l7 S& N) J" H: m! c3 {
9 P8 o( S+ U7 G, v. J# I
Now, add to the Form_Activate event the line 3 J" X' A; Q4 S+ f
! `3 o2 }( g8 a, \6 d; O2 O$ w
   Dither ME 5 L2 F, r) T" e) v! `: |
, ^. m% h. U, b5 Q
This version creates a fading blue background by adjusting the blue value in the RGB function. (RGB stands for Red-Green-Blue.) You can create a fading red background by changing the RGB call to
' |/ G; L. q2 \1 _9 ^9 n) e
3 L/ k2 e7 S# E- H, b4 g   RGB(255 - intLoop, 0, 0).2 B4 R1 l+ J6 D6 s5 U
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
# ~7 a. p0 s  K, g% M" O% W" s- O" Z
发表于 2008-8-13 13:49:23 | 显示全部楼层
创建不规则窗口
% i; F% k+ U2 O. A+ b. o* _  Win32 API 有很多让你意想不到的功能。要创建特殊的不规则窗口看上去似乎很难。但我们如果我们说我们用几行代码就可以实现,这似乎不可思议。但事实就是如此!  " s6 J6 P% l) O; k
  请试试:
$ P; m3 B) P% y9 T" X' e. \2 GPrivate Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long. z) h: T0 a4 V
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long2 [# T# y1 I8 f/ S# o6 g2 U1 b( q/ t2 }2 ^
Private Sub Form_Load()* D/ L* B: f. g) r. x
Show 'The form!
1 w" `5 o6 |$ S; wSetWindowRgn hWnd, CreateEllipticRgn(0, 0, 300, 200), True; }5 W+ x3 Q. i8 M) m5 C% j7 J
End Sub
5 ]1 n) l' H9 K- Z% e8 T3 l6 M4 y& D$ w! J2 m( E0 E; F! q
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... + o2 i8 r* W. U) x$ v) D
发表于 2008-8-13 13:49:25 | 显示全部楼层
创建透明窗体 ! F9 A8 M4 Z7 u, Z
     透明窗体,顾名思义,就是窗体是透明的,透过窗体可以看到窗体下面7 F* g- q0 q# ~# L' z7 g
的东西。实现透明窗体的原理也很简单:首先得到主窗口的矩形区域,  d9 |# t/ U: _
再得到客户区的矩形区域,然后用CombineRgn函数,使用异或操作,将
1 C+ W+ A5 x$ g- \# C重叠部分去除,再使用SetWindowRgn函数设置窗体区域,就行了。- |' y, }" e- d
下面的例子实现了该功能。6 f% g( g$ X2 A& A3 }- z3 }* R' o
>>步骤1----建立新工程。
# ^8 W% m' o& m0 T>>步骤2----编写如下代码:
, _; v& |# o  j! ]4 ?, D' u: X1 _; ], D' W0 f6 q5 B
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd _; l# {7 u' [- W: K+ O5 M* j
    As Long, lpRECT As RECT) As Long$ h$ b. g: \+ ]) r2 G
Private Declare Function GetClientRect Lib "user32" (ByVal hWnd _2 q7 v3 e* S: g5 M3 P  D( C
    As Long, lpRECT As RECT) As Long, ]6 H! J! D( h/ {% ?' [) q
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn _
* f& m4 f* ~1 F- ^. N    As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, _; A; C; h2 B1 t% P1 o7 I0 D
    ByVal nCombineMode As Long) As Long
+ U# ?( j, q( U  J) {& F4 RPrivate Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As _
9 U$ e  N& L0 t3 J3 h- b    Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) _2 I$ c* J3 E+ d, U( J3 Y3 ]
    As Long7 L" f7 M: l; V( I) d
Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd _3 ~: c' ?9 R7 O/ ^7 [
    As Long, lpPoint As POINTAPI) As Long
' H- N/ U. V, y3 V5 B9 g( B- s6 U1 o, NPrivate Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As _
- S1 U) }9 F1 {. Q    Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
; S# b, m5 b1 j' p' o
3 @) s6 }0 a) d7 k* v  LConst RGN_XOR = 3
1 f- _2 t: B/ D3 w& N8 g' L' ~% Z  q: I  h5 t
Private Type POINTAPI
- Q/ {$ R1 m* |% Y  t- _; C    x As Long, ^" c* J, F" ^3 [& K
    Y As Long3 N+ }) F+ y- C4 E% O7 {
End Type2 C4 f' n* f3 E, o/ F! g
2 j0 D' x) T% N% u7 ?
Private Type RECT( b9 U, u2 C4 |; o
    Left As Long  A8 n* d) F, @, H" N7 {/ R
    Top As Long
: I$ ?2 ^6 P) v) v9 w    Right As Long
: p4 g4 m* X4 @1 s    Bottom As Long" v$ V; P1 [! u5 Z* l
End Type' G! l% O5 l$ G" L
1 `; O0 m+ S. E: P8 ?+ V
Private rctClient As RECT, rctFrame As RECT) A( H$ Y5 e7 t3 c, J& }( `9 n1 ~
Private hClient As Long, hFrame As Long
+ w" D7 U" b1 m; r$ G3 u) j! d' x. W# h* o5 R
Public Sub MakeTransparent(frm As Form)
$ K; L2 M6 a' T, z/ s  w    GetFrameClientRgn frm
' ]. n4 n$ j  N$ _    SetWindowRgn frm.hWnd, hFrame, True6 ?& _: V- N  u- t' `
End Sub3 o  u. M1 d' }, V5 V
! I. z2 K3 T  h0 [
Private Sub GetFrameClientRgn(frm As Form)3 U2 L. }& C7 j2 }
    GetWindowRect frm.hWnd, rctFrame
+ M) }) X3 n- O! _" V    GetClientRect frm.hWnd, rctClient
+ |6 A! L# m+ ~# O( E
% Y/ Z5 G! z" J# h7 F. r    '将窗口矩形坐标转换为屏幕坐标+ v* D& ~7 o' }. V* u( r/ B
    Dim lpTL As POINTAPI, lpBR As POINTAPI: [$ d* N. m( s, L0 N& a; J
    lpTL.x = rctFrame.Left8 d( t) L& \7 H
    lpTL.Y = rctFrame.Top  P2 F+ ^4 \: i; g
    lpBR.x = rctFrame.Right
" [: c' ]/ N0 E( P+ C! C    lpBR.Y = rctFrame.Bottom
4 x0 O% v% F5 e7 O/ d+ n    ScreenToClient frm.hWnd, lpTL
3 c9 @2 R" g( ~' _    ScreenToClient frm.hWnd, lpBR
4 l+ s# k5 k! c    rctFrame.Left = lpTL.x. M, ~) ^& ]) v3 X6 G
    rctFrame.Top = lpTL.Y5 u. w# `/ x$ g' L$ b% y
    rctFrame.Right = lpBR.x5 M# W, }# D+ F. g# o- r
    rctFrame.Bottom = lpBR.Y
: H: _( B/ x' X- a9 Y    rctClient.Left = Abs(rctFrame.Left)
9 e% }9 b) y2 A) A    rctClient.Top = Abs(rctFrame.Top)+ a; W" X! @3 S+ W: X* F2 T. r
    rctClient.Right = rctClient.Right + Abs(rctFrame.Left)1 g# m, B9 S7 a7 Y) `8 x
    rctClient.Bottom = rctClient.Bottom + Abs(rctFrame.Top)# {" M& B% n) L& }: i' X
    rctFrame.Right = rctFrame.Right + Abs(rctFrame.Left)9 ~! V$ ~7 Z+ P) e
    rctFrame.Bottom = rctFrame.Bottom + Abs(rctFrame.Top)2 g4 f) B, l8 \. ~' r6 J: a- `; R" E- {
    rctFrame.Top = 03 l  H  d- X; d
    rctFrame.Left = 0, J9 f7 \" |$ @

! ?# E/ c: U( O9 I& b0 g$ }    hClient = CreateRectRgn(rctClient.Left, rctClient.Top, _" m, M" J- S) Q, W( W4 ~
    rctClient.Right, rctClient.Bottom)3 {8 o) e3 k/ Q+ I6 R
    hFrame = CreateRectRgn(rctFrame.Left, rctFrame.Top, _" R, K  m, X3 L5 D% Q) H
    rctFrame.Right, rctFrame.Bottom)
1 r; u" P  P$ x9 c0 f4 j# W  A+ c3 Y9 p
    CombineRgn hFrame, hClient, hFrame, RGN_XOR8 [2 P% e( P- S. C; V
End Sub
0 P. D) C9 R5 s; f, f
3 ^! t" f2 U+ ?+ r: u1 t  z3 jPrivate Sub Form_Resize()
) ]% t5 u& }9 y4 I$ J# y    MakeTransparent Me- b/ U2 z2 p0 |9 O( C$ G2 ^& c, f
End Sub( O4 h; G9 M5 t- |" ~7 x
3 I+ A7 |- n1 ]4 C5 d* ?4 K$ F
>>步骤3----编译运行,是不是看到效果了。“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
' b& J; i& b" K# T. G) g  B7 V/ u
发表于 2008-8-13 13:49:27 | 显示全部楼层
创建位图菜单
: g: ]. q; T$ c+ O( }" P+ C' f& R' i  o, K. T
在通常的程序中菜单总是以文本的方式存在,有时候显得非常单调乏味。如果能够9 S* @/ z; ]4 Q  c' w4 k" N( j3 ]
在菜单中加入位图图形,将会极大地增加用户的使用兴趣。本文介绍了如何使用位! o5 G. J0 G  j9 {; A
图制作菜单选项。 6 u0 z! E1 p4 x4 L# N, ]

3 K; ]8 n! o4 i9 B创建位图菜单; ]/ k* S5 x+ n* B" K
----创建位图菜单其实非常简单,它需要用到Windows应用程序编程接口(API)的
7 |( \! e4 k4 E7 H0 {2 S一些菜单函数和位图函数,你需要将这些函数的声明包含在你的应用程序的标准模$ Z: o5 C  T4 Y: \
块中,具体的内容请参见样例程序。步骤如下: ( K  y7 a' t* H1 ^+ g

1 M* b1 Z$ g8 b* y# x使用函数GetSubMenu来提取子菜单项的句柄,并通过使用函数CreateCompatibleDC; }- i7 |5 {# ?6 k8 ^; v& P% u# A
来创建一个兼容的设备环境描述表; 1 `8 r1 C6 W8 Y
在一个循环过程中通过使用CreateCompatibleBitmap函数,SelectObject函数以及, {6 d3 @: r! j( R% L) Y" f1 _
BitBlt函数来分别将针对各个菜单项所载入的位图选入到兼容设备环境中; ' P! m* N" f' O8 k9 Z) e! A" B
通过ModifyMenu函数绘制真正的位图菜单选项; " S" {7 g* Q# e! d/ ?' ~
使用DeleteDC函数来释放设备环境,以便其他的程序可以使用它们。 + s5 `+ _! \% [* T9 a
----提取位图可以有多种方法,在本样例程序中在窗体上设置了四个图形框控件,
# J6 H; `$ O# a8 V* L1 L% Q, E7 a使用它们载入4个预设的图标来作为菜单选项位图的源文件,当然你也可以使用其) n3 e% A: P; }4 I
他的方法,例如使用LoadPicture函数来从磁盘装载位图。
! M4 @: H8 L! N! {4 m) z; j6 }' B
8 `' T7 m# \& r1 w; I6 R样例程序
: s# _# s% Q1 c1 f  k# Z: w! p* h  {" k5 \1 V, T! N. D
在Visual Basic中开始一个新的工程,采用缺省的方法建立Form1。 ( W$ i" t! \5 X& L# T3 h
创建一个新的模块,采用缺省的方法建立Module1.Bas。
- K4 g( |2 \* _" ~将如下的声明语句和常量添加到Module1.Bas模块中:
1 e  k$ T/ Q/ F, l" XOption Explicit
' `0 j6 _; t( t- P3 nDeclare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
6 G7 U' L- `# Y3 jDeclare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ( _3 p( X2 D( d, |4 r# D5 v6 `
ByVal nPos As Long) As Long
0 A! H- h* X/ O# k" d! ~Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long,6 e1 t% R' D9 T* X$ i
ByVal nPos As Long) As Long: }/ [5 e7 ~& C6 C. w6 U2 i' I6 E
Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" * G# K( T( K2 F1 q2 r6 O0 l' e& l
(ByVal hMenu As Long,ByVal nPosition As Long, ByVal wFlags As Long,& V6 {8 ?0 W$ A. Y, S  F& n; i7 v
ByVal wIDNewItem As Long, ByVal lpString As Any) As Long* I) L6 \% ~8 M# V0 \
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As ) p+ G( [; R7 O1 k% W! n1 k
Long# Z0 [/ M. |% Y  l
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long9 v% ]5 S" z# S5 N3 f- k- |% h
Declare Function CreateCompatibleBitmap Lib "gdi32"
3 u8 ~4 n! L& \( S4 P(ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long$ t% S: ]5 Q& x) I8 A0 C
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, 8 t+ W5 ?) e2 C& L; G. e
ByVal hObject As Long) As Long4 w! x  I' A; ]4 h# ~$ G6 w9 U/ U
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As ' K( b& r+ U; O5 Y- F
Long,
0 Y/ c1 ^( \9 }% w! v% V. Y% AByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
! i8 Y* y$ l! s' mhSrcDC
2 m2 ~5 }) I' \" Z7 d; CAs Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As 8 {; Q9 q7 d  i0 ~7 @" S6 s
Long  u" q) B2 ?; w5 d3 m( I7 ~
Public Const SRCCOPY = &HCC0020
% q/ L& g# G: L; J* A5 C* ]" T7 BPublic Const MF_BYPOSITION = &H400&! D) ?5 }1 {9 }1 e* E9 k
Public Const MF_BITMAP = &H4&
! e$ L; X, ~2 P0 b. b' i5 G
6 ]6 P2 i, s  ?3 S# U  ^注意上面的声明语句需要书写在一行内。 # F0 E0 \  ^/ M: C  v
在Form1上添加4个图形框控件,将它们的Name属性设置为Picture1,将它们的1 R$ P+ ?1 o( Z8 P1 \4 U! E
Index属性依次设置为0,1,2,3,将它们的AutoRedrew属性设置为True,将它们
' @: c6 J- E7 H: {: C的AutoResize属性设置为Ture,以及将它们的Visable属性设置为False。
  T* h# @) m* d; b. \4 ~将上面的4个图形框控件的Picture属性依次设置为Face1.ico,Face2.ico,Face3.1 f1 P/ Y) ~6 ]6 v2 o, t$ k* P$ x
ico,Face4.ico。
! {6 X( s5 @7 r' s( t$ n在Form1上添加第一个菜单项,将它的标题设置为“[&F]文件”,名称设置为' e% w7 J' q+ Q8 ^, F: r( k8 n0 h: [: I
mnuFile。在其下添加一个子菜单项,将它的标题设置为“[&E]退出”,名称设置  n- c) w' ~5 B! p
为mnuExit。 ; f* W0 C$ R* @0 L& I. I
在Form1上添加第二个菜单项,将它的标题设置为“[&A]脸谱”,名称设置为
! o; n# w( f! ~6 q, wmnuFace。在其下添加4个子菜单项,分别将改4个子菜单项的名称设置为“[N]正常”
2 t  j( q9 h5 w0 V,“[&S]微笑”,“ [&L]大笑”,以及“[&O]悲伤”。将它们的名称设置为“
- a4 d2 _: G5 `# F( |mnuFaceSel”,并相应将这4个子菜单项的索引设置为0,1,2,3。
( s. k. z- K$ J# e, I2 @将如下的代码添加到Form1的Form_Load事件中: ' L( {$ S- D! W) A
Private Sub Form_Load()) u3 x( {0 m( o2 s' s
Dim nLoopCtr As Integer- y4 U. V! D& V  Y, \
Dim lResult As Long3 T; B7 q7 Q4 _4 l" Y
Dim hTempDC As Long
; j# I0 p% p4 f& G9 L: B% fDim nWidth As Integer
& ^" I, S- G, T# `: T; qDim nHeight As Integer, C# `+ S* P/ H+ W
Dim lTempID As Long
% @& ~2 I; q2 a6 xDim hMenuID As Long
6 x3 u# t& E$ {8 W3 Z2 nDim lItemCount As Long" S4 d0 f* ?0 f0 E: E+ C
Dim hBitmap As Long; i* j$ G/ @! c1 E2 P" b5 u
nWidth = Picture1(nLoopCtr).Width \ Screen.TwipsPerPixelX  _# B! P$ `. K. h2 C
nHeight = Picture1(nLoopCtr).Height \ Screen.TwipsPerPixelY
6 Z3 q6 ^8 j4 L, qhMenuID = GetSubMenu(GetMenu((Me.hwnd)), 1)
# ^8 g, l; h4 ^+ y* EhTempDC = CreateCompatibleDC(Picture1(nLoopCtr).hdc)$ Q' N" K" y: E6 \# X  L
For nLoopCtr = 0 To 3
" O( z+ N" G; O4 d9 r; u- U4 MhBitmap = CreateCompatibleBitmap(Picture1(nLoopCtr).hdc, nWidth,
0 V/ k# x0 u$ ~' q! D8 ?* |nHeight)6 x" q/ ^8 Y4 a: @7 ]$ L/ U+ C
lTempID = SelectObject(hTempDC, hBitmap). T7 L/ O1 Y8 s# y5 U9 a
lResult = BitBlt(hTempDC, 0, 0, nWidth, nHeight, (Picture1(0 Y' W% T/ E3 K2 W0 G2 k
nLoopCtr).hdc), 0, 0, SRCCOPY)  j9 ?/ j" ]) l. p5 U9 G
lTempID = SelectObject(hTempDC, lTempID)/ G* J; L& D* R7 r# W. d2 K
nuFaceSel(nLoopCtr).Caption = ""2 V) u1 n' h2 P: P
lResult = ModifyMenu(hMenuID, nLoopCtr, MF_BYPOSITION Or 2 h" N! |2 V) T5 F; |+ \
MF_BITMAP," z# O; l8 S- r! Q; [" t
GetMenuItemID(hMenuID, nLoopCtr), hBitmap). n( x/ R' G* c) I
Next nLoopCtr  B1 P3 D7 X; i" G9 s6 ^4 M7 M
lResult = DeleteDC(hTempDC)
3 Q9 [6 _  z1 [2 ?! DEnd Sub
4 ~7 w8 _' D6 z1 A5 h. q% C* V将如下的代码添加到“退出”子菜单的单击事件中: 8 p0 C+ r9 z$ ^* P7 C1 Z
Private Sub mnuExit_Click(Index As Integer)
% Y% i  h4 ]' z. _Select Case Index8 J) w! y* n3 }2 Y8 z
Case 0
8 x/ m- l& _; B$ i* ?! BUnload Me
) {. o( k3 c9 a( nEnd Select
& n+ Z! {" a3 m7 cEnd Sub$ ?5 L6 G# o, Q9 [) T
运行该样例程序,单击“脸谱”菜单,则会看到由4个脸谱图标所形成的位图子菜
- l3 H7 l# o3 _8 }+ V; G/ p3 F单项,如图1所示。单击“文件”\“退出”菜单可退出应用程序。 5 \- |$ Q% T) N, N$ b- V! G
& S& l( I2 \' |8 ^/ }
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... # D/ ?: d0 R) S1 n" G
发表于 2008-8-13 13:49:28 | 显示全部楼层
创建无 Icon 的窗口
6 B7 g, Y9 Y- O, J; o  }我们在很多时候都需要那种无 Icon 的 窗口,如“关于……”“查找”等。在 VB 中,我们可以按以下步骤来创建此类窗口:
* X2 m. y' R$ ], l1 v" L1、设置窗口的 BorderStyle = 3; - q4 ^$ U% h1 c! `
2、在 Form_Load 中加入:Me.Icon = LoadPicture("")  “绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... 9 N  r; i) [: O7 f8 j" f3 b5 k
 楼主| 发表于 2008-8-13 13:49:29 | 显示全部楼层
创建一个递增数字框
4 J6 z* h# J0 @9 e9 |# HYou can注释:t increment a vertical scroll bar注释:s value -- a fact that can become annoying. For example, start a new project and place a text box and a vertical scroll bar on the form. Place the vertical scroll bar to the right of the text box and assign their Height and Top properties the same values. Assign the vertical scroll bar a Min property value of 1 and a Max value of 10. Place the following code in the vertical scroll bar注释:s Change event:
( s# }6 F/ Z# X1 ]+ m5 x* G. x5 i  U

+ |; d, g6 `! f* C# W- p5 V- TText1.Text = VScroll1.Value
3 A- z' G' U; ^0 x- iNow press [F5] to run the project. Notice that if you click on the bottom arrow of the vertical scroll bar, the value increases; if you click on the top arrow, the value decreases. From my perspective, it should be the other way around.
9 U1 B7 f  S3 l/ l
8 m  I. F2 T; K3 t5 jTo correct this, change the values of the Max and Min properties to negative values. For example, end the program and return to the design environment. Change the vertical scroll bar注释:s Max value to -1 and its Min value to -10. In its Change event, replace the line you entered earlier with the following:
- K" @( J$ @+ M6 B' C5 Y4 F7 `' D2 \3 i7 E) N2 b2 F8 z$ W
6 n% L& B' l# ^4 W; R( A8 Z/ |6 n
Text1.Text = Abs(Vscroll1.Value); d/ v* d* O1 Z) S3 u+ f
Now press [F5] to run the project. When you click on the top arrow of the vertical scroll bar, the value now increases. Adjust the Height properties of the text box and the scroll bar so you can注释:t see the position indicator, and your number box is ready to go.   
& h, t. X# _5 W) f5 M6 ^9 i- J+ A' {  r! ?# U3 }, [2 I
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
0 v5 J9 U2 o% k- f: @4 j
发表于 2008-8-13 13:49:33 | 显示全部楼层
打开 Win95 的创建快捷方式窗口$ j* h5 j% `0 q
以下的代码演示了如何利用 Win95 的 Wizard 在指定的目录中建立快捷方式。) X% L. f8 K  Y3 ]' h% t

* Q/ ^0 o3 B" N( I, S; cDim X As Integer
5 N* l+ j+ ]- Q" h& S* K- W. z- }X = Shell("C:\WINDOWS\rundll32.exe AppWiz.Cpl,NewLinkHere " & App.Path & "\", 1)- W$ a. @/ ^  d" `9 C% _' r/ e0 L: j
& `9 M4 b( I# }
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
" C* d) O: R* l7 i
您需要登录后才可以回帖 登录 | 注册

本版积分规则

阮姓人报名

小黑屋|手机版|Archiver|中国好站之家 ( 皖ICP备07008304号 )

GMT+8, 2018-7-22 05:21 , Processed in 0.501205 second(s), 19 queries .

Powered by DX! X3.4

© 2001-2088 服务器赞助商:久久商务网

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