VC++实现编辑框输入提示效果
编辑框在第一次输入时最好给出一个虚拟的输入提示信息文本,这样的效果更佳友好。,我在编辑框添加灰色提示字(html+VC)一文中简单介绍了一些方法,但是效果欠佳。
原始的编辑框CEdit类没有这样的功能,我们可以通过继承来改造得到:https://www.codeproject.com/Articles/737/Dim-Edit-Control
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
/*|*\
|*| File: DimEditCtrl.h |*| |*| By: James R. Twine, TransactionWorks, Inc. |*| Copyright 2000, TransactionWorks, inc. |*| Date: Thursday, September 21, 2000 |*| |*| Notes: This Is The Implementation Of A "Dim Edit Control". |*| It Provides Visual Instructions Within The Edit |*| Control Itself. It Can Be Used To Indicate Special |*| Properties Of A Edit Control Used On A Crowded |*| Interface |*| |*| May Be Freely Incorporated Into Projects Of Any Type |*| Subject To The Following Conditions: |*| |*| o This Header Must Remain In This File, And Any |*| Files Derived From It |*| o Do Not Misrepresent The Origin Of This Code |*| (IOW, Do Not Claim You Wrote It) |*| |*| A "Mention In The Credits", Or Similar Acknowledgement, |*| Is *NOT* Required. It Would Be Nice, Though! :) \*|*/ #if !defined(AFX_DIMEDITCTRL_H__CF8D88FB_6945_11D4_8AC4_00C04F6092F9__INCLUDED_) #define AFX_DIMEDITCTRL_H__CF8D88FB_6945_11D4_8AC4_00C04F6092F9__INCLUDED_ #pragma once // ///////////////////////////////////////////////////////////////////////////// class CDimEditCtrl : public CEdit // Attributes // Operations void SetShowDimControl( bool bShow ); // Show Or Hide The Dim Control // Overrides // Implementation // Generated message map functions DECLARE_MESSAGE_MAP() void DrawDimText( void ); // Draw The Dim Text COLORREF m_crDimTextColor; // "Hard" Dim Text Color ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} #endif // !defined(AFX_DIMEDITCTRL_H__CF8D88FB_6945_11D4_8AC4_00C04F6092F9__INCLUDED_) |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
/*|*\
|*| File: DimEditCtrl.cpp |*| |*| By: James R. Twine, TransactionWorks, Inc. |*| Copyright 2000, TransactionWorks, inc. |*| Date: Thursday, September 21, 2000 |*| |*| Notes: This Is The Implementation Of A "Dim Edit Control". |*| It Provides Visual Instructions Within The Edit |*| Control Itself. It Can Be Used To Indicate Special |*| Properties Of A Edit Control Used On A Crowded |*| Interface |*| |*| May Be Freely Incorporated Into Projects Of Any Type |*| Subject To The Following Conditions: |*| |*| o This Header Must Remain In This File, And Any |*| Files Derived From It |*| o Do Not Misrepresent The Origin Of This Code |*| (IOW, Do Not Claim You Wrote It) |*| |*| A "Mention In The Credits", Or Similar Acknowledgement, |*| Is *NOT* Required. It Would Be Nice, Though! :) \*|*/ #include "stdafx.h" #include "DimEdit.h" #include "DimEditCtrl.h" #ifdef _DEBUG ///////////////////////////////////////////////////////////////////////////// CDimEditCtrl::CDimEditCtrl() : return; // Done! CDimEditCtrl::~CDimEditCtrl() BEGIN_MESSAGE_MAP(CDimEditCtrl, CEdit) ///////////////////////////////////////////////////////////////////////////// void CDimEditCtrl::PreSubclassWindow() SetShowDimControl( true ); // Default To Show The Dim Control return; // Done! void CDimEditCtrl::SetDimText( LPCTSTR cpDimText ) void CDimEditCtrl::SetShowDimControl( bool bShow ) BOOL CDimEditCtrl::Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, if( bCreated ) // If We Got Created void CDimEditCtrl::OnChange() if( !iLen ) // If No Text void CDimEditCtrl::OnSetfocus() void CDimEditCtrl::OnPaint() if( m_bShowDimText ) // If Showing Any Dim Text void CDimEditCtrl::DrawDimText( void ) GetClientRect( &rRect ); // Get Drawing Area dcDraw.SelectObject( (*GetFont()) ); // Use The Control's Current Font dcDraw.RestoreDC( iState ); // Restore The DC State return; // Done! BOOL CDimEditCtrl::OnEraseBkgnd(CDC *pDC) if( ( bStatus ) && ( m_bShowDimText ) ) // If All Good, And Showing Any Dim Text /* void CDimEditCtrl::OnLButtonDblClk(UINT nFlags, CPoint point) void CDimEditCtrl::SetDimOffset( char cRedOS, char cGreenOS, char cBlueOS ) m_bUseDimOffset = true; // Set The Flag return; // Done! void CDimEditCtrl::SetDimColor( COLORREF crColor ) return; // Done! void CDimEditCtrl::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) if( m_bUseDimOffset ) // If Using An Offset For The Dim Color m_crDimTextColor = RGB( GetRValue( crWindow ) + void CDimEditCtrl::OnKillfocus() if( !iLen ) // If No Text } |

