No.4
- 回答日時:
不十分?どこがですか?
もうすでに回答があるようなので大丈夫だと思いますが…
もう少しプロパティとかを見た方がいいです。
この手のプログラムのサンプルソースなんていくらでもあります。
最近は丸投げの人が多いですがそういう人は成長しません。
探す事も一つの力です。
頑張りましょう。
No.3
- 回答日時:
Point DragStart;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
DragStart = e.Location;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mouse_pos = pictureBox1.PointToScreen(e.Location);
mouse_pos = this.PointToClient(mouse_pos);
pictureBox1.Left = mouse_pos.X - DragStart.X;
pictureBox1.Top = mouse_pos.Y - DragStart.Y;
}
}
とりあえずこんな感じで出来るみたいです。
No.2
- 回答日時:
参考URLは画面自体がドラッグできますが、同様な手続きをピクチャボックスを継承したクラスを作成し、張り替えると楽チンです。
大きく手順は三つです。
フォームから飛び出させる方法も載せておりますが、不要であれば消してください。
(チラツキは無視w)
----------------
[mypic.cs]の新規作成
----------------
//http://www.ipentec.com/document/document.aspx?pa …
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class mypic : PictureBox
{
private const int WM_SYSCOMMAND = 0x112;
private const int SC_MOVE = 0xF010;
[DllImport("User32.dll")]
private static extern bool SetCapture(IntPtr hWnd);
[DllImport("User32.dll")]
private static extern bool ReleaseCapture();
[DllImport("User32.dll")]
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("User32.dll")]
private static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("User32.dll")]
private static extern IntPtr GetParent(IntPtr hWnd);
[DllImport("User32.dll")]
private static extern IntPtr GetDesktopWindow();
[DllImport("User32.dll")]
private static extern int ClientToScreen(IntPtr hWmd, ref Point lpPoint);
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
#region フォームを飛び出させたいとき
{
IntPtr hDeskTop = GetDesktopWindow();
IntPtr hParent = GetParent(this.Handle);
if (hDeskTop != hParent)
{
Point pnt = this.Location;
int hh = Marshal.SizeOf(pnt);
hh = Marshal.SizeOf(this.Location.GetType());
ClientToScreen(hParent, ref pnt);
SetParent(this.Handle, GetDesktopWindow());
this.Location = pnt;
}
}
#endregion
SetCapture(this.Handle);
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE | 2, 0);
}
}
----------------
フォーム1に「pictureBox1」を作成
----------------
----------------
[Form1.Designer.cs]の一部を修正
----------------
this.pictureBox1 = new System.Windows.Forms.PictureBox();
を以下に↓
this.pictureBox1 = new mypic();
private System.Windows.Forms.PictureBox pictureBox1;
を以下に↓
private mypic pictureBox1;
参考URL:http://www.ipentec.com/document/document.aspx?pa …
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
VB6.0(SP6)にて開発を行なって...
-
VC++2010でdllファイルの作成に...
-
python エラー
-
アプリケーションのDLLファイル...
-
エクセルのエラーメッセージ「4...
-
ソフトの開発言語を調べる方法
-
BCC Developer開発環境でソケッ...
-
パブリックシンボルとは?
-
ILSpyで、デコンパイルできない。
-
右クリックメニューについて
-
gcc コンパイル killed
-
#pragmaとは
-
レコードセットをcloseする所で...
-
<unistd.h>をVisualStudioでつ...
-
C++でデスクトップGUIアプリ開...
-
error C3867 関数呼び出しには...
-
バッチからsqlplusの接続エラー...
-
CとC++の混在、最近は
-
実行後にコンパイルに失敗しま...
-
Visual Studioのstrcpy_sについて
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
res://ieframe.dll/について
-
ASP.NETのDLL入れ替えについて
-
VB6.0(SP6)にて開発を行なって...
-
WIN10で常にフォームを手前に
-
C# DLL エントリ ポイントが...
-
ファイルをvbaで圧縮したいので...
-
visual studioの不要なDll削除方法
-
手書き文字認識のdll
-
M365にアップデートしてからコ...
-
[VBA]64b版-行数表示.dllの登録...
-
VBAエディタのコード画面で、カ...
-
ベースアドレスの設定について
-
メイクファイルからdllを生成す...
-
VBからIMEパッドを呼び出す方法...
-
パソリからIDをVB6で読み込みた...
-
実行ファイルからソースファイ...
-
steamのゲームが起動しません。
-
APIの呼び出しDLLファイルの場...
-
指定された引数が有効範囲にな...
-
dllをいじる。。
おすすめ情報