- 博客(23)
- 问答 (1)
- 收藏
- 关注
原创 获得磁盘驱动器号GetLogicalDriveStrings,HeapAlloc
::FindAllDrivers(){ CComboBox* Driver=(CComboBox*)GetDlgItem(IDC_DRIVER); DWORD dwNumBytesForDriveStrings;//实际存储驱动器号的字符串长度 HANDLE hHeap; LPSTR lp; CString strLogdrive; //获得实际存储驱动器号的字符串长度 dwN
2011-09-27 15:16:06 847
原创 运行一个实例
BOOL COnlyOneInstApp::InitInstance(){if (!FirstInstance())return FALSE;//已经有实例存在了,退出。。。BOOL COnlyOneInstApp::FirstInstance()
2011-09-27 14:43:53 425
原创 通知区域托盘
//图标句柄HICON hIcon;TCHAR szTip[] = _T("鼠标在图标上!");TCHAR szInfo[] = _T("通知气球内容!");TCHAR szInfoTitle[] = _T("通知气球标题!");HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(IDI_ICON1),RT_GROUP_IC
2011-09-27 14:32:20 1003
原创 复制 移动 与获取文件属性
CopyFileBOOL WINAPI CopyFile( _In_ LPCTSTR lpExistingFileName, _In_ LPCTSTR lpNewFileName, _In_ BOOL bFailIfExists);Mo
2011-09-27 13:48:08 579
原创 CFileFind遍历目录 查找 删除等
void BrowseDir(CString strDir){CFileFind ff;CString szDir = strDir;if(szDir.Right(1) != "\\")szDir += "\\";szDir += "*.*";BOOL res = ff.FindFile(szDir);while(res){res = ff.FindNextFile();
2011-09-26 22:20:00 2161
原创 FindResource,LoadResource
Updating ResourcesThe following example copies a dialog box resource from one executable file, Hand.exe, to another, Foot.exe, by following these steps:Use the LoadLibrary function to load the e
2011-09-26 15:45:26 1033
原创 获得操作系统信息,关机,重启
#include #pragma comment(lib, "user32.lib")#pragma comment(lib, "advapi32.lib")BOOL MySystemShutdown(){ HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process.
2011-09-25 22:34:53 511
原创 屏幕保护程序
CWnd::OnActivateThe framework calls this member function when a CWnd object is being activated or deactivated.afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized
2011-09-25 20:56:48 686
原创 在对话框上创建状态栏
static UINT indicators[] ={ID_SEPARATOR, // status line indicatorID_SEPARATOR,ID_SEPARATOR,ID_SEPARATOR};在OnCreate
2011-09-23 19:32:32 542
原创 下拉工具栏的设计
MainFrm.h中afx_msg void OnToolbarDropDown(NMHDR* pnmh, LRESULT* plRes);MainFrm.cpp中ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnToolbar
2011-09-22 17:53:05 582
原创 LoadLibrary,GetProcAddress
例子:该例子调用User32.dll里的SetWindowAttributes函数将窗体设为半透明SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE, GetWindowLong(this->GetSafeHwnd(),GWL_EXST
2011-09-17 19:32:51 1754
原创 GetSystemMetrics
例子:该例子获取各参数的值,没有菜单、工具栏、状态栏int i;i = GetSystemMetrics(SM_CLEANBOOT);//启动方式 0i = GetSystemMetrics(SM_CMONITORS);//显示器数目 1i = GetSystemMetrics(SM_CMOUSEBUTTONS);//鼠标上按键的数目 3i = GetSystemMetrics(S
2011-09-13 21:05:30 8045
原创 SetWorldTransform,SetGraphicsMode
例子:该例子将文字在新的体系中输出OnDraw()函数中XFORM xform;ZeroMemory(&xform, sizeof(XFORM));xform.eM11 = 1;xform.eM22 = 1;xform.eDx = 100;xform.eDy = 100;pDC->SetGraphicsMode(GM_ADVANCED);pDC->SetWorldTr
2011-09-13 10:46:55 3560
原创 CRng
CRgn类封装了一个Windows图形设备接口(GDI)区域。这一区域是某一窗口中的一个椭圆或多边形区域。要使用这个区域,你可以使用类CRgn的成员函数以及被定义为类CDC的成员函数的剪贴函数。例子:该例子利用两幅大小相同的位图,其中一幅为背景图片(IDB_BACK),其中一幅为掩码图片(IDB_MASK),通过一定的逻辑运算将背景图片中需要的不规则区域取出作为窗体。基于对话框
2011-09-13 08:59:47 1748
原创 CDialogBar
例子:该例子只能在经典MFC项目中运行,在vs2010中不行。新建对话框CMyDlgBar基于CDialogBar,选择WS_CHILD样式,无边框,若要停泊在左右边则调整好宽度,若要停泊在上下边则调整好宽度,否则会很难看。ControlBar在运行中并不能调整大小,它的初始大小是对话框的初始大小,尽管对话框的border可以选为resizing但是它只是在ControlBar的内部改变大小,
2011-09-12 13:33:57 1724
原创 CListCtrl
通常需要设计自己的listctrl(继承自CListCtrl)实现特定的功能如添加删除等。CListCtrl里有特定的消息以NM_前缀和LVN_前缀开头。通过响应这些消息来实现特定的功能。否则如果只用CListCtrl则这些消息响应没有地方添加。 CRect rect;LVCOLUMN lvc;lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEX
2011-09-11 20:35:54 4216
原创 位图的巧妙运算得到透明图片的效果
CBitmap bitmap;bitmap.LoadBitmap(IDB_BITMAP1);//载入底层位图BITMAP bmp;bitmap.GetBitmap(&bmp);int nWidth = bmp.bmWidth;int nHeight = bmp.bmHeight;CDC dcMem;dcMem.CreateCompatibleDC(pDC);dcMem.Sele
2011-09-09 16:58:38 1288
原创 GetWindow,GetWindowLong,SetWindowLong
例子:获得应用程序的标题名CString strCaption;CWnd*pWnd=AfxGetMainWnd()->GetWindow(GW_HWNDFIRST);if(pWnd==NULL)return;while(pWnd){if(pWnd->IsWindowVisible() &&pWnd->GetWindowTextLength() && !pWnd->GetOwne
2011-09-08 21:46:39 736
原创 窗体样式小结
主框架常用样式:WS_OVERLAPPED 0X0000 0000L具有title bar和border,也是子框架和对话框的样式WS_MAXIMIZEBOX 0X0001 0000L具有最大化按钮,子框架常用WS_MINIMIZEBOX 0X0002 0000L具有
2011-09-08 19:58:19 820
原创 剪切区域
相关函数BeginPath()EndPath()GetPath()SelectClipPath()SetPolyFillMode()存疑CloseFigure()WidenPath()The WidenPath function redefines t
2011-09-07 22:19:45 2084
原创 GetDeviceCaps获取与修改显示器属性
int pixelxperinch = dc.GetDeviceCaps(LOGPIXELSX);//每英寸水平逻辑像素数int pixelyperinch = dc.GetDeviceCaps(LOGPIXELSY);//每英寸垂直逻辑像素数int pixelx = dc.GetDeviceCaps(HORZRES);//水平像素总数int pixely = dc.GetDevice
2011-09-07 16:37:28 21310 1
原创 字体
typedef struct tagLOGFONT { // lf LONG lfHeight; LONG lfWidth; LONG lfEscapement; LONG lfOrientation; LONG lfWeight; BYTE
2011-09-07 16:30:32 1238
原创 获得窗体指针的办法FromHandle,WindowFromPoint
HWND hWnd = GetSafeHwnd();CWnd* pWnd = FromHandle(hWnd);CPoint point;GetCursorPos(&point);CWnd* pWnd = WindowFromPoint(point);//设置窗口的层次使其置顶局中显示SetWindowPos(&wndTopMost, 0, 0, 0, 0,
2011-09-07 11:40:22 1309
空空如也
如何获取主机中所有进程的udp连接的具体信息(远程IP:Port 收发字节数)
2014-12-14
TA创建的收藏夹 TA关注的收藏夹
TA关注的人