MFC API小结

来源:互联网 发布:python 前五分钟 编辑:程序博客网 时间:2024/05/16 12:29

最近要用到MFC编程,windowsAPI感觉很多,总记不住,就把它们写下来:

CWnd::GetDlgCtrlID()
获取控件ID


AfxMessageBox
弹出消息对话框

 

MessageBox


LoadImage
加载bitmapiconcursor,返回各自的handle

 

GetObject HBITMAP来获取BITMAP数据结构,如:

HBITMAP hbmp = LoadImage( … );

BITMAP bmp;

GetObject(hbmp, sizeof(BITMAP), &bmp);

这样就能得到bmp
DeleteObject
DestroyCursorDestroyIconLoadImage用完后,删除各自的handle


CDialog::DoModal
弹出对话框,调用CDialog::OnOK();时退出对话框

 

CFileDialog::GetPathName 获取文件名的绝对路径


SendMessage
发送消息给指定对话框,如:
::SendMessage(::GetParent(this->m_hWnd), WM_RBUTTONUP, GetDlgCtrlID(), 0);
发送消息WM_RBUTTONUP给它的拥用者,参数1为自己的ID

 

想知道窗口有哪些消息,使用MFC ClassWizard,就可看到列出的对话框或者控件的消息。

 

CWnd:: Invalidate() 让对话框或者控件区域无效,当数据更新后需要更新UI的时候调用。

 

StretchDIBits 将一设备无关的bitmap数据copy到一个HDC

 

CClientDC::CClientDC  引用MSDN里的话:The CClientDC class is derived from CDC and takes care of calling the Windows functions GetDC at construction time and ReleaseDC at destruction time. This means that the device context associated with a CClientDC object is the client area of a window.也就是说调用下面的语句:

         CClientDC  pDC(this);

就能为当前的CWnd对象生成对应的DC,再调用:

         StretchDIBits(pDC,0,0,bmpWidth,bmpHeight,0,0,bmpWidth,bmpHeight,

                   lpSrcBits,lpBitmapInfo,DIB_RGB_COLORS,SRCCOPY);

就能将bitmap图片画到这个DC上(其中lpSrcBitslpBitmapInfobitmap图片的数据)。

 

CDC::GetPixel

 

 

CDialog::OnPaint()

 

CDialog::OnInitDialog()

CWnd::UpdateData

 

HWND current = ::GetFocus();

 

::GetWindowText(current, str, 100);

 

BITMAPFILEHEADER以及BITMAPINFOHEADER

 

CreateDIBSection

 

CreateCompatibleDC NULL为参数

 

BitBlt

 

DeleteDC

 

DeleteObject

 

SelectObject

 

GridCtrl API

 

ON_NOTIFY

 

DDX_GridControl

原创粉丝点击