»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
¼¼ÊõÎĵµ > VBÎĵµ > ´°Ìå½çÃæ
VB´òÔ쳬¿á¸öÐÔ»¯²Ëµ¥
·¢±íÈÕÆÚ£º2004-10-25 21:26:47×÷ÕߣºÂ ³ö´¦£ºCSDN  

   ÖÚËùÖÜÖª£¬MS Office 2003ÍƳöÒѾ­ÓÐÒ»¶Îʱ¼äÁË£¬µ«ÎÒÃÇÒÀÈ»²»»áÍü¼ÇOffice XP¸Õ¸ÕÍƳöʱÆäÁîÈ˶úĿһеIJ˵¥¸øÎÒÃÇÁôϵÄÉî¿ÌÓ¡Ïó¡£Í»ÆðµÄÐü¸¡Ê½Í¼±ê£¬²»Í¬Ñ°³£µÄ²Ëµ¥ÏîÌî³ä·½Ê½£¬²»½öÈð칫һ×åÃÇÔÞ²»¾ø¿Ú£¬¸üÈùã´óµÄ³ÌÐòÔ±ºÍ±à³Ì°®ºÃÕ߶ÔÕâÖÖ·ç¸ñµÄ²Ëµ¥µÄÖÆ×÷²úÉúÁËŨºñµÄÐËȤ¡£ËùÒÔ£¬ÔÚÕâƪÎÄÕÂÀÎÒÃǾÍÀ´ºÃºÃµØÑо¿Ñо¿ÓÃVBÔõôÖÆ×÷ÕâÖÖ·ç¸ñµÄ²Ëµ¥£¬ÔÚÎÄÕµÄ×îºó£¬ÎÒ½«¸ø³öÔ´´úÂëµÄÏÂÔصØÖ·¡£ÊÂʵÉÏ£¬ÔÚÁ˽âÆäÔ­ÀíÒԺ󣬲»ÂÛÊÇÓÃVB¡¢VC»¹ÊÇDelphi£¬¶¼Äܹ»ÖÆ×÷³öXP·ç¸ñµÄ²Ëµ¥¡£²»½öÈç´Ë£¬ÎÒÃÇ»¹¿ÉÒÔÖÆ×÷³ö¸ü¼Ó³äÂú¸öÐÔµÄÁíÀà·ç¸ñµÄ²Ëµ¥£¬±ÈÈç3DÁ¢Ìå·ç¸ñ¡¢½¥±ä·ç¸ñ¡¢¶à²Ê·ç¸ñµÈµÈ¡£Ö»ÓÐÏë²»µ½µÄ£¬Ã»ÓÐ×ö²»µ½µÄ¡£Follow me£¡

    ÏÖÔÚ£¬ÎÒÏëÓбØҪ˵һ˵ÎÒÃÇÏÖÔÚÒª×öµÄÊÂÇé¡£ÊÂʵÉÏ£¬ÎÒÃÇÖ»Òª×öÒ»¸ö²Ëµ¥Àà¾ÍÐÐÁË¡£µ«Ë­¶¼»áÃ÷°×£¬Ö»×öÒ»¸ö²Ëµ¥ÀàÊDz»¹»µÄ£¬ÎÒÃÇÐèÒªÒ»¸ö³ÌÐò£¬»òÕ߸üÏêϸµÄ˵£¬ÊÇÒ»¸ö´°Ì壬À´²âÊÔÎÒÃǵIJ˵¥Àà¡£ÔÚÎÒ¸öÈ˵Ŀª·¢¹ý³ÌÖУ¬ÎÒÊÇÏÈдµÄ²Ëµ¥À࣬ºóдµÄ²âÊÔ´°Ì壬µ«ÎªÁËÈôó¼ÒÏÈÁìÂÔÒ»ÏÂдºÃµÄ²Ëµ¥ÀàÔÚÓ¦ÓÃʱÊǶàôµÄ·½±ã£¬ËùÒÔÈÃÎÒÃÇÏÈÀ´¿´¿´²âÊÔ´°Ì壺

    £¨1£©´ò¿ªVB£¬Ð½¨¡°±ê×¼EXE¡±¹¤³Ì¡£

    £¨2£©­­ÏÂÃæÊÇ´°ÌåµÄ¿Ø¼þ£º

 

