樣例程序
在Visual Basic中開始一個新的工程,采用缺省的方法建立Form1。
創(chuàng)建一個新的模塊,采用缺省的方法建立Module1.Bas。
將如下的聲明語句和常量添加到Module1.Bas模塊中:
Option Explicit
Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long,
ByVal nPos As Long) As Long
Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long,
ByVal nPos As Long) As Long
Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA"
(ByVal hMenu As Long,ByVal nPosition As Long, ByVal wFlags As Long,
ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function CreateCompatibleBitmap Lib "gdi32"
(ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long,
ByVal hObject As Long) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long,
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC
As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Const SRCCOPY = &HCC0020
Public Const MF_BYPOSITION = &H400&
Public Const MF_BITMAP = &H4&
注意上面的聲明語句需要書寫在一行內(nèi)。
在Form1上添加4個圖形框控件,將它們的Name屬性設(shè)置為Picture1,將它們的Index屬性依次設(shè)置為0,1,2,3,將它們的AutoRedrew屬性設(shè)置為True,將它們的AutoResize屬性設(shè)置為Ture,以及將它們的Visable屬性設(shè)置為False。
將上面的4個圖形框控件的Picture屬性依次設(shè)置為Face1.ico,F(xiàn)ace2.ico,F(xiàn)ace3.ico,F(xiàn)ace4.ico。
在Form1上添加第一個菜單項,將它的標(biāo)題設(shè)置為“[&F]文件”,名稱設(shè)置為mnuFile。在其下添加一個子菜單項,將它的標(biāo)題設(shè)置為“[&E]退出”,名稱設(shè)置為mnuExit。
在Form1上添加第二個菜單項,將它的標(biāo)題設(shè)置為“[&A]臉譜”,名稱設(shè)置為mnuFace。在其下添加4個子菜單項,分別將改4個子菜單項的名稱設(shè)置為“[N]正常”,“[&S]微笑”,“ [&L]大笑”,以及“[&O]悲傷”。將它們的名稱設(shè)置為“mnuFaceSel”,并相應(yīng)將這4個子菜單項的索引設(shè)置為0,1,2,3。
相關(guān)推薦:北京 | 天津 | 上海 | 江蘇 | 山東 |
安徽 | 浙江 | 江西 | 福建 | 深圳 |
廣東 | 河北 | 湖南 | 廣西 | 河南 |
海南 | 湖北 | 四川 | 重慶 | 云南 |
貴州 | 西藏 | 新疆 | 陜西 | 山西 |
寧夏 | 甘肅 | 青海 | 遼寧 | 吉林 |
黑龍江 | 內(nèi)蒙古 |