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

好站长论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

[复制链接]
发表于 2008-8-13 13:49:16 | 显示全部楼层 |阅读模式
[推荐][分享]VB窗体技术资料集锦[请求加精]/ W* x* v* l* h
成组更新控件属性   % ]  P& \  h" w) r
            2 G+ _5 J9 b2 ^# c2 Y5 k2 J+ p
下面是成组更新 Enabled 属性的例子:
& `' y$ U! {" |* f  d6 a9 F4 FSub EnableAll(Enabled As Boolean, ParamArray objs() As Variant)$ T: C  H: b1 B/ Y/ B: {
Dim obj As Variant
9 m  Y7 z4 O$ h5 S8 s+ jFor Each obj In objs5 a1 M0 f4 {" x4 t; T& f& j
obj.Enabled = Enabled
6 W2 B6 d1 p6 l/ ~8 b' MNext obj
7 g' e: q+ n$ ZEnd Sub( \6 F) k- e1 E& B# h5 B
应用:: i* z8 L8 A2 q5 H
EnableAll True, Text1, Text2, Command1, Command2 “绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
6 s+ L' H. O# U% O- R
发表于 2008-8-13 13:49:17 | 显示全部楼层
处理过程时的鼠标显示 9 Q" m" S8 V" B- o' e8 @8 Y) O( c
为让你的程序更加专业一点,我们往往需要在程序处理过程时的鼠标形状显示为“沙漏”状态。我们一般的方法是在子程序的开始及结尾编程来改变鼠标形状,这样十分烦琐且容易忘记。我们还可以以下面的方法来实现这一目标: ) R# X" E! ?4 ]4 o  Z
1、创建一个新类,命名为:CHourGlass; 2 I, m! j6 G8 X
2、在此类中加入以下代码: % Y4 q0 S3 h# w/ W% n
Private Sub Class_Initialize() " [% ^: _5 `/ Z, |
Screen.MousePointer = vbHourglass
( Z( E# h% ]6 ]8 E+ nEnd Sub * K& b: T( h" Q7 W3 X4 c8 b
Private Sub Class_Terminate() 3 q4 F' h! S5 _- e
Screen.MousePointer = vbDefault 0 i3 \: }9 D/ L  P, L" e5 I
End Sub
  F1 `  l3 |$ p$ P3、在子程序的开始加入下面代码: ! L/ v% o. K' d$ ^1 U5 Q9 f
Dim MyHourGlass As CHourGlass ' z2 v7 n# j, f# }- Q9 }
Set MyHourGlass = New CHourGlass  “绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
* E4 n8 m; J& S8 ~7 Z
发表于 2008-8-13 13:49:19 | 显示全部楼层
窗口事件的发生顺序" U$ d3 i8 W7 S- c4 C
; |6 K' S* a) r/ k* D5 k
1 Form_Initialize
% N# `8 M. V1 V3 p8 }2 Form_Load* t8 S( u" E( M9 \7 j% b0 @) E
3 Form_Resize
# L. `6 m7 G. m- s* P* X$ E; R! ~4 Form_Activate
; F& a8 ^, G# U+ P5 Form_GotFocus+ z9 ~( k8 u% D7 E) N* P
6 Form_Paint
! t# O  A; B" ^- }7 \1 V7 Form_Unload+ s; Q4 B) `% l) L2 N( |8 J
8 Form_Terminate7 b8 ^) \! ~4 K% z: j
3 ?* f" i! H6 a" E  i8 |8 i
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...   X& r! r3 D- G, ~9 s, [
发表于 2008-8-13 13:49:21 | 显示全部楼层
窗体加入抖动背景5 a' ^' a$ V; I0 T  e9 k
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:
* I& [# |+ Y; c9 m' a* r# {: o! O" C4 o, `6 `
   Sub Dither(vForm As Form); U5 j+ J0 M! |8 d9 w' N
   Dim intLoop As Integer
, U( {- Y$ G' t      vForm.DrawStyle = vbInsideSolid
( \6 G: K( @. h5 w9 ^7 I% V      vForm.DrawMode = vbCopyPen- }1 p( W% l! [' {$ B1 R
      vForm.ScaleMode = vbPixels& _& c) z5 p0 B3 v6 n
      vForm.DrawWidth = 2. [5 A& ^" X' Q4 o
      vForm.ScaleHeight = 256$ E1 m7 C1 a' I$ a# O
      For intLoop = 0 To 255
, O, m- M/ ^' n, p; S1 J         vForm.Line (0, intLoop)-(Screen.Width, intLoop - 1), RGB(0, 0, 255 -intLoop), B
5 I% q" h" `- o      Next intLoop
8 L1 \: s% F- Q: `- E) {+ w1 D   End Sub
  J5 c: y1 `9 |; j! i0 X$ }) g! x5 M$ N5 t  J- r/ S7 c
Now, add to the Form_Activate event the line
  H3 d' w5 y  I* B0 b/ ^! D- h; W/ ]; A: p  W7 o& w4 k6 ^
   Dither ME ( I' q* U. y1 p6 n+ u; u

' C4 q9 V5 @9 z7 {6 _7 FThis 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
* U9 I; ^% T5 s
* P' Q( J1 j7 }) Z   RGB(255 - intLoop, 0, 0).! f, F9 T* X6 d$ G7 a: k+ C! ^
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... 3 p5 A7 D+ m- k& r- Q) }- s
发表于 2008-8-13 13:49:23 | 显示全部楼层
创建不规则窗口
: j( d$ ?: j, j% Q. c  Win32 API 有很多让你意想不到的功能。要创建特殊的不规则窗口看上去似乎很难。但我们如果我们说我们用几行代码就可以实现,这似乎不可思议。但事实就是如此!  
/ u. x+ H8 ]# u* c  ~  请试试:
" F, H1 r7 |' m8 T! zPrivate Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
. y$ R2 a) x' o4 D% cPrivate Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
# J  ?9 E7 L: f7 x1 K& H% XPrivate Sub Form_Load()
3 j% H6 R/ O0 z; l( E. M! I9 p' u$ UShow 'The form!
* _; e4 ]0 q- C; BSetWindowRgn hWnd, CreateEllipticRgn(0, 0, 300, 200), True  A/ M8 O+ {6 O* y! G
End Sub
9 o  t7 p7 D6 L& j' S
" b9 o" \, [/ A7 _) E+ [“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... , V) W) J6 s0 Q
发表于 2008-8-13 13:49:25 | 显示全部楼层
创建透明窗体
; Z0 Q' `1 C+ a& S  ?2 n" G& l     透明窗体,顾名思义,就是窗体是透明的,透过窗体可以看到窗体下面" Y1 K) _+ G; o9 _9 b5 G
的东西。实现透明窗体的原理也很简单:首先得到主窗口的矩形区域,
% c2 |9 V# A0 P3 a' T7 S再得到客户区的矩形区域,然后用CombineRgn函数,使用异或操作,将" B* ]- o# z( l% v
重叠部分去除,再使用SetWindowRgn函数设置窗体区域,就行了。
9 c6 j. B! K) t. A' Z( t0 S下面的例子实现了该功能。  e  l; J' C/ E( D3 o3 k
>>步骤1----建立新工程。
* b; q$ l9 m6 u0 s" B5 U>>步骤2----编写如下代码:
" M+ X9 n( b9 f2 O3 r0 h9 s" V) i! i3 ]+ N) \& A- I
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd _- ?9 k7 f* s+ h, ^& H
    As Long, lpRECT As RECT) As Long
# Q' P4 t5 t. e" K! }2 i4 JPrivate Declare Function GetClientRect Lib "user32" (ByVal hWnd _
2 y; J% o3 R; M2 d& z0 D    As Long, lpRECT As RECT) As Long
7 z- s! t5 h! |. u& A4 mPrivate Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn _' B" \8 F) R4 h3 G/ L4 P0 W! }
    As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, _
2 j8 M( N  g  ~1 }% B    ByVal nCombineMode As Long) As Long
9 C! W2 E/ k6 L$ q* y5 ^% qPrivate Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As _) Q; A0 ~3 _4 z6 C' q' x) u
    Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) _