VC++实现编辑框输入提示效果的更多相关文章
- 分享一个仅0.7KB的jQuery文本框输入提示插件
由于项目需要,找过几个jQuery文本框输入提示插件来用,但总是有不满意的地方,要么体积较大,要么使用不便,要么会出现把提示文字作为文本框的值的情况.于是我们自己的开发团队制作了这个最精简易用的输入提 ...
- Jquery实现文本框输入提示
一些用户体验好的表单都会在文本框里设置输入提示,文本框获取焦点时,提示内容消息,如果未输入,失去焦点时又会出现提示. 网上找到一个比较好用的控件jquery.inputDefault.js 使用方法: ...
- 转摘:ashx+jquery-autocomplete文本框输入提示功能Asp.net
引入所需文件 <script type="text/javascript" src="JS/jquery-1.8.2.min.js"></sc ...
- VC中编辑框更新SetDlgItemText()与UpdateData()的区别
SetDlgItemText(IDC_EDIT_RXDATA,m_strREData); //前一个是ID号,后一个是编辑框的成员变量 UpdateData(FALSE); 它们都能更新编辑框的 ...
- MFC 编辑框输入16进制字符串转换为16进制数或者10进制数据计算
1.编辑框添加变量,并选择变量类型为CString. 2. 使用“_tcstoul”函数将Cstring 类型转换为16进制/10进制数进行计算.
- MFC中 编辑框输入换行功能
首先修改编辑框的属性: Multiline 设为true , Auto HScroll 设为true , Auto VScroll 设为 true . 然后响应PreTranslateMessage( ...
- 仿造w3school的试一试功能,实现左侧编辑框,右侧效果页面
转自http://fhqllt.iteye.com/blog/836186 每次想快速测试页面效果的时候,特别是在学习前端代码的时候,就想到W3school的那个试一试功能,一直都是用他们那个在线的版 ...
- js搜索框输入提示(高效-ys8)
<style type="text/css"> .inputbox .seleDiv { border: 1px solid #CCCCCC; display: non ...
- jquery php 百度搜索框智能提示效果
这个程序是利用php+ajax+jquery 实现的一个仿baidu智能提示的效果,有须要的朋友能够下载測试哦. 代码例如以下 index.html文件,保保存成index.htm <!DOCT ...
随机推荐
- 使用VMware安装CentOS7步骤详情
准备资料: CentOS-7-x86_64-Everything-1611 点击下载CentOS 对,资料就这些 第一步. 点击文件 再点击新建虚拟机 第二步 .点击完新建虚拟机之后会跳出一个窗口 ...
- struts2漏洞-第一次入侵经历
这两天上数据库,老师给了我们一个网站,该网站是一个售花网站.是有一个师兄写的毕业设计.然后挂在内网,然后使用这个系统,然后分析网站,写个数据库设计的报告.简单的写了数据库作业后就闲来无事做,就想对这个 ...
- C#通用JSON帮助类
using System; using System.Data; using System.Text; using System.Collections.Generic; using System.R ...
- iOS-本地的推送
// // ViewController.m // 05-本地的推送 // // Created by hongqiangli on 2017/6/12. // #import "Vi ...
- GPIO实验(二)
=============第三个实验============用c语言轮流点亮3个LED=================== 1.crt0.S.text.global _start_start: ...
- USB设备驱动程序学习笔记(二)
一.usbmouse_as_key.c /* * drivers\hid\usbhid\usbmouse.c */ #include <linux/kernel.h>#include &l ...
- 【Unity笔记】一些Mecanim动画系统、状态机的参数细节
动画混合树Blend Tree调整动画片段的播放速度: 0 动画不播放 -1 动画倒着播放:如果只有“往前走”的动画,可以变成“往后走”动画 勾选动画是否镜像: 左右颠倒(挥左手变成挥右手) 过度条件 ...
- SpringMVC @ModelAttribute 详解
[@Controller]4 详解@ModelAttribute http://blog.sina.com.cn/s/blog_6d3c1ec601017q4p.html A.@ModelAttrib ...
- netfiler/iptables
一. 什么是netfilter netfilter is a set of hooks inside the Linux kernel that allows kernel modules to re ...
- javascript总述
一.JavaScript核心 一个完整的JavaScript应该由下列三个不同的部分组成. 1.核心(ECMAScript) 2.文档对象模型(DOM,Document Object Model) 3 ...