cwnd.cpp

来自「bt848,bt878 a采集卡的探测」· C++ 代码 · 共 62 行

CPP
62
字号
#include "CWnd.hpp"
#include <assert.h>

CWnd& CWnd::operator=(CWnd& w) // note: Ownership is NOT passed when assigning!
{
	bool ret = Destroy();
	assert(ret);
	handle = w.handle;
	return *this;
}

bool CWnd::SetHWND(HWND h) 
{ 
	if (Destroy()) {
		handle = h;
		return true;
	}
	return false;
} 

bool CWnd::SetHWND(CWnd& father,int nID) 
{ 
	if (Destroy()) {
		handle = father.GetItem(nID).GetHWND() ; 
		return true;
	}
	return false;
}
	
bool CWnd::Create(DWORD dwExStyle, LPCTSTR ClassName, LPCTSTR WindowName, DWORD dwStyle,int x,int y,int Width,int Height,CWnd& Parent, CMenu& Menu, HINSTANCE Instance, LPVOID lpParam) 
{
	if (Destroy()) {
		handle = ::CreateWindowEx(dwExStyle,ClassName,WindowName, dwStyle,x,y,Width,Height,Parent.GetHWND(), Menu.GetHMENU(),Instance,lpParam);
		if (IsOpen()) {
			IsOwner = true;
			return true;
		}
	}
	return false;
}

bool CWnd::Destroy()
{
	if (IsOwner) {
		if (::DestroyWindow(handle)) {
			IsOwner = false;
			handle = NULL;
			return true;
		}
		return false;
	}
	return true;
}

CString CWnd::GetText()
{
	CString ret;
	int len = GetWindowTextLength(GetHWND())+1;
	ret.SetLen(len);
	ret.SetLen(::GetWindowText(GetHWND(),ret.Ptr(),len));
	return ret;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?