dポイントプレゼントキャンペーン実施中!

VB6でForm内にCommandButtonがいくつか有ります。
各CommandButtonはClickするとShellオブジェクトでファイルを開く様になっています。
やりたいことは
2つのCommandButton間をDragDrop?によりCaptionを入れ替えたいです。
(CommandButton間をマウスDragDropでCaption名入れ替え)

MouseDownとDragDropイベントで何とかなると思いましたがうまくいきません。

Dim dd As Integer
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
dd = 1 'CommandボタンNo,
End If
End Sub
Private Sub Command2_DragDrop(Source As Control, X As Single, Y As Single)
Dim cn As String
cn = Command2.Caption
Command2.Caption = Controls("Command" & dd).Caption
Controls("Command" & dd).Caption = cn
End Sub

CommandButtonプロパティでDragModeを自動にするとShellオブジェクトでファイルが開かないし
サイトで調べたところファイルの移動やコマンド自体の移動などで分かりませんでした。
ご教授お願い致します。

A 回答 (1件)

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


  Command1.Drag
End Sub

Private Sub Command2_DragDrop(Source As Control, X As Single, Y As Single)
  Dim strTmp As String
  strTmp = Command2.Caption
  Command2.Caption = Source.Caption
  Source.Caption = strTmp
End Sub
    • good
    • 0
この回答へのお礼

試したところSourceでドラックした内容を受け取れました。
助かりました、有り難うございます。
Command1のクリックイベントが使えないですが、DragDropイベントへ
If Source.Caption = Command1.Caption Then をDragDropイベントへ
入れることで対処出来ました。有り難うございました。

お礼日時:2014/07/25 14:32

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!