.NET フォーム関連
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
] [
Twitter
]
開始行:
→[[.NETプログラミング]]
#contents
*Webサイト [#sd7a34c8]
-[[Working with .NET windows Forms:http://www.only4gurus....
*Tips [#b7e75c96]
-[[英語OSでフォームやボタン位置がずれる問題>http://bbs.wa...
--自動スケーリング機能が働いているため。フォームのAutoSca...
--[[フォームの自動スケーリングについて>http://msdn2.micro...
--※フォームでMaximumSizeを設定していると、AutoScaleをTrue...
-[[Creating a Splash Screen that runs without a message p...
-[[Windowsフォームの入力チェックを効率化する>http://codez...
--ErrorProviderの紹介
*フォームの強制前出し [#m090ef3a]
-あんまり無闇にこれやると行儀が悪いしウザいので注意
using System.Runtime.InteropServices; //<-これ必要
[DllImport("USER32.DLL", CharSet=CharSet.Auto)]
private static extern int ShowWindow(
IntPtr hWnd,
int nCmdShow
);
[DllImport("USER32.DLL", CharSet=CharSet.Auto)]
private static extern bool SetForegroundWindow(
IntPtr hWnd
);
private const int SW_NORMAL = 1;
/// ---------------------------------------------------...
/// <summary>
/// 同名のプロセスが起動中の場合、メイン ウィンドウ...
/// <returns>
/// 既に起動中であれば true。それ以外は false。</re...
/// ---------------------------------------------------...
public static bool ShowPrevProcess()
{
Process hThisProcess = Process.GetCurrentProcess();
Process[] hProcesses = Process.GetProcessesByName(hThi...
int iThisProcessId = hThisProcess.Id;
foreach (Process hProcess in hProcesses)
{
if (hProcess.Id != iThisProcessId)
{
ShowWindow(hProcess.MainWindowHandle, SW_NORMAL);
SetForegroundWindow(hProcess.MainWindowHandle);
return true;
}
}
return false;
}
*フォームのカスタムペイント [#sab2728e]
-[[Google Talk Window Form>http://www.codeproject.com/cs/...
*XPスタイル [#s05828c0]
-[[Windows FormをXPスタイルにする:http://www.atmarkit.co....
*Transparent, Click-Through Forms [#vbdb244d]
-http://www.codeproject.com/useritems/ClickThroughWindows...
*フォームの形を自由に変えたい [#gc30624b]
-http://www.codeproject.com/csharp/irregularshapedform.asp
-http://www.codeproject.com/useritems/Desktop_Sheep.asp
*フォームを閉じるときに閉じるのを中止したい [#le99190c]
-Closingイベントのハンドラで e.Cancel プロパティに true ...
*フォームの印刷 [#ibe5a9d5]
-http://www.atmarkit.co.jp/fdotnet/dotnettips/393printdoc...
*デスクトップの中央付近に表示させる方法 [#dbf72068]
int myWid = this.Width;
Rectangle rect = new Rectangle();
int deskWid = Screen.GetWorkingArea(rect).Width;
SetDesktopLocation( (deskWid - myWid )/2, this.Location....
*特定の色ではなく「システムでXXに使っている色」を指定した...
-SystemColors クラスをヘルプで参照されたし。
-似たようなものとして KnownColor 列挙体というのがあるんだ...
*コモンダイアログの使い方 [#y1b1066a]
-色設定ダイアログ使用例
ColorDialog f = new ColorDialog();
f.AllowFullOpen = true;
f.FullOpen = false;
f.AnyColor = true;
f.ShowHelp = false;
f.Color = ls[cnum].BackColor;
DialogResult rc = f.ShowDialog(this);
if(rc == DialogResult.OK )
{
SetColor(ls[cnum], f.Color );
}
-ファイルオープンダイアログの使用例
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Directory.GetCurrentDirectory();
ofd.Filter = "テキストファイル (*.txt)|*.txt|"
+ "すべてのファイル (*.*)|*.*";
ofd.FilterIndex = 2;
ofd.Multiselect = true;
DialogResult rc = ofd.ShowDialog(this);
if( rc == DialogResult.OK )
{
//hogehoge
}
-[[Customizing OpenFileDialog in .Net>http://www.codeproj...
-[[印刷のプロパティダイアログをダイレクトに表示したい>htt...
--OpenPrinterPropertiesDialog で検索のこと
-http://www.atmarkit.co.jp/fdotnet/csharptips/007dialog/0...
-OpenFileDialog, SaveFileDialogなどでヘルプを検索のこと
*描画のダブルバッファリング [#l3ec4618]
-[[CodeProjectのサンプル:http://www.codeproject.com/useri...
-http://www.microsoft.com/japan/msdn/vbasic/migration/tip...
*Formのデザイナ画面が開かなくなった [#hafeff01]
-なぜかコードとして認識されるときがある模様。対応方法は以...
--ソリューション・エクスプローラでxxx.csのプロパティを開く
--「ビルドアクション」プロパティが「コンパイル」になって...
--同プロパティをもう一度「コンパイル」にする
-これで直るはず。これでも直らなかったら .csprojをいじって...
*フォーム内のコントロールを列挙して何かをしたいとき [#yc9...
-http://jeanne.wankuma.com/tips/form/findcontrol.html
-Controls[<コントロール名>] で1階層下のコントロールを取...
Public Shared Function FindControl(ByVal hParent As Cont...
' hParent 内のすべてのコントロールを列挙する
For Each hControl As Control In hParent.Controls
' 列挙したコントロールにコントロールが含まれてい...
If hControl.HasChildren = True Then
Dim hFindControl As Control = FindControl(hCo...
' 再帰呼び出し先でコントロールが見つかった場...
If Not hFindControl Is Nothing Then
Return hFindControl
End If
End If
' コントロール名が合致した場合はそのコントロール...
If hControl.Name = stName Then
Return hControl
End If
Next hControl
End Function
*ドッキングフォームを使いたい [#kea4b687]
-[[Dobon.NET .NETでDocking Windowを使う:http://dobon.net/...
-[[Magic Docking:http://www.codeproject.com/cs/miscctrl/m...
*Formの位置をタスクバーの場所とサイズを考慮して決めたい [...
-SetDesktopLocation メソッドを使ってデスクトップ座標で指...
-デスクトップ座標とは、タスクバーを除外した画面の作業領域
-http://jeanne.wankuma.com/tips/form/11-desktoplocation.h...
*デフォルトボタンの設定 [#q4703d3b]
-親となるダイアログのAcceptButtonプロパティにそのボタンを...
*フォームのサイズ変更範囲の設定 [#s00a62b9]
-http://www.atmarkit.co.jp/fdotnet/dotnettips/238winlimit...
終了行:
→[[.NETプログラミング]]
#contents
*Webサイト [#sd7a34c8]
-[[Working with .NET windows Forms:http://www.only4gurus....
*Tips [#b7e75c96]
-[[英語OSでフォームやボタン位置がずれる問題>http://bbs.wa...
--自動スケーリング機能が働いているため。フォームのAutoSca...
--[[フォームの自動スケーリングについて>http://msdn2.micro...
--※フォームでMaximumSizeを設定していると、AutoScaleをTrue...
-[[Creating a Splash Screen that runs without a message p...
-[[Windowsフォームの入力チェックを効率化する>http://codez...
--ErrorProviderの紹介
*フォームの強制前出し [#m090ef3a]
-あんまり無闇にこれやると行儀が悪いしウザいので注意
using System.Runtime.InteropServices; //<-これ必要
[DllImport("USER32.DLL", CharSet=CharSet.Auto)]
private static extern int ShowWindow(
IntPtr hWnd,
int nCmdShow
);
[DllImport("USER32.DLL", CharSet=CharSet.Auto)]
private static extern bool SetForegroundWindow(
IntPtr hWnd
);
private const int SW_NORMAL = 1;
/// ---------------------------------------------------...
/// <summary>
/// 同名のプロセスが起動中の場合、メイン ウィンドウ...
/// <returns>
/// 既に起動中であれば true。それ以外は false。</re...
/// ---------------------------------------------------...
public static bool ShowPrevProcess()
{
Process hThisProcess = Process.GetCurrentProcess();
Process[] hProcesses = Process.GetProcessesByName(hThi...
int iThisProcessId = hThisProcess.Id;
foreach (Process hProcess in hProcesses)
{
if (hProcess.Id != iThisProcessId)
{
ShowWindow(hProcess.MainWindowHandle, SW_NORMAL);
SetForegroundWindow(hProcess.MainWindowHandle);
return true;
}
}
return false;
}
*フォームのカスタムペイント [#sab2728e]
-[[Google Talk Window Form>http://www.codeproject.com/cs/...
*XPスタイル [#s05828c0]
-[[Windows FormをXPスタイルにする:http://www.atmarkit.co....
*Transparent, Click-Through Forms [#vbdb244d]
-http://www.codeproject.com/useritems/ClickThroughWindows...
*フォームの形を自由に変えたい [#gc30624b]
-http://www.codeproject.com/csharp/irregularshapedform.asp
-http://www.codeproject.com/useritems/Desktop_Sheep.asp
*フォームを閉じるときに閉じるのを中止したい [#le99190c]
-Closingイベントのハンドラで e.Cancel プロパティに true ...
*フォームの印刷 [#ibe5a9d5]
-http://www.atmarkit.co.jp/fdotnet/dotnettips/393printdoc...
*デスクトップの中央付近に表示させる方法 [#dbf72068]
int myWid = this.Width;
Rectangle rect = new Rectangle();
int deskWid = Screen.GetWorkingArea(rect).Width;
SetDesktopLocation( (deskWid - myWid )/2, this.Location....
*特定の色ではなく「システムでXXに使っている色」を指定した...
-SystemColors クラスをヘルプで参照されたし。
-似たようなものとして KnownColor 列挙体というのがあるんだ...
*コモンダイアログの使い方 [#y1b1066a]
-色設定ダイアログ使用例
ColorDialog f = new ColorDialog();
f.AllowFullOpen = true;
f.FullOpen = false;
f.AnyColor = true;
f.ShowHelp = false;
f.Color = ls[cnum].BackColor;
DialogResult rc = f.ShowDialog(this);
if(rc == DialogResult.OK )
{
SetColor(ls[cnum], f.Color );
}
-ファイルオープンダイアログの使用例
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Directory.GetCurrentDirectory();
ofd.Filter = "テキストファイル (*.txt)|*.txt|"
+ "すべてのファイル (*.*)|*.*";
ofd.FilterIndex = 2;
ofd.Multiselect = true;
DialogResult rc = ofd.ShowDialog(this);
if( rc == DialogResult.OK )
{
//hogehoge
}
-[[Customizing OpenFileDialog in .Net>http://www.codeproj...
-[[印刷のプロパティダイアログをダイレクトに表示したい>htt...
--OpenPrinterPropertiesDialog で検索のこと
-http://www.atmarkit.co.jp/fdotnet/csharptips/007dialog/0...
-OpenFileDialog, SaveFileDialogなどでヘルプを検索のこと
*描画のダブルバッファリング [#l3ec4618]
-[[CodeProjectのサンプル:http://www.codeproject.com/useri...
-http://www.microsoft.com/japan/msdn/vbasic/migration/tip...
*Formのデザイナ画面が開かなくなった [#hafeff01]
-なぜかコードとして認識されるときがある模様。対応方法は以...
--ソリューション・エクスプローラでxxx.csのプロパティを開く
--「ビルドアクション」プロパティが「コンパイル」になって...
--同プロパティをもう一度「コンパイル」にする
-これで直るはず。これでも直らなかったら .csprojをいじって...
*フォーム内のコントロールを列挙して何かをしたいとき [#yc9...
-http://jeanne.wankuma.com/tips/form/findcontrol.html
-Controls[<コントロール名>] で1階層下のコントロールを取...
Public Shared Function FindControl(ByVal hParent As Cont...
' hParent 内のすべてのコントロールを列挙する
For Each hControl As Control In hParent.Controls
' 列挙したコントロールにコントロールが含まれてい...
If hControl.HasChildren = True Then
Dim hFindControl As Control = FindControl(hCo...
' 再帰呼び出し先でコントロールが見つかった場...
If Not hFindControl Is Nothing Then
Return hFindControl
End If
End If
' コントロール名が合致した場合はそのコントロール...
If hControl.Name = stName Then
Return hControl
End If
Next hControl
End Function
*ドッキングフォームを使いたい [#kea4b687]
-[[Dobon.NET .NETでDocking Windowを使う:http://dobon.net/...
-[[Magic Docking:http://www.codeproject.com/cs/miscctrl/m...
*Formの位置をタスクバーの場所とサイズを考慮して決めたい [...
-SetDesktopLocation メソッドを使ってデスクトップ座標で指...
-デスクトップ座標とは、タスクバーを除外した画面の作業領域
-http://jeanne.wankuma.com/tips/form/11-desktoplocation.h...
*デフォルトボタンの設定 [#q4703d3b]
-親となるダイアログのAcceptButtonプロパティにそのボタンを...
*フォームのサイズ変更範囲の設定 [#s00a62b9]
-http://www.atmarkit.co.jp/fdotnet/dotnettips/238winlimit...
ページ名: