posts - 131, comments - 12, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理


void DrawTitleBar(CDC *pDC);
void *****::DrawTitleBar( CDC *pDC )
{
HWND hWndNew;
hWndNew=GetSafeHwnd();
if (hWndNew)
{
CRect rectClient;
GetClientRect(&rectClient);
CDC* pDisplayMemDC=new CDC;
pDisplayMemDC->CreateCompatibleDC(pDC);
CBitmap *pBitmap=new CBitmap;
BITMAP bm;
CRect rtWnd;
GetWindowRect(&rtWnd);
//重绘标题栏左上角
pBitmap->LoadBitmap(IDB_JZ_ADDBTL);
pBitmap->GetBitmap(&bm);
pDisplayMemDC->SelectObject(pBitmap);
pDC->StretchBlt(0,0,52,29,pDisplayMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);//539
pBitmap->DeleteObject();
//重绘标题栏
pBitmap->LoadBitmap(IDB_JZ_NEWBTLBK);
pBitmap->GetBitmap(&bm);
pDisplayMemDC->SelectObject(pBitmap);
pDC->StretchBlt(rectClient.left+52,0,rectClient.right,29,pDisplayMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);//539
pBitmap->DeleteObject();
//重绘左边边框
pBitmap->LoadBitmap(IDB_JZ_BK);
pBitmap->GetBitmap(&bm);
pDisplayMemDC->SelectObject(pBitmap);
pDC->StretchBlt(0,29,4,rtWnd.Height(),pDisplayMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
pBitmap->DeleteObject();
//重绘右边边框
pBitmap->LoadBitmap(IDB_JZ_BK);
pBitmap->GetBitmap(&bm);
pDisplayMemDC->SelectObject(pBitmap);
pDC->StretchBlt(rtWnd.Width()-6,29,6,rtWnd.Height(),pDisplayMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
pBitmap->DeleteObject();
//重绘底部边框
pBitmap->LoadBitmap(IDB_JZ_BK);
pBitmap->GetBitmap(&bm);
pDisplayMemDC->SelectObject(pBitmap);
pDC->StretchBlt(0,rtWnd.Height()-4,rtWnd.Width(),4,pDisplayMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
pBitmap->DeleteObject();
ReleaseDC(pDisplayMemDC);
delete pDisplayMemDC;
delete pBitmap;
}
}

posted @ 2012-12-25 09:23 盛胜 阅读(1113) | 评论 (0)编辑 收藏

virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
挖空窗口某个区域函数
LRESULT *****::DefWindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
// TODO: 在此添加专用代码和/或调用基类
LRESULT lrst = CDialog::DefWindowProc(message, wParam, lParam);
if (!::IsWindow(m_hWnd))
{
return lrst;
}
//窗口的移动、重绘、非客户区重绘、非客户激活
if (message==WM_MOVE||message==WM_PAINT||message==WM_NCPAINT||message==WM_NCACTIVATE/* ||message == WM_NOTIFY*/)  
{  
CDC* pWinDC = GetWindowDC();
CRect rctBtn;
CRect rctWnd;
GetWindowRect(&rctWnd);
pWinDC->ExcludeClipRect(rctWnd.Width()-26,5,rctWnd.Width()-26+22,27);
if (pWinDC)  
DrawTitleBar(pWinDC); //边框重绘函数 
ReleaseDC(pWinDC);  
}
return lrst; 
//return CDialog::DefWindowProc(message, wParam, lParam);
}

posted @ 2012-12-25 09:21 盛胜 阅读(469) | 评论 (2)编辑 收藏


RECT的特点
  ----RECT既是个特别的数据结构,又是个函数,他的作用就是定义一个矩形区域对象,而作为函数使用时他能用两个属性(Tpiont型)指明区域范围,同时也可分解成四个单一的变量类型(Integer型),即:
  topleft:左上角坐标(Tpiont型变量);
  bottomright:右下角坐标(Tpiont型变量);
  topleft.x或left:左上角横坐标;
  topleft.y或top:左上角纵坐标;
  bottomright.x或right:右下角横坐标;
  bottomright.y或bottom:右下角纵坐标。
  ----例如,下面三种方法定义一个相同的RECT变量:
  Rect(10,10,110,210);
  topleft:=Piont(10,10);
  bottomright:=Point(110,210);
  left:=10;top:=10;right:=110;Bottom:=210;
  ----下面的代码在Form1窗体上定义一个RECT矩形并用红色填充:
  var
  NewRect: TRect;
  begin
  NewRect := Rect(20, 30, 50, 90);
  Form1.Canvas.Brush.Color := clRed;
  Form1.Canvas.FillRect(NewRect);
  end;

posted @ 2012-12-24 14:20 盛胜 阅读(286) | 评论 (0)编辑 收藏

http://hi.baidu.com/gildor/item/fca3243bf3133549033edc91
CImage与OpenCV兼容问题

CImage类和OpenCV中的某个类冲突,在配置了OpenCV后,如果创建CImage类,会有如下问题:
error C2872: 'CvvImage' : ambiguous symbol
        could be 'c:\program files\opencv\otherlibs\highgui\highgui.h(438) : CvvImage'
        or 'd:\program files\visual studio 8\vc\atlmfc\include\atlimage.h(68): ATL::CvvImage'

可以考虑修改OpenCV的代码,去掉其中对于CImage的定义。
打开\OpenCV\_make\opencv.sln工程
在OpenCV中,只有两处用到了CImage的定义,
一个是highgui.h line 438; 直接把#define注释掉。
另外一处是image.cpp,line 236 void CImage::DrawToHDC。
改为void CvvImage::

然后重新编译,把掉用opencv CImage的地方改为CvvImage就可以了。有可能有个别工程编不通,如果不是由于修改引起的就没有问题。

2.直接在 OpenCV头文件后
#undef CImage #include <atlimage.h>






opencv 2.0以后的版本

使用OpenCV   highgui.h中定义的CvvImage类可以很好的实现OpenCV和Windows MFC显示接口。由于CvvImage实在highgui.h头文件中声明的,因此如果程序中需要使用,则必须在开头包含头文件

  1. #include <highgui.h>  

CvvImage对应CImage宏:

  1. #define CImage CvvImage   

 

注意事项:

1.由于CImage太常见, 很容易造成冲突,因此建议不要使用该宏(可以直接删去此宏定义)。

2.参数中含有HDC(注:一种windows系统下定义的变量类型,用来描述设备描述表的句柄类型)类型的并不能保证移植到其他平台,例如Show/DrawToHDC等。 

       OpenCV 2.2.0版本中,CvvImage类不见了...为了能够继续使用这个类,下面把这个类的源代码贴出来,使用的时候将该代码加入到工程中便可以使用了。为了方便切换OpenCV的版本,这里用到了一些条件编译宏,来保证代码的灵活性。

代码见:

http://blog.csdn.net/raocong2010/archive/2011/01/17/6146158.aspx

posted @ 2012-12-24 14:06 盛胜 阅读(2234) | 评论 (1)编辑 收藏

//欢迎界面背景
  CRect ctrlRect;
  GetClientRect(&ctrlRect);
  //this->GetWindowRect(ctrlRect);
  CRect rec(0, 93,ctrlRect.right,ctrlRect.bottom-25);
  CDC *pdc = GetDC();
  CPoint OldPoint; 
  OldPoint=pdc->GetBrushOrg();
  CBrush myBrush;
  CBitmap bmpbk;
  bmpbk.LoadBitmap(IDB_BK_WELCOME);
  pdc->SetBrushOrg(CPoint(0,0));
  myBrush.CreatePatternBrush( &bmpbk);
  pdc->FillRect(&rec, &myBrush);
  bmpbk.DeleteObject();

posted @ 2012-12-21 16:33 盛胜 阅读(314) | 评论 (0)编辑 收藏

HWND m_SysDlgHwnd;                 m_SysDlgHwnd=GetSafeHwnd();
 
         extern HWND m_SysDlgHwnd;
LONG style = GetWindowLong(m_SysDlgHwnd,GWL_STYLE);
style &= ~WS_CLIPSIBLINGS ;
style &= ~WS_CLIPCHILDREN ;
SetWindowLong(m_SysDlgHwnd,GWL_STYLE,style);


extern HWND m_SysDlgHwnd;
LONG style = GetWindowLong(m_SysDlgHwnd,GWL_STYLE);
style = style | WS_CLIPSIBLINGS ;
style = style | WS_CLIPCHILDREN ;
SetWindowLong(m_SysDlgHwnd,GWL_STYLE,style);

posted @ 2012-12-21 16:08 盛胜 阅读(193) | 评论 (0)编辑 收藏

http://www.114la.com/other/rgb.htm
 

RGB颜色查询对照表

 

因为兼容性问题,色阶板功能只能在IE浏览器中运行

RGB颜色对照表

#FFFFFF#FFFFF0#FFFFE0#FFFF00
#FFFAFA#FFFAF0#FFFACD#FFF8DC
#FFF68F#FFF5EE#FFF0F5#FFEFDB
#FFEFD5#FFEC8B#FFEBCD#FFE7BA
#FFE4E1#FFE4C4#FFE4B5#FFE1FF
#FFDEAD#FFDAB9#FFD700#FFD39B
#FFC1C1#FFC125#FFC0CB#FFBBFF
#FFB90F#FFB6C1#FFB5C5#FFAEB9
#FFA54F#FFA500#FFA07A#FF8C69
#FF8C00#FF83FA#FF82AB#FF8247
#FF7F50#FF7F24#FF7F00#FF7256
#FF6EB4#FF6A6A#FF69B4#FF6347
#FF4500#FF4040#FF3E96#FF34B3
#FF3030#FF1493#FF00FF#FF0000
#FDF5E6#FCFCFC#FAFAFA#FAFAD2
#FAF0E6#FAEBD7#FA8072#F8F8FF
#F7F7F7#F5FFFA#F5F5F5#F5F5DC
#F5DEB3#F4F4F4#F4A460#F2F2F2
#F0FFFF#F0FFF0#F0F8FF#F0F0F0
#F0E68C#F08080#EEEEE0#EEEED1
#EEEE00#EEE9E9#EEE9BF#EEE8CD
#EEE8AA#EEE685#EEE5DE#EEE0E5
#EEDFCC#EEDC82#EED8AE#EED5D2
#EED5B7#EED2EE#EECFA1#EECBAD
#EEC900#EEC591#EEB4B4#EEB422
#EEAEEE#EEAD0E#EEA9B8#EEA2AD
#EE9A49#EE9A00#EE9572#EE82EE
#EE8262#EE7AE9#EE799F#EE7942
#EE7621#EE7600#EE6AA7#EE6A50
#EE6363#EE5C42#EE4000#EE3B3B
#EE3A8C#EE30A7#EE2C2C#EE1289
#EE00EE#EE0000#EDEDED#EBEBEB
#EAEAEA#E9967A#E8E8E8#E6E6FA
#E5E5E5#E3E3E3#E0FFFF#E0EEEE
#E0EEE0#E0E0E0#E066FF#DEDEDE
#DEB887#DDA0DD#DCDCDC#DC143C
#DBDBDB#DB7093#DAA520#DA70D6
#D9D9D9#D8BFD8#D6D6D6#D4D4D4
#D3D3D3#D2B48C#D2691E#D1EEEE
#D1D1D1#D15FEE#D02090#CFCFCF
#CDCDC1#CDCDB4#CDCD00#CDC9C9
#CDC9A5#CDC8B1#CDC673#CDC5BF
#CDC1C5#CDC0B0#CDBE70#CDBA96
#CDB7B5#CDB79E#CDB5CD#CDB38B
#CDAF95#CDAD00#CDAA7D#CD9B9B
#CD9B1D#CD96CD#CD950C#CD919E
#CD8C95#CD853F#CD8500#CD8162
#CD7054#CD69C9#CD6889#CD6839
#CD661D#CD6600#CD6090#CD5C5C
#CD5B45#CD5555#CD4F39#CD3700
#CD3333#CD3278#CD2990#CD2626
#CD1076#CD00CD#CD0000#CCCCCC
#CAFF70#CAE1FF#C9C9C9#C7C7C7
#C71585#C6E2FF#C67171#C5C1AA
#C4C4C4#C2C2C2#C1FFC1#C1CDCD
#C1CDC1#C1C1C1#C0FF3E#BFEFFF
#BFBFBF#BF3EFF#BEBEBE#BDBDBD
#BDB76B#BCEE68#BCD2EE#BC8F8F
#BBFFFF#BABABA#BA55D3#B9D3EE
#B8B8B8#B8860B#B7B7B7#B5B5B5
#B4EEB4#B4CDCD#B452CD#B3EE3A
#B3B3B3#B2DFEE#B23AEE#B22222
#B0E2FF#B0E0E6#B0C4DE#B0B0B0
#B03060#AEEEEE#ADFF2F#ADD8E6
#ADADAD#ABABAB#AB82FF#AAAAAA
#A9A9A9#A8A8A8#A6A6A6#A52A2A
#A4D3EE#A3A3A3#A2CD5A#A2B5CD
#A1A1A1#A0522D#A020F0#9FB6CD
#9F79EE#9E9E9E#9C9C9C#9BCD9B
#9B30FF#9AFF9A#9ACD32#9AC0CD
#9A32CD#999999#9932CC#98FB98
#98F5FF#97FFFF#96CDCD#969696
#949494#9400D3#9370DB#919191
#912CEE#90EE90#8FBC8F#8F8F8F
#8EE5EE#8E8E8E#8E8E38#8E388E
#8DEEEE#8DB6CD#8C8C8C#8B8B83
#8B8B7A#8B8B00#8B8989#8B8970
#8B8878#8B8682#8B864E#8B8386
#8B8378#8B814C#8B7E66#8B7D7B
#8B7D6B#8B7B8B#8B795E#8B7765
#8B7500#8B7355#8B6969#8B6914
#8B668B#8B6508#8B636C#8B5F65
#8B5A2B#8B5A00#8B5742#8B4C39
#8B4789#8B475D#8B4726#8B4513
#8B4500#8B3E2F#8B3A62#8B3A3A
#8B3626#8B2500#8B2323#8B2252
#8B1C62#8B1A1A#8B0A50#8B008B
#8B0000#8A8A8A#8A2BE2#8968CD
#87CEFF#87CEFA#87CEEB#878787
#858585#848484#8470FF#838B8B
#838B83#836FFF#828282#7FFFD4
#7FFF00#7F7F7F#7EC0EE#7D9EC0
#7D7D7D#7D26CD#7CFC00#7CCD7C
#7B68EE#7AC5CD#7A8B8B#7A7A7A
#7A67EE#7A378B#79CDCD#787878
#778899#76EEC6#76EE00#757575
#737373#71C671#7171C6#708090
#707070#6E8B3D#6E7B8B#6E6E6E
#6CA6CD#6C7B8B#6B8E23#6B6B6B
#6A5ACD#698B69#698B22#696969
#6959CD#68838B#68228B#66CDAA
#66CD00#668B8B#666666#6495ED
#63B8FF#636363#616161#607B8B
#5F9EA0#5E5E5E#5D478B#5CACEE
#5C5C5C#5B5B5B#595959#575757
#556B2F#555555#551A8B#54FF9F
#548B54#545454#53868B#528B8B
#525252#515151#4F94CD#4F4F4F
#4EEE94#4D4D4D#4B0082#4A708B
#4A4A4A#48D1CC#4876FF#483D8B
#474747#473C8B#4682B4#458B74
#458B00#454545#43CD80#436EEE
#424242#4169E1#40E0D0#404040
#3D3D3D#3CB371#3B3B3B#3A5FCD
#388E8E#383838#36648B#363636
#333333#32CD32#303030#2F4F4F
#2E8B57#2E2E2E#2B2B2B#292929
#282828#27408B#262626#242424
#228B22#218868#212121#20B2AA
#1F1F1F#1E90FF#1E1E1E#1C86EE
#1C1C1C#1A1A1A#191970#1874CD
#171717#141414#121212#104E8B
#0F0F0F#0D0D0D#0A0A0A#080808
#050505#030303#00FFFF#00FF7F
#00FF00#00FA9A#00F5FF#00EEEE
#00EE76#00EE00#00E5EE#00CED1
#00CDCD#00CD66#00CD00#00C5CD
#00BFFF#00B2EE#009ACD#008B8B
#008B45#008B00#00868B#00688B
#006400#0000FF#0000EE#0000CD
#0000AA#00008B#000080#000000

posted @ 2012-12-18 08:58 盛胜 阅读(673) | 评论 (0)编辑 收藏

     摘要: http://blog.chinaunix.net/uid-677314-id-379541.html摘在网上,对于编写程序可以作为参考。首先,包括头文件。#include <mysql/mysq.h>编译方法:$ gcc -I/usr/include/mysql -L/usr/lib/mysql myapp.c -o myapp  -lmysqlclient程序:...  阅读全文

posted @ 2012-12-06 17:42 盛胜 阅读(464) | 评论 (0)编辑 收藏

转载请注明出处谢谢:
http://www.cppblog.com/lanshengsheng/archive/2012/11/28/195760.html

 char m_otherdbpath[MAX_PATH];

HWND pathhWnd=GetSafeHwnd();
BROWSEINFO bi;
LPITEMIDLIST pidl;
bi.hwndOwner = this->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = m_otherdbpath;
bi.lpszTitle = "选择输出文件路径";
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = NULL;
bi.iImage = NULL;
if((pidl = SHBrowseForFolder(&bi)) != NULL)
{
if(SUCCEEDED(SHGetPathFromIDList(pidl, m_otherdbpath)))//得到文件夹的全路径,不要的话,只得本文件夹名
{
m_edit_dbotherpath.SetWindowText(m_otherdbpath);
}
}

posted @ 2012-11-28 11:34 盛胜 阅读(627) | 评论 (0)编辑 收藏

原文地址:http://blog.sina.com.cn/s/blog_5eb73de10100dt5l.html

 

 

在实际的应用中,可以用WM_CTLCOLOR 消息改变mfc中控件的颜色,比如现在就来改变一个static text的背景色和字体:

1. 在对话框的类中添加两个变量:

CBrush m_brush;
CFont m_font;

在OnInitDialog()函数中添加:

// TODO: 在此添加额外的初始化代码
m_font.CreatePointFont(150,"华文行楷");
m_brush.CreateSolidBrush(#00ff00);

 

2. 添加WM_CTLCOLOR 消息响应,添加的方法为:

     在对话框类中声明:afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) ;

    在消息映射中添加: ON_WM_CTLCOLOR()

     如:

      BEGIN_MESSAGE_MAP(CtestEnvDlg, CDialog)

      ON_WM_CTLCOLOR()
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

 

3. 添加响应函数:

HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(m_yourStatic.m_hWnd == pWnd->m_hWnd)
{
   pDC->SetBkColor(#00ff00);

   //pDC->SetTextColor(#ff0000);//文字色
   pDC->SelectObject(&m_font);
   return m_brush;
}
return hbr;
}

 HBRUSH CJuanZongAJAddCriminal::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO:  在此更改 DC 的任何属性
if (pWnd->GetDlgCtrlID() == IDC_STATIC)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(#dedede);
pDC->SetBkColor(#383838);
hbr = CreateSolidBrush(#383838);
}
if (nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetTextColor(#dedede);
pDC->SetBkColor(#14344d);
hbr = CreateSolidBrush(#14344d);
}

// TODO:  如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}

这样就可以改变static text的颜色和字体了

posted @ 2012-11-27 15:58 盛胜 阅读(833) | 评论 (0)编辑 收藏

仅列出标题
共14页: First 2 3 4 5 6 7 8 9 10 Last