乐之网站制作江苏国龙翔建设有限公司网站

diannao/2026/1/16 18:25:51/文章来源:
乐之网站制作,江苏国龙翔建设有限公司网站,seo是什么意思?,嘉定网站建设哪里好MFC 中#xff0c; ListBox 与 ComboBox 中的项在设置了高度的情况下如何实现文本的水平居中与垂直居中#xff1f;#xff1f;#xff1f;ListBox 与 ComboBox 中的数据均为动态添加文本内容含有数字、英文、中文void CMyComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemS…MFC 中 ListBox 与 ComboBox 中的项在设置了高度的情况下如何实现文本的水平居中与垂直居中ListBox 与 ComboBox 中的数据均为动态添加文本内容含有数字、英文、中文void CMyComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct){ASSERT(lpDrawItemStruct-CtlType  ODT_COMBOBOX);LPCTSTR lpszText  (LPCTSTR) lpDrawItemStruct-itemData;ASSERT(lpszText ! NULL);CDC dc;dc.Attach(lpDrawItemStruct-hDC);// Save these value to restore them when done drawing.COLORREF crOldTextColor  dc.GetTextColor();COLORREF crOldBkColor  dc.GetBkColor();// If this item is selected, set the background color// and the text color to appropriate values. Erase// the rect by filling it with the background color.if ((lpDrawItemStruct-itemAction  ODA_SELECT) (lpDrawItemStruct-itemState   ODS_SELECTED)){dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));dc.FillSolidRect(lpDrawItemStruct-rcItem, ::GetSysColor(COLOR_HIGHLIGHT));}else{dc.FillSolidRect(lpDrawItemStruct-rcItem, crOldBkColor);}// Draw the text.dc.DrawText(lpszText,(int)_tcslen(lpszText),lpDrawItemStruct-rcItem,DT_CENTER|DT_SINGLELINE|DT_VCENTER);// Reset the background color and the text color back to their// original values.dc.SetTextColor(crOldTextColor);dc.SetBkColor(crOldBkColor);dc.Detach();}只能自绘。。。具体应用的时候我们往往不能满足于MFC提供的标准功能这种情况下我们一般会对控件进行重载定制对于ComboBox自然也不例外。不过ComboBox略显复杂它本身还包括子控件要想完全重载就要对这些子控件同样进行定制。有经验的朋友一定知道这个时候我们需要对这些子控件进行子类化用我们自己的类去代替。微软同样为我们想到了这一点在上文提到的链接中介绍说如果要重载ComboBox可以通过一篇文章《How to subclass CListBox and CEdit inside of CComboBox》介绍的方法来实现。这篇文章用的方法是通过OnCtlColor来实现对子控件的子类化的应该说这个方法很巧妙但并不优雅而且文章中也提到这个方法必须在ComboBox至少绘制一次的基础上才能起作用对于一些要求在这之前就要实现替换的需求并不适用文章相关原文如下Note that for subclassing to occur, the dialog box must be painted at least once. There are cases when the dialog box doesnt paint at all (for example, closing the dialog box before it is displayed, hidden dialog boxes). This method may not be suitable when access to the subclassed windows are needed in these cases.那么有什么更好的方法实现ComboBox对其子控件的子类化么本文就是要解决这个问题。要实现子类化其实只要解决一个问题那就是过去要子类化的控件的句柄。我们知道ComboBox的信息都封装到了COMBOBOXINFO这个结构中通过ComboBox的成员函数GetComboBoxInfo即可获取这些信息。看一下这个结构的定义[cpp] view plaincopy/** Combobox information*/typedef struct tagCOMBOBOXINFO{DWORD cbSize;RECT rcItem;RECT rcButton;DWORD stateButton;HWND hwndCombo;HWND hwndItem;HWND hwndList;} COMBOBOXINFO, *PCOMBOBOXINFO, *LPCOMBOBOXINFO;我们发现hwndItem和hwndList应该就是我们想要的。然后我们要为子类化选择一个合适的时间对于控件来说在PreSubclassWindow函数中处理再合适不过了。这样我们就很好的解决了子类化的途径和时机的问题动手试一下吧我重载重载了CComboBox做了测试为了验证子类化是否成功我没有对ComboBox进行初始化而是通过子类化的新控件完成的核心代码如下[cpp] view plaincopyvoid CExComboBox::PreSubclassWindow(){CComboBox::PreSubclassWindow();COMBOBOXINFO    comboInfo;//获取控件信息comboInfo.cbSize sizeof(COMBOBOXINFO);GetComboBoxInfo(comboInfo);//子类化编辑框if(comboInfo.hwndItem ! NULL){m_editReplace.SubclassWindow(comboInfo.hwndItem);m_editReplace.SetWindowText(_T(编辑框已被子类化));}//子类化列表框if(comboInfo.hwndList ! NULL){m_listboxReplace.SubclassWindow(comboInfo.hwndList);m_listboxReplace.AddString(_T(列表框已被子类化));}}运行程序成功实现目的。我整理了一个小例子有兴趣的朋友可以下载研究一下不过大家也能看得出来功能和实现都比较简单所以其实这个实例的价值也不是很大。个人认为这个方案相对来说比较合理对于动态创建的控件可通过OnCreate函数来完成子类化。找到了合理的子类化途径我们也就可以更好的对ComboBox做自绘和扩展以实现更加丰富的功能。Following is a owner drawn Combo Box which will be filled with the names of the fonts.. And each entry is in same font as selected. This is something similar to the one in Netscape 4.x font selector.This is pretty simple. All it does is to enumerate the fonts and store the LOGFONTs in the Item data. and when the painting is to be done, takes the value from the Item data and paints the item..It has a very nice effect.. Since this does only the font names, you might need another combobox for the sizes..Post-Migration Risks of Office 365 Download NowYou can also set the colors for the highlight and normal..To use this, Create a ComboBox in your Resource Editor, Set the Owner draw to Variable and check the Has strings.Then, In the OnInitDialog () or OnInitialUpdate() call the function FillFonts (). Thats it.. You have got your fonts in the Combo box. To get the selected font, Use GetSelFont () with LOGFONT as the argument. this argument will be filled in upon return.P.S:If you make the ComboBox to be a Drop down List then the edit window (actually the static control window) will hav the name in the same font as selected.. Otherwise, it will be in the dialog boxs font..//*************************************************************************//CCustComboBox.h#if !defined(AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_)#define AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_#if _MSC_VER 1000#pragma once#endif // _MSC_VER 1000// CustComboBox.h : header file///////// CCustComboBox windowtypedef enum {FONTS} STYLE;      //Why have I enumerated, Cos, Maybe I might want something other than Fonts hereclass CCustComboBox : public CComboBox{// Constructionpublic:CCustComboBox();CCustComboBox (STYLE);// Attributespublic:void SetHilightColors (COLORREF hilight,COLORREF hilightText){m_clrHilight hilight;m_clrHilightText hilightText;};void SetNormalColors (COLORREF clrBkgnd,COLORREF clrText){m_clrNormalText clrText;m_clrBkgnd clrBkgnd;};static BOOL CALLBACK EnumFontProc (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData);void FillFonts ();int  GetSelFont (LOGFONT);// Operationspublic:// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CCustComboBox)public:virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);protected:virtual void PreSubclassWindow();//}}AFX_VIRTUAL// Implementationpublic:virtual ~CCustComboBox();// Generated message map functionsprotected:STYLE m_enStyle;COLORREF m_clrHilight;COLORREF m_clrNormalText;COLORREF m_clrHilightText;COLORREF m_clrBkgnd;BOOL m_bInitOver;void DrawDefault (LPDRAWITEMSTRUCT);void DrawFont(LPDRAWITEMSTRUCT);void InitFonts ();//{{AFX_MSG(CCustComboBox)afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);afx_msg void OnDestroy();//}}AFX_MSGafx_msg   long OnInitFonts (WPARAM, LPARAM);DECLARE_MESSAGE_MAP()};///////{{AFX_INSERT_LOCATION}}// Microsoft Developer Studio will insert additional declarations immediately before the previous line.#endif //!defined(AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_)//**************************************************************************// CustComboBox.cpp : implementation file//#include stdafx.h#include CustComboBox.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] __FILE__;#endif#define WM_INITFONTS          (WM_USER 123)//I chose 123 cos nobody might use the same exact number.. I can improve this by use RegisterWindowMessage../////// CCustComboBox//Initial values of the text and highlight stuffCCustComboBox::CCustComboBox(){m_enStyle FONTS;m_clrHilight GetSysColor (COLOR_HIGHLIGHT);m_clrNormalText GetSysColor (COLOR_WINDOWTEXT);m_clrHilightText GetSysColor (COLOR_HIGHLIGHTTEXT);m_clrBkgnd GetSysColor (COLOR_WINDOW);m_bInitOver FALSE;}CCustComboBox::CCustComboBox (STYLE enStyle){m_enStyle enStyle;m_clrHilight GetSysColor (COLOR_HIGHLIGHT);m_clrNormalText GetSysColor (COLOR_WINDOWTEXT);m_clrHilightText GetSysColor (COLOR_HIGHLIGHTTEXT);m_clrBkgnd GetSysColor (COLOR_WINDOW);m_bInitOver FALSE;}CCustComboBox::~CCustComboBox(){}BEGIN_MESSAGE_MAP(CCustComboBox, CComboBox)//{{AFX_MSG_MAP(CCustComboBox)ON_WM_CREATE()ON_WM_DESTROY()//}}AFX_MSG_MAPON_MESSAGE (WM_INITFONTS,OnInitFonts)END_MESSAGE_MAP()/////// CCustComboBox message handlersvoid CCustComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct){//I might want to add something else somedayswitch (m_enStyle){case FONTS:DrawFont(lpDrawItemStruct);break;}}//I dont need the MeasureItem to do anything. Whatever the system says, it staysvoid CCustComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct){}void CCustComboBox::DrawFont(LPDRAWITEMSTRUCT lpDIS){CDC* pDC CDC::FromHandle(lpDIS-hDC);CRect rect;TRACE0 (In Draw Font\n);// draw the colored rectangle portionrect.CopyRect(lpDIS-rcItem);pDC-SetBkMode( TRANSPARENT );if (lpDIS-itemState ODS_SELECTED){pDC-FillSolidRect (rect,m_clrHilight);pDC-SetTextColor (m_clrHilightText);}else{pDC-FillSolidRect (rect,m_clrBkgnd);pDC-SetTextColor (m_clrNormalText);}if ((int)(lpDIS-itemID) 0) // Well its negetive so no need to draw text{}else{CString strText;GetLBText (lpDIS-itemID,strText);CFont newFont;CFont *pOldFont;((LOGFONT*)lpDIS-itemData)-lfHeight 90; //9 point size((LOGFONT*)lpDIS-itemData)-lfWidth 0;newFont.CreatePointFontIndirect ((LOGFONT*)lpDIS-itemData);pOldFont pDC-SelectObject (newFont);pDC-DrawText(strText, rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE);pDC-SelectObject (pOldFont);newFont.DeleteObject ();}}void CCustComboBox::InitFonts (){CDC *pDC GetDC ();ResetContent (); //Delete whatever is thereEnumFonts (pDC-GetSafeHdc(),NULL,(FONTENUMPROC) EnumFontProc,(LPARAM)this);//Enumeratem_bInitOver TRUE;}BOOL CALLBACK CCustComboBox::EnumFontProc (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData){if (dwType TRUETYPE_FONTTYPE) //Add only TTF fellows, If you want you can change it to check for others{int index ((CCustComboBox *) lpData)-AddString(lplf-lfFaceName);LPLOGFONT lpLF;lpLF new LOGFONT;CopyMemory ((PVOID) lpLF,(CONST VOID *) lplf,sizeof (LOGFONT));((CCustComboBox *) lpData)-SetItemData (index,(DWORD) lpLF);}return TRUE;}int CCustComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct){if (CComboBox::OnCreate(lpCreateStruct) -1)return -1;// TODO: Add your specialized creation code hereif (m_enStyle FONTS){PostMessage (WM_INITFONTS,0,0);}return 0;}long CCustComboBox::OnInitFonts (WPARAM, LPARAM){InitFonts ();return 0L;}void CCustComboBox::OnDestroy(){if (m_enStyle FONTS){int nCount;nCount GetCount ();for (int i 0; i {delete ((LOGFONT*)GetItemData (i)); //delete the LOGFONTS actually created..}}// TODO: Add your message handler code hereCComboBox::OnDestroy();}void CCustComboBox::FillFonts (){m_enStyle FONTS;PostMessage (WM_INITFONTS,0,0); //Process in one place}int  CCustComboBox::GetSelFont (LOGFONT lf){int index GetCurSel ();if (index LB_ERR)return LB_ERR;LPLOGFONT lpLF (LPLOGFONT) GetItemData (index);CopyMemory ((PVOID)lf, (CONST VOID *) lpLF, sizeof (LOGFONT));return index; //return the index here.. Maybe the user needs it:-)}void CCustComboBox::PreSubclassWindow(){// TODO: Add your specialized code here and/or call the base class//Tried to do what Roger Onslow did for the button.. Did not work..?? Any RD guys around :-)}CommentsgoodPosted by xixihaha on 12/02/2010 05:50amso nice ,hahahReplyHow Can I do Dynamic Creation of a ComboBoxPosted by subbaraovnrt on 12/15/2004 07:59amIn a Dialog box I used one Push Button When I press that button New Combobox Dynamically created but the all font in that ComboBox all are same bold Arial.How my Dialog box behaves as static your implementation.ReplyHow to initalize the Font combobox after FillFonts()Posted by Legacy on 11/14/2001 12:00amOriginally posted by: Chris HambletonTo initalize the Font combobox after FillFonts(), simply change the PostMessage() calls to SendMessage().PostMessage() returns as soon as the message is posted (while the combobox is still empty), but SendMessage() returns only after the message has been handled (after the combobox has been filled).The reason youre currently unable to initialize the Font combobox is because youre calling SetCurSel() / SetString() on a combobox thats currently empty.Hope this helps!!ReplyHow do you intialize the editor box?Posted by Legacy on 11/05/2001 12:00amOriginally posted by: ButchGreat.But how do you initialize the editor box portion of the combo to say a default font selection?Thanks.Reply!!!Posted by Legacy on 07/11/2001 12:00amOriginally posted by: Chethana SastryThis is great. I could finish a weeks work in just 15 mins!Thanks!I have a problem though...If i say SetCurSel(0) it fails and returns -1Have you encountered the same problem? If so, what is the solution?ReplysuperPosted by Legacy on 02/08/2001 12:00amOriginally posted by: pierresuper!!its worksReplyGreat !Posted by Legacy on 05/01/2000 12:00amOriginally posted by: Ergin SalihThis is wonderful, it is easily modified to work off a listof font objects.Exactly what I wanted.Thanks

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/91337.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

上海做网站 公司有哪些辽宁建设工程信息网新域名

SSL证书如果不及时更新,可能会带来以下问题: 1.影响体验和信誉: - 如果你的网站SSL证书过期了,现在大部分浏览器都会提醒用户这个网站的安全证书已经失效。这就很可能让用户觉得你的网站不太安全,不敢继续浏览&#x…

企业案例网站免费cms内容管理系统

背景:考虑到用户的不同需求,图像编辑是一项实用而富有挑战性的任务,其中最困难的部分之一是准确描述编辑后的图像应该是什么样子。 创新点:在本文作者提出了一种新的编辑形式,称为模仿编辑,以帮助用户更方…

论坛型网站 建站宣传册设计及网站建设

前言 Vue CLI是Vue.js项目的官方脚手架,基于Node.js与Webpack构建。安装Vue CLI前需确保Node.js已安装,随后通过npm全局安装。Vue CLI能迅速创建和管理Vue.js项目,提升开发效率。而Webpack则负责资源打包,通过配置文件管理依赖、插…

荥阳市建设局 网站展馆设计收费标准

使用查询语句的时候,经常要返回前几条或者中间某几行数据,这个时候怎么办呢?不用担心,mysql已 经为我们提供了这样一个功能。 SELECT*FROMtableLIMIT [offset,]rows |rows OFFSET offsetLIMIT 子句可以被用于强制 SELECT 语句返回…

