| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 940 人关注过本帖, 1 人收藏
标题:本人用VB编写赌场轮盘游戏遇到的难题,请高手指点!
取消只看楼主 加入收藏
shi781203
Rank: 2
来 自:广东省
等 级:论坛游民
帖 子:112
专家分:50
注 册:2011-3-18
结帖率:37.14%
收藏(1)
已结贴  问题点数:10 回复次数:2 
本人用VB编写赌场轮盘游戏遇到的难题,请高手指点!
这个难题就是如何编写代码使得Image控件对象或Picture控件对象旋转?
搜索更多相关主题的帖子: 如何 轮盘游戏 旋转 
2013-03-02 13:24
shi781203
Rank: 2
来 自:广东省
等 级:论坛游民
帖 子:112
专家分:50
注 册:2011-3-18
收藏
得分:0 
以下是引用lowxiong在2013-3-2 17:03:46的发言:

用api函数PlgBlt,那转起来真叫一个顺畅啊!

Declare Function PlgBlt Lib "gdi32" (ByVal hdcDest As Long, lpPoint As POINTAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long) As Long
网上找不到关于这个函数的例子,你能举一个例子说明一下可以吗?

飞点燃费盐--历史上至有型的计算机病毒(能感染你是我的荣幸,也是你的光荣!)
2013-03-03 12:27
shi781203
Rank: 2
来 自:广东省
等 级:论坛游民
帖 子:112
专家分:50
注 册:2011-3-18
收藏
得分:0 
以下是引用曙光电子在2013-3-4 17:08:25的发言:

另一种旋转方法
代码:
Option Explicit

Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long

Private fnt As CLogFont

Private Sub Check1_Click()
   Timer1.Enabled = CBool(Check1.Value)
   HScroll1.Enabled = Not Timer1.Enabled
   If Timer1.Enabled Then
      HScroll1.Value = 0
      Picture1.Cls
   End If
End Sub

Private Sub Command1_Click()
   Picture1.Cls
End Sub

Private Sub Command2_Click()
End
End Sub



Private Sub Form_Load()
   Set fnt = New CLogFont
   Set fnt.LogFont = Picture1.Font
   HScroll1.Value = 0
   Set Me.Icon = Nothing
End Sub

Private Sub Form_Resize()
   On Error Resume Next
   With HScroll1
      .Width = Me.ScaleWidth - .Left * 2
      Picture1.Move .Left, Picture1.Top, Me.ScaleWidth - .Left * 2, Me.ScaleHeight - Picture1.Top - .Left
      Command1.Left = Me.ScaleWidth - .Left - Command1.Width
      Check1.Left = Me.ScaleWidth - .Left - Check1.Width
   End With
End Sub

Private Sub HScroll1_Change()
   fnt.Rotation = HScroll1.Value
   Label1.Caption = "&旋转角度 (" & HScroll1.Value & "):"
End Sub

Private Sub HScroll1_Scroll()
   Label1.Caption = "&旋转角度 (" & HScroll1.Value & "):"
End Sub

Private Sub Label2_Click()

End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
   Dim hFont As Long
   With Picture1
      hFont = SelectObject(.hDC, fnt.Handle)
      .CurrentX = X
      .CurrentY = Y
      Picture1.Print "胡大勤: " & fnt.Rotation
      Call SelectObject(.hDC, hFont)
   End With
End Sub


Private Sub Timer1_Timer()
   With HScroll1
      If .Value = .Max Then
         .Value = .Min
      Else
         .Value = .Value + .LargeChange
      End If
      If (.Value Mod 360) = 0 Then Picture1.Cls
   End With
   With Picture1
      Picture1_MouseUp 0, 0, .ScaleWidth \ 2, .ScaleHeight \ 2
   End With
End Sub

类模块代码:
Option Explicit

Private Const LF_FACESIZE = 32
Private Const LF_FULLFACESIZE = 64

Private Const CLIP_DEFAULT_PRECIS = 0
Private Const CLIP_CHARACTER_PRECIS = 1
Private Const CLIP_STROKE_PRECIS = 2
Private Const CLIP_MASK = &HF
Private Const CLIP_LH_ANGLES = 16
Private Const CLIP_TT_ALWAYS = 32
Private Const CLIP_EMBEDDED = 128

Private Const DEFAULT_QUALITY = 0
Private Const DRAFT_QUALITY = 1
Private Const PROOF_QUALITY = 2

Private Const DEFAULT_PITCH = 0
Private Const FIXED_PITCH = 1
Private Const VARIABLE_PITCH = 2

Private Const ANSI_CHARSET = 0
Private Const DEFAULT_CHARSET = 1
Private Const SYMBOL_CHARSET = 2
Private Const SHIFTJIS_CHARSET = 128
Private Const HANGEUL_CHARSET = 129
Private Const CHINESEBIG5_CHARSET = 136
Private Const OEM_CHARSET = 255


Private Const FF_DONTCARE = 0
Private Const FF_ROMAN = 16


Private Const FF_SWISS = 32

Private Const FF_MODERN = 48


Private Const FF_SCRIPT = 64
Private Const FF_DECORATIVE = 80


