ふ 流浪の日々

日々流されてます

ホーム 連絡をする 同期する ( RSS 2.0 ) Login
投稿数  72  : 記事  0  : コメント  1365  : トラックバック  34

ニュース




書庫

日記カテゴリ

前回(【MFC】CMFCButtonお試し)より、ほぼ一ヶ月ぶりのお試し・・・微妙に忙しいのか、単なるサボリなのかは神のみぞ知るということで。。。

 

[TestMaskEdit.zip](730kb) ※とりあえず手元にあるXPのみ動作確認。

TestMaskEdit

本日はこれまたお気軽な[CMFCMaskedEdit]クラスを試してみましょう。

 

エディットボックスで入力制限・・・なんてのはよくある話ですが、今までポチポチ自前で実装してたのが楽になるかと思います。

# よく解らない変なルールに対応するために結局自前で実装・・・なんて方もいるとは思いますが。。。

 

 

使い方はそんなに難しくなくて、

2. Call the CMFCMaskedEdit::EnableMask method to specify the mask.

3. Call the CMFCMaskedEdit::SetValidChars method to specify the list of valid characters.

4. Call the CMFCMaskedEdit::SetWindowText method to specify the default text for the masked edit control.

5. Call the CMFCMaskedEdit::GetWindowText method to retrieve the validated text.

If you do not call one or more methods to initialize the mask, valid characters, and default text, the masked edit control behaves just as the standard edit control behaves.

2.CMFCMaskedEdit::EnableMask でマスク定義

3.CMFCMaskedEdit::SetValidChars で入力可の文字定義

4.CMFCMaskedEdit::SetWindowText でデフォルトの表示を定義

5.CMFCMaskedEdit::GetWindowText で入力可能な文字で構成された文字列を取得

で、マスク定義やら入力かの文字定義やらデフォルト表示やらをちゃんと呼ばないと、ふつーのエディットコントロールと同様の動きをする、そうです。

 

※使えるマスク値はこんなかんじ
D 数値
d 数値orスペース
+ + or - or スペース
C アルファベット
c アルファベット+スペース
A アルファベット+数値
a アルファベット+数値+スペース
* 表示可能な文字

 

ウイザードでダイアログベースのアプリを作って、ぺこぺこコントロールを張ってOnInitDialog()に以下をしこんでテストテスト。。。

// マスク①
// (1)アルファベットのみ (2)フォーマット指定

m_MaskedEdit1.EnableMask(L" CCCCCCCCCC ",L"[__________]");  

// wankuma を入力可能な文字に指定

m_MaskedEdit1.SetValidChars(L"wankuma");                   

// デフォルトの表示セット

m_MaskedEdit1.SetWindowText(L"[wankumawan]");               

// マスク②
// (1)数値のみ (2)フォーマット指定

m_MaskedEdit2.EnableMask(L"       dddd dddd ",L"[DIGIT:____-____]");   

// 入力可能文字指定無し ※ただし、入力可能なのは結局数値のみ

m_MaskedEdit2.SetValidChars(NULL);                                      

// デフォルトの表示セット           

m_MaskedEdit2.SetWindowText(L"[DIGIT:____-____]");

                       

// マスク③
// (1)数値のみ (2)フォーマット指定 (3)未入力を*にする

m_MaskedEdit3.EnableMask(L" ddd ddd ",L"[___.___]",L'*');      

// 入力可能文字指定無し ※ただし、入力可能なのは結局数値のみ

m_MaskedEdit3.SetValidChars(NULL);                   

// デフォルト表示のセット

m_MaskedEdit3.SetWindowText(L"[***.***]");                       

 

なんとなーく、MFC使いの人には解ってもらえたと思います。

 

 

では、また次回!ほげほげ。

mug_dd

投稿日時 : 2008年9月30日 15:21

コメント

# re: 【MFC】CMFCMaskedEditお試し 2008/09/30 15:34 aetos(旧シャノン)
サンプルのDIGITのところが顔文字に見えます( ̄‐ ̄)フフフ

# re: 【MFC】CMFCMaskedEditお試し 2008/09/30 15:39
>aetosさん

>サンプルのDIGITのところが顔文字に見えます( ̄‐ ̄)フフフ

そんなことを言われたら、ソースのところも全部顔文字に見えてきました。。。


# ObacoCxUbD 2014/08/28 6:33 http://crorkz.com/
R7CPLJ Thanks a bunch for sharing this with all of us you really know what you're talking about! Bookmarked. Please also visit my site =). We could have a link exchange agreement between us!

# vsNbeqgMixCErBD 2014/08/30 21:12 http://facebook.com/pages/Flyttfirma-i-Stockholm/5
Well I really liked reading it. This tip procured by you is very useful for good planning.

# NYsffJKHSEPGtHCQ 2014/08/30 23:43 https://www.youtube.com/watch?v=CX-BtyBKO8Q
This site is mostly a stroll-via for all the data you needed about this and didn't know who to ask. Glimpse right here, and also you'll definitely discover it.

# DRVZQUNIxubXB 2014/08/31 3:28 http://www.nokiaandroidapps.com
I'm usually to blogging and i really recognize your content. The article has really peaks my interest. I'm going to bookmark your web site and keep checking for brand new information.

# VAZADNUThbViEOd 2014/09/08 20:28 http://janetnevins.wordpress.com/
This web site is mostly a walk-by way of for the entire data you wanted about this and didn't know who to ask. Glimpse right here, and also you'll definitely discover it.

# qjcJpNAVPNd 2014/09/09 9:27 http://vender-por-internet.net/luis-souto/
It is best to take part in a contest for top-of-the-line blogs on the web. I will recommend this site!

# NeqyIfwVjrkgUGrXgM 2014/09/10 20:32 http://www.canadanobis.com
This website online is mostly a walk-through for the entire data you wanted about this and didn't know who to ask. Glimpse right here, and you'll definitely discover it.

# CRBZUVlvgs 2014/09/11 20:30 http://www.ukessays.com
Fantastic site. Lots of helpful info here. I'm sending it to several pals ans also sharing in delicious. And certainly, thanks in your sweat!

# QVYuzDrwlAhzJZEiBY 2014/09/18 16:34 http://mikefrontier.info/story.php?id=32976
Iq4gCV I really enjoy the article.Really looking forward to read more. Fantastic.

Post Feedback

タイトル
名前
Url:
コメント