pc端与手机端网站开发的区别手机制作公章的软件

DefaultListableBeanFactory源码分析文章目录 一、概述 二、关键结构与存储 Bean定义的存储结构ConcurrentHashMap的使用和意义 三、核心功能解析 四、总结 DefaultListableBeanFactory源码分析 一、概述 DefaultListableBeanFactory 是 Spring 框架中的一个核心类&#xff…

有高并发,高访问量网站开发兰州优化网站公司

目录 部署模式概述 1. Local Mode 2. Standalone Mode 3. YARN Mode 4. Mesos Mode 5. Kubernetes Mode 部署模式选择 部署模式概述 Apache Spark支持多种部署模式,这些模式决定了如何在集群上启动和运行你的Spark应用程序。以下是Spark支持的主要部署模式&a…

网站建站平台大学生网站模板

在开发高性能的C应用中,数据库操作的效率往往成为一个瓶颈。传统的同步数据库操作在等待数据库响应时会阻塞程序的执行,导致整体性能下降。为了解决这个问题,异步操作成为了一个重要的技术手段。 本文将详细介绍如何在C中使用MySQL的异步接口…

wordpress 插件下载站怎么做网站文字优化

跳跳! 题目描述 你是一只小跳蛙,你特别擅长在各种地方跳来跳去。 这一天,你和朋友小 F 一起出去玩耍的时候,遇到了一堆高矮不同的石头,其中第 i i i 块的石头高度为 h i h_i hi​,地面的高度是 h 0 …