×é¼þÃû³Æ

ÊôÐÔ

Öµ

Form

Name

Caption

frmMain

²Ëµ¥Àý×Ó

Frame

Name

Caption

fraStyle

²Ëµ¥·ç¸ñ

Label

Name

Caption

lblHelp

ÔÚ´°Ìå¿Õ°×´¦µ¥»÷Êó±êÓÒ¼ü

OptionButton

Name

Caption

Index

opnStyle

Window ±ê×¼

0

OptionButton

Name

Caption

Index

opnStyle

XP ·ç¸ñ

1

OptionButton

Name

Caption

Index

opnStyle

3D Á¢Ìå·ç¸ñ

2

OptionButton

Name

Caption

Index

opnStyle

½¥±ä·ç¸ñ

3

OptionButton

Name

Caption

Index

opnStyle

¶à²Ê·ç¸ñ

4

 

    Æäʵ¾ÍÊÇÔÚ´°ÌåÉÏÌí¼ÓÁËÒ»¸öFrame£¬È»ºóÔÚFrameÀïÌí¼ÓOptionButton¿Ø¼þÊý×飬ÓÃÀ´ÉèÖò˵¥·ç¸ñ£¬»¹ÓÐÒ»¸öLabel£¬ÉÏÃæÖ»ÏÔʾһÐÐÌáʾÎÄ×Ö£¬·Ç³£¼òµ¥¡£

    £¨3£©´°Ìå´úÂ룺

 

Option Explicit

 

Private Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINTAPI) As Long

 

Private Type POINTAPI

    X As Long

    Y As Long

End Type

 

Dim menu As cMenu

 

Private Sub Form_Load()

    ' ³õʼ»¯²Ëµ¥²¢Ìí¼Ó²Ëµ¥Ïî

    Set menu = New cMenu

    menu.CreateMenu

    menu.AddItem "open", LoadPicture("images\open.ico"), "´ò¿ª", MIT_STRING

    menu.AddItem "save", LoadPicture("images\save.ico"), "±£´æ", MIT_STRING

    menu.AddItem "print", LoadPicture("images\print.ico"), "´òÓ¡", MIT_STRING

    menu.AddItem "find", LoadPicture("images\find.ico"), "²éÕÒ", MIT_STRING

    menu.AddItem "sep1", LoadPicture(), "", MIT_SEPARATOR

    menu.AddItem "undo", LoadPicture("images\undo.ico"), "³·Ïû", MIT_STRING

    menu.AddItem "redo", LoadPicture("images\redo.ico"), "Öظ´", MIT_STRING

    menu.AddItem "sep2", LoadPicture(), "", MIT_SEPARATOR

    menu.AddItem "cut", LoadPicture("images\cut.ico"), "¼ôÇÐ", MIT_STRING

    menu.AddItem "copy", LoadPicture("images\copy.ico"), "¸´ÖÆ", MIT_STRING

    menu.AddItem "paste", LoadPicture("images\paste.ico"), "Õ³Ìù", MIT_STRING

    menu.AddItem "sep3", LoadPicture(), "", MIT_SEPARATOR

    menu.AddItem "check", LoadPicture("images\check.ico"), "Ò»¸ö CheckBox", MIT_CHECKBOX

    menu.AddItem "exit", LoadPicture("images\exit.ico"), "Í˳ö", MIT_STRING

End Sub

 

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    ' µ¥»÷Êó±êÓÒ½¨µ¯³ö²Ëµ¥

    If Button = vbRightButton Then

        Dim pos As POINTAPI

        GetCursorPos pos

        menu.PopupMenu pos.X, pos.Y, POPUP_LEFTALIGN Or POPUP_TOPALIGN

    End If

End Sub

 

Private Sub Form_Unload(Cancel As Integer)

    ' ÊÍ·Å×ÊÔ´, жÔØ´°Ìå

    Set menu = Nothing

    Dim frm As Form

    For Each frm In Forms

        Unload frm

    Next

