理论上探讨:可以设置只读模式的ComboBox SetReadOnly()不可实用
来源:互联网 发布:mac精确模式怎么退出 编辑:程序博客网 时间:2024/05/16 04:59
注意:此方法在于调整编辑框的父子关系,经测试,大部分情况下布局会出问题,因此只在理论上比较有趣,实践上不可实用
vc6.0工程文件,演示可以设置只读模式的ComboBox,可以设置只读属性,SetReadOnly()。
目前发现的问题是在应用了xp样式后,文字显示时隐时现。
http://download.csdn.net/detail/wwwwws/5841909
#if !defined(AFX_COMBOBOXX_H__BF360CE4_B6DE_4AB9_96D8_82598BC5A43F__INCLUDED_)#define AFX_COMBOBOXX_H__BF360CE4_B6DE_4AB9_96D8_82598BC5A43F__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000// ComboBoxX.h : header file///////////////////////////////////////////////////////////////////////////////// CComboBoxX windowclass CComboBoxX : public CComboBox{// Constructionpublic:CComboBoxX();// Attributespublic:HWND m_hEdit;// Operationspublic:// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CComboBoxX)protected:virtual void PreSubclassWindow();//}}AFX_VIRTUAL// Implementationpublic:virtual ~CComboBoxX();BOOL EnableWindow( BOOL bEnable = TRUE );BOOL SetReadOnly( BOOL bReadOnly = TRUE );// Generated message map functionsprotected://{{AFX_MSG(CComboBoxX)//}}AFX_MSGDECLARE_MESSAGE_MAP()};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_COMBOBOXX_H__BF360CE4_B6DE_4AB9_96D8_82598BC5A43F__INCLUDED_)
// ComboBoxX.cpp : implementation file//#include "stdafx.h"#include "ComboBoxX.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CComboBoxXCComboBoxX::CComboBoxX(){m_hEdit = NULL;}CComboBoxX::~CComboBoxX(){}BEGIN_MESSAGE_MAP(CComboBoxX, CComboBox)//{{AFX_MSG_MAP(CComboBoxX)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CComboBoxX message handlersvoid CComboBoxX::PreSubclassWindow() {// TODO: Add your specialized code here and/or call the base classCRect rect;// Get EditBox's handlem_hEdit = ::GetWindow( m_hWnd, GW_CHILD );// Get EditBox's size::GetWindowRect( m_hEdit, rect );GetParent()->ScreenToClient( rect );// Alter EditBox from child window to brother window::SetParent( m_hEdit, ::GetParent( m_hWnd ) );// Set EditBox's Z-order and its position in the parent client window::SetWindowPos( m_hEdit, m_hWnd, rect.left, rect.top, rect.Width(), rect.Height(), NULL );}BOOL CComboBoxX::SetReadOnly( BOOL bReadOnly ){ASSERT( ::IsWindow( m_hEdit ) );if ( ::IsWindowEnabled( m_hEdit ) ){CWnd::EnableWindow( !bReadOnly );::EnableWindow( m_hEdit, TRUE );return (BOOL)::SendMessage( m_hEdit, EM_SETREADONLY, bReadOnly, 0L );}elsereturn FALSE;}BOOL CComboBoxX::EnableWindow( BOOL bEnable ){ASSERT( ::IsWindow( m_hEdit ) );if ( bEnable == FALSE ){::EnableWindow( m_hEdit, FALSE );return CWnd::EnableWindow( FALSE );}else if ( ::IsWindowEnabled( m_hEdit ) == FALSE ){::EnableWindow( m_hEdit, TRUE );return ( ::GetWindowLong( m_hEdit, GWL_STYLE ) & ES_READONLY ) ? TRUE : CWnd::EnableWindow( TRUE );}elsereturn TRUE;}
- 理论上探讨:可以设置只读模式的ComboBox SetReadOnly()不可实用
- combobox设置不可输入
- jqery 用 readonly 设置easyui-combobox为只读的方法
- Easyui combobox设置不可编辑
- COMBOBOX的只读如何实现
- 具有只读属性的ComboBox
- 只读,必填,combobox不可写、高度自适应
- 只读,必填,combobox不可写、高度自适应
- 关于只读更新的探讨
- datagrid 设置combobox并设置不可编辑
- 理论上可以赚钱
- easyui textbox 设置只读不可编辑状态
- 理论上 Android可以处理 多个手指的触摸
- 理论上 Android可以处理 多个手指的触摸
- ComboBox 控件的加载设置可以影响速度哦
- Ext.NETMultiCombo下拉列表 设置它的只读属性Editable 为True 好像不可以到达 只读效果问题。
- Flex4 设置s:Combobox选项不可编辑
- 可以搜索的ComboBox----
- 百度MP3 安卓API接口
- SDP (Session Description Protocol)
- ubuntu 下rar解压工具安装方法
- python 函数不确定的参数
- SDJZU-LOL如何拯救小学生
- 理论上探讨:可以设置只读模式的ComboBox SetReadOnly()不可实用
- c++ primer 习题11.15
- 结构化数据和非结构化数据
- JAVA帮助文档全系列 JDK1.5 JDK1.6 JDK1.7 官方中英完整版下载
- SDJZU-电子钟
- POJ 3264 RMQ
- octave隐函数如何作图
- 知识库之volatile关键字
- 子集生成算法