手机网站版面设计机械代加工厂家

http://api.map.baidu.com/lbsapi/creatmap/index.html转载于:https://www.cnblogs.com/qinqiu/p/4476747.html

广告在什么网站做网站空间如何使用

Deep networks Deep Learning and Unsupervised Feature Learning Tutorial Solutions 深度网络的优势 比单层神经网络能学习到更复杂的表达。不同层的网络学习到的特征是由最底层到最高层慢慢上升的。比如在图像的学习中,第一个隐含层网络可能学习的是边缘特征&am…

免费网站友情链接深圳网站建设平台

目录: 单例模式在类中实现装饰器批量装饰实现单例模式 ,且不丢失类型提示限制实例个数 1.重写__new__方法实现多线程情况下的单例模式 用new方法实现单例模式 import time, threadingclass Singleton:"""单例模式————最多只允许创…

知名网站建设加工百度指数可以查询多长时间的

当你掌握Java语言到了一定的阶段,或者说已经对Java的常用类和API都使用的行云流水。你会不会有一些思考?比如,这个类是如何设计的?这个方法是怎么实现的?接下来的一系列文章,我们一起学习下Java的一些常见类…

做企业公示的数字证书网站百度搜索排名怎么收费

在我的上一篇博客《Java JDBC学习实战(一): JDBC的基本操作》中,简要介绍了jdbc开发的基本流程,并详细介绍了Statement和PreparedStatement的使用:利用这两个API可以执行SQL语句,完成基本的CURD…

生产企业做网站有用吗网站百度不到

商业竞争激烈,品牌不仅是企业的标志和形象,更是其核心价值和竞争力的体现。然而,企业在品牌推广过程中面临着诸多如缺乏有效的渠道管理、品牌形象模糊以及竞争激烈的市场环境等。这些阻碍着企业的品牌发展和市场占有率的提升。本文将通过企业…

高性能网站建设进行指南深圳vi设计公司全力设计

如果您正在使用Maven构建Java项目,可能是在Eclipse中,或者是通过运行mvn install在命令提示符下构建的,并且构建失败并显示诸如“无效的目标发行版:1.7”或“无效的目标发行版:1.8”之类的错误,那么您来了到…

网站的面包屑怎么做的东莞网页平面设计

刷题建议 刷题建议与debug 代码随想录目前基本都有了视频讲解,一定要先看视频,事半功倍。写博客,将自己的感悟沉淀下来,不然会忘大家提问的时候,记得要把问题描述清楚,自己在哪一步遇到了问题&#xff0c…

文件外链生成网站王也踏青

题面 最小支配集全集-最大独立集 所以先把点权改成正无穷/负无穷来保证强制选/不选某个点到独立集里&#xff0c;然后变成了洛谷的动态DP模板 GTMDNOIP2018ZTY 1 #include<stack>2 #include<cstdio>3 #include<cstring>4 #include<algorithm>5 using n…

网站如何做聚合页面游戏音效设计师培训

<base href>就是指网页里面的相对链接 的前缀url&#xff0c;如在<head></head>部分定义了此链接为http://ent.sina.com.cn/ &#xff0c;那么下面的<a hrefaaa.html></a>代表http://ent.sina.com.cn/aaa.html 这个标签的用处是解决编程时候的相…

广州做网站要多少钱网站建设的作业模板

一、前言 大家好&#xff0c;这里是白泽。有一些同学提问&#xff0c;希望在自己的简历上增加一些有含金量的项目经历&#xff0c;最好能够去参与一些开源项目的开发&#xff0c;但由于对一个庞大的开源项目缺乏认知&#xff0c;难以着手。同时也担心自己能力不足&#xff0c;…

网站模板 音乐济南建设工程交易网

SMB简介&#xff1a; SMB&#xff08;Server Message Block&#xff09;(*nix平台和Win NT4.0又称CIFS)协议是Windows平台标准文件共享协议&#xff0c;Linux平台通过samba来支持。SMB最新版本v3.0&#xff0c;在v2.0基础上针对WAN和分布式有改进。 建议使用原版wind…