End Sub

 

Private Sub opnStyle_Click(Index As Integer)

    ' ÉèÖò˵¥·ç¸ñ

    Select Case Index

        Case 0                                  ' Windows ±ê×¼

            menu.Style = STYLE_WINDOWS

        Case 1                                  ' XP ·ç¸ñ

            menu.Style = STYLE_XP

        Case 2                                  ' 3D Á¢Ìå·ç¸ñ

            menu.Style = STYLE_3D

        Case 3                                  ' ½¥±ä·ç¸ñ

            menu.Style = STYLE_SHADE

        Case 4                                  ' ¶à²Ê·ç¸ñ

            menu.Style = STYLE_COLORFUL

    End Select

End Sub

 

    ´úÂëÖд´½¨ÁËÒ»¸öcMenuÀàµÄ¶ÔÏó£¬ÎÒÃǵıà³ÌÖص㽫»á·ÅÔÚcMenuÀàÉÏ£¬ÉÏÃæµÄ´úÂëÖ»ÊǼòµ¥µØµ÷ÓÃcMenu¡£ÔÚºóÃæµÄÎÄÕÂÖУ¬ÎÒÃǻῴµ½ÆäʵcMenuÓжà´ï30¸ö·½·¨ºÍÊôÐÔ¹©ÎÒÃǵ÷Óã¬ËüµÄStyleÊôÐÔÖ»ÌṩÁË5ÖÖÄÚÖ÷ç¸ñ£¬ÔÚʵ¼ÊÓ¦ÓÃÖУ¬ÎÒÃÇ¿ÉÒÔÀûÓÃcMenuÀàÌṩµÄ·½·¨ºÍÊôÐÔÖÆ×÷³ö¸÷ÖÖ¸÷Ñù·ç¸ñµÄ²Ëµ¥£¬Îª×Ô¼ºµÄ³ÌÐò½õÉÏÌí»¨¡£

    £¨4£©ÔËÐнá¹û£º

 

Windows ±ê×¼

 

XP ·ç¸ñ

 

 

 

 

    Æäʵ£¬Æ¯ÁÁµÄ½çÃ涼ÊÇ¡°»­¡±³öÀ´µÄ£¬²Ëµ¥µ±È»Ò²²»ÀýÍâ¡£¼ÈÈ»ÊÇ¡°»­¡±³öÀ´µÄ£¬¾ÍÐèÒªÓд°ÌåÀ´½ÓÊÕ¡°»­¡±²Ëµ¥Õâ¸öÏûÏ¢£¬ºóÃæÎÒÃǻῴµ½£¬Êµ¼ÊÉϲ»½ö½öÊÇ¡°»­¡±Õâ¸öÏûÏ¢£¬Ò»ÇйØÓÚÕâ¸ö²Ëµ¥µÄÏûÏ¢¶¼ÒªÓÐÒ»¸ö´°ÌåÀ´½ÓÊÕ¡£Èç¹ûÄã¶ÔÏûÏ¢²»Ì«Á˽⣬¿ÉÒÔ¿´¿´ÍøÉÏÆäËüһЩ¹ØÓÚWindowsÏûÏ¢»úÖƵÄÎÄÕ¡£²»Á˽âҲûÓйØϵ£¬Ö»Òª»áʹÓþͿÉÒÔÁË£¬ºóÃæµÄÎÄÕ¸ø³öÁËÍêÕûµÄÔ´´úÂ룬¶øÇÒÎÄÕµÄ×îºó»¹¸ø³öÁËÔ´´úÂëµÄÏÂÔصØÖ·¡£
    ÏÂÃæÎÒÃÇÀ´´´½¨½ÓÊÕÏûÏ¢µÄ´°Ì壺´ò¿ªÉϴν¨ºÃµÄ¹¤³Ì£¬Ìí¼ÓÒ»¸ö´°Ì壬²¢½«ÆäÃû³ÆÉèÖÃΪfrmMenu£¨×¢Ò⣺ÕâÒ»²½ÊDZØÐëµÄ£©¡£»¹¼ÇµÃÉÏƪÎÄÕµÄ×îºóÒ»·ùͼÂ𣿲˵¥×ó±ßÄǸöºÚµ×É«µÄ¸½¼ÓÌõ£¬ÎªÁË·½±ã£¬½«frmMenuµÄPictureÊôÐÔÉèÖóÉÄÇ·ùͼ¡£µ½´Ë£¬Õâ¸ö´°Ìå¾ÍËãOKÁË£¡¶ÔÁË£¬¾ÍÕâÑù£¬ÒòΪÕâ¸ö´°Ìå½ö½öÊÇΪÁË´¦ÀíÏûÏ¢ºÍ´æ´¢ÄǸöºÚµ×É«µÄ·ç¸ñÌõ£¬ÎÒÃǽ«»á¶ÔËü½øÐÐ×ÓÀà´¦Àí£¬´¦ÀíÏûÏ¢µÄ´úÂëÈ«²¿¶¼·ÅÔÚÁ˽«ÔÚÏÂһƪÖÐÏêϸ½éÉܵıê׼ģ¿éÖС£
    ½ÓÏÂÀ´Ìí¼ÓÒ»¸öÀàÄ£¿é£¬²¢½«ÆäÃû³ÆÉèÖÃΪcMenu£¬´úÂëÈçÏ£º

 