Private Const FW_DONTCARE = 0
Private Const FW_THIN = 100
Private Const FW_EXTRALIGHT = 200
Private Const FW_LIGHT = 300
Private Const FW_NORMAL = 400
Private Const FW_MEDIUM = 500
Private Const FW_SEMIBOLD = 600
Private Const FW_BOLD = 700
Private Const FW_EXTRABOLD = 800
Private Const FW_HEAVY = 900

Private Const FW_ULTRALIGHT = FW_EXTRALIGHT
Private Const FW_REGULAR = FW_NORMAL
Private Const FW_DEMIBOLD = FW_SEMIBOLD
Private Const FW_ULTRABOLD = FW_EXTRABOLD
Private Const FW_BLACK = FW_HEAVY

Private Const OUT_DEFAULT_PRECIS = 0
Private Const OUT_STRING_PRECIS = 1
Private Const OUT_CHARACTER_PRECIS = 2
Private Const OUT_STROKE_PRECIS = 3
Private Const OUT_TT_PRECIS = 4
Private Const OUT_DEVICE_PRECIS = 5
Private Const OUT_RASTER_PRECIS = 6
Private Const OUT_TT_ONLY_PRECIS = 7
Private Const OUT_OUTLINE_PRECIS = 8

Private Type LogFont
   lfHeight As Long
   lfWidth As Long
   lfEscapement As Long
   lfOrientation As Long
   lfWeight As Long
   lfItalic As Byte
   lfUnderline As Byte
   lfStrikeOut As Byte
   lfCharSet As Byte
   lfOutPrecision As Byte
   lfClipPrecision As Byte
   lfQuality As Byte
   lfPitchAndFamily As Byte
   lfFaceName As String * LF_FACESIZE
End Type

Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LogFont) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long

Private Const LOGPIXELSY = 90

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long

Private m_Font As StdFont
Private m_hFont As Long
Private m_Rotation As Single

Private Sub Class_Terminate()
  
   If m_hFont Then
      Call DeleteObject(m_hFont)
      Set m_Font = Nothing
   End If
End Sub

Public Property Set LogFont(ByVal NewFont As Font)
   If m_hFont Then
      Call DeleteObject(m_hFont)
      m_hFont = 0
   End If
   
   If NewFont Is Nothing Then
      Set m_Font = Nothing
   Else
     
      Set m_Font = New StdFont
      With m_Font
         .Bold = NewFont.Bold
         .Charset = NewFont.Charset
         .Italic = NewFont.Italic
         .Name = NewFont.Name
         .Size = NewFont.Size
         .Strikethrough = NewFont.Strikethrough
         .Underline = NewFont.Underline
         .Weight = NewFont.Weight
      End With
      m_hFont = CreateLogFont
   End If
End Property

Public Property Get LogFont() As Font
   Set LogFont = m_Font
End Property

Public Property Let Rotation(ByVal NewVal As Single)
   If NewVal <> m_Rotation Then
      m_Rotation = NewVal
      If m_hFont Then
         Call DeleteObject(m_hFont)
         m_hFont = 0
      End If
      If Not (m_Font Is Nothing) Then
         m_hFont = CreateLogFont
      End If
   End If
End Property

Public Property Get Rotation() As Single
   Rotation = m_Rotation
End Property

Public Property Get Handle() As Long
   Handle = m_hFont
End Property

Private Function CreateLogFont() As Long
   Dim lf As LogFont
   Dim hWnd As Long
   Dim hDC As Long
   
   hWnd = GetDesktopWindow
   hDC = GetDC(hWnd)
   
   With lf
     
      .lfHeight = -(m_Font.Size * GetDeviceCaps(hDC, LOGPIXELSY)) / 72
      .lfWidth = 0
      .lfEscapement = m_Rotation * 10
      .lfOrientation = .lfEscapement
      .lfWeight = m_Font.Weight
      .lfItalic = m_Font.Italic
      .lfUnderline = m_Font.Underline
      .lfStrikeOut = m_Font.Strikethrough
      .lfClipPrecision = CLIP_DEFAULT_PRECIS
      .lfQuality = PROOF_QUALITY
      .lfPitchAndFamily = DEFAULT_PITCH Or FF_DONTCARE
      .lfFaceName = m_Font.Name & vbNullChar
   
      .lfCharSet = m_Font.Charset
      If .lfCharSet = OEM_CHARSET Then
         If (m_Rotation Mod 360) <> 0 Then
            .lfCharSet = ANSI_CHARSET
         End If
      End If
     
      If (m_Rotation Mod 360) <> 0 Then
         .lfOutPrecision = OUT_TT_ONLY_PRECIS
      Else
         .lfOutPrecision = OUT_DEFAULT_PRECIS
      End If
   End With
   
   CreateLogFont = CreateFontIndirect(lf)
   Call ReleaseDC(hWnd, hDC)
End Function

真的非常多谢你的回复,看来你非常了解API函数!你是API高手吧?

飞点燃费盐--历史上至有型的计算机病毒(能感染你是我的荣幸,也是你的光荣!)
2013-03-04 22:37
快速回复:本人用VB编写赌场轮盘游戏遇到的难题,请高手指点!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011937 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved