tagCANDY CGI VBレスキュー(花ちゃん)の Visual Basic 6.0用 掲示板
VBレスキュー(花ちゃん)の Visual Basic 6.0用 掲示板
[ツリー表示へ]  [ワード検索]  [Home]

タイトル Re^4: こんなことできるのかな?
投稿日: 2008/03/01(Sat) 14:26
投稿者だめおやじ
> 花ちゃん様へ指導いただき下記より解決できましたが、Picture1にPicture2を貼付
 てPicture1の範囲でPicture2を移動したいのですが解決できません。追加コ−ドは
 コ−ド内に記載してあります。ご教授願います。
 Picture1の移動は正常に作動しています。

> Picture2は「x、y」の取得が悪いのかPicture1の範囲を超えてドラッグされます

      記

>  http://hanatyan.sakura.ne.jp/vbhlp/gra_image.htm

 コード

Dim lngImageHeight As Long
Dim lngImageWidth  As Long
'***************追加分************
Dim lngPicture1Height As Long 
Dim lngPicture1Width  As Long 
Dim lngPicture2Height As Long 
Dim lngPicture2Width  As Long 
'***************ここまで************
Dim lngX As Long
Dim lngY As Long

Private Sub Command10_Click() '追加分
If lngPictureHeight = 0 Then                '初めてクリックした時
    lngPictureHeight = Picture2.Height   '変数に元の画像サイズを記録する
    lngPictureWidth = Picture2.Width
End If
   ' Picture1.Stretch = True
     Picture2.Height = lngPictureHeight
     Picture2.Width = lngPictureWidth
    
End Sub

Private Sub Command3_Click()
'画像の読込
If lngImageHeight = 0 Then           '初めてクリックした時
    lngImageHeight = Image1.Height   '変数に元の画像サイズを記録する
    lngImageWidth = Image1.Width
End If
    Image1.Stretch = True
    Image1.Height = lngImageHeight
    Image1.Width = lngImageWidth
  Set Image1.Picture = LoadPicture("C:\還暦.jpg") 
End Sub

Private Sub Command1_Click()
    '拡大のMAXの設定
    If lngImageHeight * 2 <= Image1.Height Then Exit Sub
    'イメージのサイズが変更できるように
    Image1.Stretch = True
    'クリックの都度10%づつ拡大する
    Image1.Height = Image1.Height * 1.1
    Image1.Width = Image1.Width * 1.1
End Sub

Private Sub Command2_Click()
    '縮小のMAXの設定
    If lngImageHeight * 0.3 >= Image1.Height Then Exit Sub
    'イメージのサイズが変更できるように
    Image1.Stretch = True
    'クリックの都度10%づつ縮小する
    Image1.Height = Image1.Height * 0.9
    Image1.Width = Image1.Width * 0.9
End Sub

Private Sub Command4_Click()
    Image1.Move 50, 50
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift _
                                 As Integer, x As Single, y As Single)
    lngX = x                 '現在の表示位置を取得
    lngY = y
    Image1.Drag vbBeginDrag
End Sub
'***************追加分************

Private Sub Picture1_MouseDown(Button As Integer, Shift _
                                 As Integer, x As Single, y As Single)
    lngX = x
    lngY = y
    Picture1.Drag vbBeginDrag
     Set Picture1.Picture = LoadPicture("C:\還暦.jpg")
End Sub
Private Sub Picture2_MouseDown(Button As Integer, Shift _
                                 As Integer, x As Single, y As Single)
    lngX = x
    lngY = y
    Picture2.Drag vbBeginDrag
     Set Picture2.Picture = LoadPicture("C:\還暦.jpg")
End Sub
Private Sub Picture1_DragDrop(Source As Control, x As Single, y As Single)
    Source.Move (Picture1.Left + x - lngX), (Picture1.Top + y - lngY)
End Sub
Private Sub Picture2_DragDrop(Source As Control, x As Single, y As Single)
    Source.Move (Picture1.Left + x - lngX), (Picture1.Top + y - lngY)
End Sub
'***************ここまで************
Private Sub Form_DragDrop(Source As Control, x As Single, y As Single)
    'ドロップ位置がフォーム上の場合
    Source.Move x - lngX, y - lngY
End Sub

Private Sub Command6_Click()
    'クリックする度に500Twip 上に移動
    Image1.Move (Image1.Left), (Image1.Top - 500)
End Sub

Private Sub Command7_Click()
    'クリックする度に500Twip 下に移動
    Image1.Move (Image1.Left), (Image1.Top + 500)
End Sub

Private Sub Command8_Click()
    'クリックする度に500Twip 左に移動
    Image1.Move (Image1.Left - 500), (Image1.Top)
End Sub

Private Sub Command9_Click()
    'クリックする度に500Twip 右に移動
    Image1.Move (Image1.Left + 500), (Image1.Top)
End Sub
Private Sub Image1_DragDrop(Source As Control, x As Single, y As Single)
    'ドロップ位置に表示
    Source.Move (Image1.Left + x - lngX), (Image1.Top + y - lngY)
End Sub

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)

古いスレッドにレスはつけられません。