'**************************************************************************************************************

'* ±¾ÀàÄ£¿éÊÇÒ»¸ö²Ëµ¥Àà, ÌṩÁ˸÷ÖÖÑùʽµÄ²Ëµ¥µÄÖÆ×÷·½°¸

'*

'* °æȨ: LPPÈí¼þ¹¤×÷ÊÒ

'* ×÷Õß: ¬ÅàÅà(goodname008)

'* (******* ¸´ÖÆÇë±£ÁôÒÔÉÏÐÅÏ¢ *******)

'**************************************************************************************************************

 

Option Explicit

 

Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, lprc As Any) As Long

 

Public Enum MenuUserStyle                                   ' ²Ëµ¥×ÜÌå·ç¸ñ

    STYLE_WINDOWS

    STYLE_XP

    STYLE_SHADE

    STYLE_3D

    STYLE_COLORFUL

End Enum

 

Public Enum MenuSeparatorStyle                              ' ²Ëµ¥·Ö¸ôÌõ·ç¸ñ

    MSS_SOLID

    MSS_DASH

    MSS_DOT

    MSS_DASDOT

    MSS_DASHDOTDOT

    MSS_NONE

    MSS_DEFAULT

End Enum

 

Public Enum MenuItemSelectFillStyle                         ' ²Ëµ¥Ïî±³¾°Ìî³ä·ç¸ñ

    ISFS_NONE

    ISFS_SOLIDCOLOR

    ISFS_HORIZONTALCOLOR

    ISFS_VERTICALCOLOR

End Enum

 

Public Enum MenuItemSelectEdgeStyle                         ' ²Ëµ¥Ïî±ß¿ò·ç¸ñ

    ISES_SOLID

    ISES_DASH

    ISES_DOT

    ISES_DASDOT

    ISES_DASHDOTDOT

    ISES_NONE

    ISES_SUNKEN

    ISES_RAISED

End Enum

 

Public Enum MenuItemIconStyle                               ' ²Ëµ¥Ïîͼ±ê·ç¸ñ

    IIS_NONE

    IIS_SUNKEN

    IIS_RAISED

    IIS_SHADOW

End Enum

 

Public Enum MenuItemSelectScope                             ' ²Ëµ¥Ïî¸ßÁÁÌõµÄ·¶Î§

    ISS_TEXT = &H1

    ISS_ICON_TEXT = &H2

    ISS_LEFTBAR_ICON_TEXT = &H4

End Enum

 

Public Enum MenuLeftBarStyle                                ' ²Ëµ¥¸½¼ÓÌõ·ç¸ñ

    LBS_NONE

    LBS_SOLIDCOLOR

    LBS_HORIZONTALCOLOR

 &nb

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00402