+ \! p+ j3 S3 h) ]. w2 e* R4 ~    As Long
6 v$ ?8 i, Q- ^Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd _; K: F, i8 r' h5 t0 V2 G3 D
    As Long, lpPoint As POINTAPI) As Long
" `# {1 `. j( ]/ C, H% ?3 xPrivate Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As _+ m: [$ b% _8 }% V" g! N- L1 f
    Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
! v( U3 }# j* a3 `  n5 }) B( r3 [2 ^5 O9 G9 k  L
Const RGN_XOR = 3
6 L, L' M# ]) e* B+ L+ S# l
  c8 z) w* Q7 H7 }  KPrivate Type POINTAPI/ k0 v/ }7 s% h0 s
    x As Long, q1 ?' G4 L, R( O* ]) |9 e. [$ s9 ^5 G* a
    Y As Long; T, n1 W' Z% Q4 m0 k2 k
End Type
& R' |9 r5 U7 V: A2 ^' N
/ Z1 z6 p5 F- h. n; Z% f& ~Private Type RECT
/ `( x* x, e6 }% ^2 a; K    Left As Long
) U* \+ A0 O1 v; S4 i5 j    Top As Long
( @, O% `  P/ f7 t1 p/ T    Right As Long9 C, `: F& X0 N  U
    Bottom As Long
- F3 B: J: k% \: cEnd Type2 T& Z, Z8 I# C4 E1 ?
: N( W, w) @2 E& O$ v
Private rctClient As RECT, rctFrame As RECT
- ^9 @  ~" {1 j8 MPrivate hClient As Long, hFrame As Long5 ]  E4 c) P# k! O. G4 ?" z

% x. @' n( S6 m& S0 o) IPublic Sub MakeTransparent(frm As Form)8 K! X0 g/ E7 L
    GetFrameClientRgn frm) `. d+ W# L8 I! L9 J6 l
    SetWindowRgn frm.hWnd, hFrame, True
& V- D1 Q9 H: e( H( N) U# E9 JEnd Sub( J; W" y. s1 `+ D3 d- X; G

: A! ^4 `6 O+ _7 _$ v9 wPrivate Sub GetFrameClientRgn(frm As Form)
7 _" y. I5 Q9 v4 A: X$ s: c1 v    GetWindowRect frm.hWnd, rctFrame
. ?( e) n2 J5 P* U5 @* }/ ]) o% {    GetClientRect frm.hWnd, rctClient& }* }& a  p" ?" ~4 Q* p- y

1 f, H9 u, c) [% g7 r& D$ {( z8 u    '将窗口矩形坐标转换为屏幕坐标
3 p3 Q3 g* k& Y    Dim lpTL As POINTAPI, lpBR As POINTAPI
8 y) C3 x* v& x( a' e5 q5 V7 N5 Q    lpTL.x = rctFrame.Left/ ?( V0 h  |3 F, l# S$ b
    lpTL.Y = rctFrame.Top
' S, d+ Y" ^) ~' A( a& u, }. k    lpBR.x = rctFrame.Right+ R; w7 i3 n3 i4 D. P
    lpBR.Y = rctFrame.Bottom) G) X  F) B4 p& u: p6 M: g% N5 J
    ScreenToClient frm.hWnd, lpTL* ]) p% W; X. l
    ScreenToClient frm.hWnd, lpBR+ R  E) h: h( n: L/ J: E
    rctFrame.Left = lpTL.x; Z0 }' z9 J9 F8 F$ s6 s
    rctFrame.Top = lpTL.Y" U- Z3 f+ }6 k; D# \0 {7 h
    rctFrame.Right = lpBR.x
4 n( m4 z" |9 S( s9 f7 q    rctFrame.Bottom = lpBR.Y
& ]0 V5 K5 @1 N) u! m% c1 P    rctClient.Left = Abs(rctFrame.Left)- J* a9 R/ m# N1 ]& h. k! \* o8 x
    rctClient.Top = Abs(rctFrame.Top)) i! {5 X+ B2 t. b2 r4 n" [
    rctClient.Right = rctClient.Right + Abs(rctFrame.Left)
7 h/ c4 b4 v* ], R# o( h3 X: w    rctClient.Bottom = rctClient.Bottom + Abs(rctFrame.Top)) [6 v6 @8 X8 y* G2 m
    rctFrame.Right = rctFrame.Right + Abs(rctFrame.Left)
& @# ~2 S  h0 m( d$ J" E$ ?    rctFrame.Bottom = rctFrame.Bottom + Abs(rctFrame.Top)8 e9 M# M& f3 T0 m, {7 z5 j
    rctFrame.Top = 0' u2 u( P! y  N3 j, n, g* Y
    rctFrame.Left = 0
- ~3 r2 L5 p+ n# n/ ?  ]0 N7 x: K. F7 D8 h2 n% K
    hClient = CreateRectRgn(rctClient.Left, rctClient.Top, _
- f) |- G: z' O: A    rctClient.Right, rctClient.Bottom)/ g- D$ F& F8 c6 S
    hFrame = CreateRectRgn(rctFrame.Left, rctFrame.Top, _) |& _5 ]) v; [; }, c. r
    rctFrame.Right, rctFrame.Bottom), `* m! k$ G0 l; o6 q2 @
2 m: j3 y; t$ o0 ~9 [! Q  I
    CombineRgn hFrame, hClient, hFrame, RGN_XOR
1 D+ }/ d' C' @: |+ o1 S. ]- U  m9 ]End Sub2 j- C; c9 h# N) ]
. d1 d2 U, _% S6 A
Private Sub Form_Resize()% X3 V% i  s  G
    MakeTransparent Me9 G6 P$ f; J; W
End Sub+ V4 O, w4 H, v$ ]( J9 g6 Y! i
. u3 R( Q+ s3 B* f2 Y
>>步骤3----编译运行,是不是看到效果了。“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
0 |4 e: P) |( }3 z: C/ H
发表于 2008-8-13 13:49:27 | 显示全部楼层
创建位图菜单
8 w+ ^0 E7 f$ t  Q% f5 S0 A
5 @6 K+ d, s5 i1 I3 @  i* b3 [8 @  p在通常的程序中菜单总是以文本的方式存在,有时候显得非常单调乏味。如果能够- t- }1 U! ?. @$ d9 X4 O& v
在菜单中加入位图图形,将会极大地增加用户的使用兴趣。本文介绍了如何使用位4 ^6 `) x% {! s3 |& Z
图制作菜单选项。
8 a+ C- \7 r- x2 Y; I( ^2 c' h8 n% v0 ~
创建位图菜单
0 N, I! s- a2 v/ i) g----创建位图菜单其实非常简单,它需要用到Windows应用程序编程接口(API)的
  X, @! Q2 A' V6 O& B9 k( O一些菜单函数和位图函数,你需要将这些函数的声明包含在你的应用程序的标准模
/ u' n; N$ J2 w5 E( c) R3 y块中,具体的内容请参见样例程序。步骤如下:
' q! `# s' l6 e7 u% T( e8 o6 E# m" u7 ]# w0 }% G/ T3 R
使用函数GetSubMenu来提取子菜单项的句柄,并通过使用函数CreateCompatibleDC
) A, r. C3 q7 D3 n. f: a& `来创建一个兼容的设备环境描述表; 3 D. E* l" i8 k) E. b! _
在一个循环过程中通过使用CreateCompatibleBitmap函数,SelectObject函数以及8 ^2 T; a' U3 F2 N
BitBlt函数来分别将针对各个菜单项所载入的位图选入到兼容设备环境中;
3 [/ k0 C- h* ?9 t) {& i8 _通过ModifyMenu函数绘制真正的位图菜单选项;
& P( R. C  u3 p" A使用DeleteDC函数来释放设备环境,以便其他的程序可以使用它们。
& {5 y+ `, `+ d+ q% m----提取位图可以有多种方法,在本样例程序中在窗体上设置了四个图形框控件,3 x1 u- g% q' r$ j5 D  ^2 w+ B
使用它们载入4个预设的图标来作为菜单选项位图的源文件,当然你也可以使用其
( I0 p8 F, z, ~2 w他的方法,例如使用LoadPicture函数来从磁盘装载位图。 / C5 I" I' n, V  D; f. Z
* |' m2 r  y1 m+ ]
样例程序 & M; @/ C. [* e2 n5 z: }/ N" _2 R: G+ A
/ W% `; D+ s! Q; N
在Visual Basic中开始一个新的工程,采用缺省的方法建立Form1。
/ n2 G; e2 z8 Q创建一个新的模块,采用缺省的方法建立Module1.Bas。
: U5 l% e% \( Z将如下的声明语句和常量添加到Module1.Bas模块中: 8 {8 n& j; S& ~0 B( ?6 g* Y$ Z
Option Explicit6 Z& ^' e# F* s3 `, M; F: S6 Q; W. r
Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long, j. y4 X1 U, k" K7 O. F. ]- N
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, 3 S/ N# ~  D- Y& L' |- W
ByVal nPos As Long) As Long
& K( g8 P! j  Q0 v6 X" _Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long,
( r5 o* V) [+ f' L+ e6 k; _5 j2 QByVal nPos As Long) As Long
. k: ^: g' u$ ?" ~7 c/ y) nDeclare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" ! J. P4 I8 O1 R0 ]
(ByVal hMenu As Long,ByVal nPosition As Long, ByVal wFlags As Long,
' v5 ~7 h1 p1 n( ^7 fByVal wIDNewItem As Long, ByVal lpString As Any) As Long, h5 T) b& t( U& }
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As
% h/ ?; ^+ b+ {- uLong1 Z1 d7 D" k  q
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long9 @+ Y+ S! R$ I' D& W
Declare Function CreateCompatibleBitmap Lib "gdi32"
1 X7 f. r2 @7 |! W( Q: f. u(ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
( }9 A, ]$ y5 Y  F3 H: ^2 dDeclare Function SelectObject Lib "gdi32" (ByVal hdc As Long, 4 Y3 r0 b1 K( `5 }; `! a
ByVal hObject As Long) As Long5 Q) V3 X0 N7 x% G
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As
- O+ ^( N% h/ ^/ R/ U' p0 D# M; \Long,, m- B. c- H2 a9 G4 ~
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
2 r6 F1 c" G3 K# T1 [8 x& E" HhSrcDC
3 Q. V8 r! U* u9 S& J- BAs Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As
; u( n" }6 Y* y+ jLong
& f. g8 M# `, ^; N! m0 oPublic Const SRCCOPY = &HCC0020
, H9 I; p* p/ y- N# ^% _Public Const MF_BYPOSITION = &H400&
- s: _1 b) X" G9 m! uPublic Const MF_BITMAP = &H4&
+ b( h. s2 K. l- I4 J3 p' _
1 k( \6 w# ~7 q0 t5 q7 |1 \/ p; B& E- z注意上面的声明语句需要书写在一行内。
7 Y5 A4 m0 J# p9 u" t在Form1上添加4个图形框控件,将它们的Name属性设置为Picture1,将它们的
" F( c0 ^# Q5 J9 }6 j& LIndex属性依次设置为0,1,2,3,将它们的AutoRedrew属性设置为True,将它们
* q# m& u6 W) C" g* T3 r的AutoResize属性设置为Ture,以及将它们的Visable属性设置为False。
! I. ?, d  w! q$ X将上面的4个图形框控件的Picture属性依次设置为Face1.ico,Face2.ico,Face3.
" t( r. y2 L' l9 @3 C3 |ico,Face4.ico。
% J" s" T) {- V4 D( l8 }+ }# Y在Form1上添加第一个菜单项,将它的标题设置为“[&F]文件”,名称设置为
- n" i9 W% t- j  e$ WmnuFile。在其下添加一个子菜单项,将它的标题设置为“[&E]退出”,名称设置
" {4 I  P) \4 w: u1 U为mnuExit。
  m* p4 S# C8 w在Form1上添加第二个菜单项,将它的标题设置为“[&A]脸谱”,名称设置为8 R8 }- f% m( o! f
mnuFace。在其下添加4个子菜单项,分别将改4个子菜单项的名称设置为“[N]正常”, J1 f/ s! _7 \4 m9 a' K0 q
,“[&S]微笑”,“ [&L]大笑”,以及“[&O]悲伤”。将它们的名称设置为“
- M" Y5 ~5 R. P4 f& P  FmnuFaceSel”,并相应将这4个子菜单项的索引设置为0,1,2,3。
. U( X& L# t* n6 P6 h- r将如下的代码添加到Form1的Form_Load事件中: - J3 r6 {/ ~! @2 S
Private Sub Form_Load()0 k3 H9 j# h! B) Y4 K$ J2 s
Dim nLoopCtr As Integer, ~) D7 R; s# z  I
Dim lResult As Long
5 u% B* }& `9 Z6 kDim hTempDC As Long
* y" _- e0 R# LDim nWidth As Integer
, d7 Y( e. x2 q7 O7 FDim nHeight As Integer- z- N- f+ W( @3 q9 {0 D" s( [& l
Dim lTempID As Long
* p. Q5 o+ ]/ O. A+ e$ N, sDim hMenuID As Long" Z- n- |1 Y( u: w  ^0 g) h
Dim lItemCount As Long4 P; j4 @: E$ p0 s; c: w# X
Dim hBitmap As Long
1 t4 Z) a2 k+ Y: V# jnWidth = Picture1(nLoopCtr).Width \ Screen.TwipsPerPixelX! |' b3 N/ s* t" R! x
nHeight = Picture1(nLoopCtr).Height \ Screen.TwipsPerPixelY  c8 ]. G9 S- v9 Z
hMenuID = GetSubMenu(GetMenu((Me.hwnd)), 1)8 P- M/ I, g1 G- @0 F& L/ d
hTempDC = CreateCompatibleDC(Picture1(nLoopCtr).hdc)
/ i1 x" l- I1 X; K5 a  rFor nLoopCtr = 0 To 3
# e. |4 Z3 Y% FhBitmap = CreateCompatibleBitmap(Picture1(nLoopCtr).hdc, nWidth,
. P' L$ N; A. y& ?: X7 YnHeight)
+ M$ B4 n6 D8 y* |lTempID = SelectObject(hTempDC, hBitmap)" p# @7 p9 ~: L1 s3 \" I
lResult = BitBlt(hTempDC, 0, 0, nWidth, nHeight, (Picture1(
! V) e  @! @0 {- T+ SnLoopCtr).hdc), 0, 0, SRCCOPY)
* i, F( u  c8 j. qlTempID = SelectObject(hTempDC, lTempID)
: T3 s3 S$ g; V7 ]8 e, _/ c2 h! `! knuFaceSel(nLoopCtr).Caption = ""0 X8 h( C" t3 Q) A9 i1 o
lResult = ModifyMenu(hMenuID, nLoopCtr, MF_BYPOSITION Or : V) L& P' [& s- e
MF_BITMAP,: |# `, t: G# f- I  i
GetMenuItemID(hMenuID, nLoopCtr), hBitmap)/ v2 E1 k- ]8 b4 {3 k
Next nLoopCtr
% u: c4 \2 l1 ?% m$ m7 D! W1 Z- _lResult = DeleteDC(hTempDC)! g# ?! S2 J6 k( @2 y  h
End Sub
& N3 R+ G- I9 T! u将如下的代码添加到“退出”子菜单的单击事件中:
; g$ W, W3 Q( H% A# bPrivate Sub mnuExit_Click(Index As Integer)5 N) c9 D7 N6 e  K
Select Case Index" O: u- l. y' d1 v
Case 0
7 ]% E0 O+ I1 O( N4 fUnload Me  i; @( [) M4 \8 N* O# m+ @
End Select
1 N9 U. o1 k0 nEnd Sub" y% f# M  t1 r5 B
运行该样例程序,单击“脸谱”菜单,则会看到由4个脸谱图标所形成的位图子菜4 `# g& A8 @! O4 m% ~
单项,如图1所示。单击“文件”\“退出”菜单可退出应用程序。 ! _" d: u9 [$ V; k0 ^) s
2 _, ]- o# @" j5 p
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
8 q1 a% O+ H3 {' l1 p- n; H- D
发表于 2008-8-13 13:49:28 | 显示全部楼层
创建无 Icon 的窗口 # @( W" [0 ?- z, O! A* q* A6 D
我们在很多时候都需要那种无 Icon 的 窗口,如“关于……”“查找”等。在 VB 中,我们可以按以下步骤来创建此类窗口:
& A: z# M# ~# c5 w1、设置窗口的 BorderStyle = 3; , n+ ^; A/ {# L0 b1 Y
2、在 Form_Load 中加入:Me.Icon = LoadPicture("")  “绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... ; g" `1 _' _( _
 楼主| 发表于 2008-8-13 13:49:29 | 显示全部楼层
创建一个递增数字框
$ c: w5 ]* K3 K! O$ Y4 vYou 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:
1 O. v) F" V3 x5 s. _" \
( K: E6 Q4 E% ?) m2 o$ F2 |) S
7 n* @. H0 D) [Text1.Text = VScroll1.Value' q  m: S* i$ l/ _, K5 m: E2 A
Now 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.
. O4 p' e: |% |1 i
# m7 P# t0 Z1 r7 i0 s2 eTo 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: + m; D, l8 i* Y  s

0 Z! @+ H# L- p, q9 U8 B* T% ?( [& k) ]# i/ V4 t* h% ]/ j* y
Text1.Text = Abs(Vscroll1.Value)/ G  r; E% }% C+ [
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.   ; g5 |) y$ E! \" Y, i
- U" J/ M0 Z/ k6 H) T1 N; A. G$ {
“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人... + U* y- V- U& X, P2 s4 p( p; v8 K
发表于 2008-8-13 13:49:33 | 显示全部楼层
打开 Win95 的创建快捷方式窗口( k* s7 C) t' J9 l; T* o
以下的代码演示了如何利用 Win95 的 Wizard 在指定的目录中建立快捷方式。- t  I! S( b- |* P$ Y

1 p" X# h9 }4 J/ U" XDim X As Integer- Y0 C6 n4 z9 ~' n4 E$ B
X = Shell("C:\WINDOWS\rundll32.exe AppWiz.Cpl,NewLinkHere " & App.Path & "\", 1)3 _( {5 q; s" B; t$ b# M  _1 D4 b

: o3 T) j& [' P  R; I“绿色IT 从我做起”圈子有奖活动话须通俗方传远,语必关风始动人...
* n# }* x# _# L/ Z3 Y' T! E
您需要登录后才可以回帖 登录 | 注册

本版积分规则

投诉建议点击这里给我发消息!点击这里给我发消息!

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

GMT+8, 2018-4-25 14:40 , Processed in 0.461256 second(s), 19 queries .

Powered by DX! X3.4

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

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