Exemple #1
0
BOOL  CWndImpl::MyRegisterClass()
{
	WNDCLASS     wndclass ;

	wndclass.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
	wndclass.lpfnWndProc   = CWndImpl::WndMsgProc ;
	wndclass.cbClsExtra    = 0 ;
	wndclass.cbWndExtra    = 0 ;
	wndclass.hInstance     = CWndImpl::GetInstance() ;
	wndclass.hIcon         = NULL;
	wndclass.hCursor       = NULL ;
	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
	wndclass.lpszMenuName  = NULL ;
	wndclass.lpszClassName = GetWindowClassName() ;

	//是否已经注册
	BOOL bRes = FALSE;
	if(::GetClassInfo(GetInstance(), GetWindowClassName(), &wndclass))
	{
		bRes = TRUE;
	}
	else
	{
		bRes =RegisterClass (&wndclass);
	}

	return bRes;
}
bool CWindowWnd::UnRegisterWindowClass()
{
	ATOM ret = ::UnregisterClass(GetWindowClassName(), CPaintManagerUI::GetInstance());
	DWORD dwError = GetLastError();
	ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
	return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Exemple #3
0
BOOL	NativeWindow::Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x /* = CW_USEDEFAULT */, int y /* = CW_USEDEFAULT */, int cx /* = CW_USEDEFAULT */, int cy /* = CW_USEDEFAULT */, HMENU hMenu /* = NULL */)
{
	BOOL created = FALSE;
	if (GetSuperClassName() != NULL)
	{
		if (!RegisterSuperClass())
		{
			return FALSE;
		}
	}
	else
	{
		if(!RegisterWindowClass())
		{
			return FALSE;
		}
	}

	hwnd_ = ::CreateWindowEx(dwExStyle, GetWindowClassName(), pstrName, dwStyle, x, y, cx, cy, hwndParent, hMenu, NULL, this);
	if (hwnd_ != NULL)
	{
		created = AfterCreated();
	}
	return created;
}
Exemple #4
0
    void WindowWnd::RegisterWindowClass()
    {
        WNDCLASS wc;
        ZeroMemory(&wc,sizeof(wc));
        wc.style = GetClassStyle();
        wc.lpfnWndProc =WindowManger::WndProc; //用自己的WndProc
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = SystemInfo::GetInstance()->GetProcessInstance();
        wc.hIcon = NULL;
        wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = NULL;
        wc.lpszMenuName = NULL;
        wc.lpszClassName = GetWindowClassName();

        ATOM ret = ::RegisterClass( &wc );

        DWORD err = ::GetLastError();
        assert( ret !=0  || err == ERROR_CLASS_ALREADY_EXISTS );

        if( ret == 0  && err != ERROR_CLASS_ALREADY_EXISTS)
        {
            THROW_EXCEPTION(YYUIException()<<UIErrorStr(_T("Call RegisterClassEx Failed! :")+FormatGetLastError(err)));
        }

    }
Exemple #5
0
    void WindowWnd::RegisterSuperClass()
    {
        //!!目前还不知道有什么用
        //功能是如下
        // Get the class information from an existing
        // window so we can subclass it later on...
        //为什么是ControlProc不明白
        WNDCLASSEX wc;
        ZeroMemory(&wc, sizeof(wc));
        wc.cbSize = sizeof(wc);
        if( !::GetClassInfoEx( NULL, GetSuperClassName() , &wc) )
        {
          /*  if( !::GetClassInfoEx(PaintManagerUI::GetInstance(),GetSuperClassName(),&wc))
            {
                THROW_EXCEPTION(YYUIException()<< UIErrorStr(_T("找不到Register Class Name"))); 
            }*/
        }
        m_OldWndProc = wc.lpfnWndProc;
        wc.lpfnWndProc = WindowWnd::ControlProc;
        wc.hInstance = SystemInfo::GetInstance()->GetProcessInstance();;
        wc.lpszClassName = GetWindowClassName();

        ATOM hr = ::RegisterClassEx(&wc);
        assert( hr !=0  || hr == ERROR_CLASS_ALREADY_EXISTS );

        if( hr == 0  && hr != ERROR_CLASS_ALREADY_EXISTS)
        {
            THROW_EXCEPTION(YYUIException()<<UIErrorStr(_T("Call RegisterClassEx Failed! :")+FormatGetLastError(hr)));
        }
    }
Exemple #6
0
HWND CWindowWnd::Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, HMENU hMenu)
{
    if( GetSuperClassName() != NULL && !RegisterSuperclass() ) return NULL;
    if( GetSuperClassName() == NULL && !RegisterWindowClass() ) return NULL;
    m_hWnd = ::CreateWindowEx(dwExStyle, GetWindowClassName(), pstrName, dwStyle, x, y, cx, cy, hwndParent, hMenu, CPaintManagerUI::GetInstance(), this);
    ASSERT(m_hWnd!=NULL);
    return m_hWnd;
}
bool CWindowWnd::RegisterSuperclass()
{
	// Get the class information from an existing
	// window so we can subclass it later on...
#if defined(UI_BUILD_FOR_WIN32) && !defined(UI_BUILD_FOR_WINCE)
	WNDCLASSEX wc = { 0 };
	wc.cbSize = sizeof(WNDCLASSEX);
	if( !::GetClassInfoEx(NULL, GetSuperClassName(), &wc) ) {
		if( !::GetClassInfoEx(CPaintManagerUI::GetInstance(), GetSuperClassName(), &wc) ) {
			ASSERT(!"Unable to locate window class");
			return NULL;
		}
	}
	m_OldWndProc = wc.lpfnWndProc;
	wc.lpfnWndProc = CWindowWnd::__ControlProc;
	wc.hInstance = CPaintManagerUI::GetInstance();
	wc.lpszClassName = GetWindowClassName();
	ATOM ret = ::RegisterClassEx(&wc);
#else
	WNDCLASS wc = { 0 };

	if( !::GetClassInfo(NULL, GetSuperClassName(), &wc) ) {
		if( !::GetClassInfo(CPaintManagerUI::GetInstance(), GetSuperClassName(), &wc) ) {
			ASSERT(!"Unable to locate window class");
			return NULL;
		}
	}

	wc.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);
	wc.hCursor		 = ::LoadCursor(NULL, IDC_ARROW);
	m_OldWndProc = wc.lpfnWndProc;
	wc.lpfnWndProc = CWindowWnd::__ControlProc;
	wc.hInstance = CPaintManagerUI::GetInstance();
	wc.lpszClassName = GetWindowClassName();
	ATOM ret = ::RegisterClass(&wc);
#endif
	ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
	return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Exemple #8
0
HWND CWndImpl::Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle,RectX rc)
{
	if(!MyRegisterClass())
	{
		m_hWnd = NULL;
	}
	else
	{
		m_hWnd = CreateWindowEx(dwExStyle, GetWindowClassName(),pstrName,dwStyle,rc.leftX,rc.topX,rc.GetW(),rc.GetH(),hwndParent,NULL,CWndImpl::GetInstance(),this);
	}

	Initialize();

	return m_hWnd;
}
Exemple #9
0
bool AxWnd::RegisterWindowClass()
{
	WNDCLASS wc = { 0 };
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hIcon = NULL;
	wc.lpfnWndProc = AxWnd::__WndProc;
	wc.hInstance = (HINSTANCE)GetModuleHandle(0);
	wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = GetWindowClassName();
	ATOM ret = ::RegisterClass(&wc);
	return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Exemple #10
0
bool CWindowWnd::RegisterWindowClass()
{
    WNDCLASS wc = { 0 };
    wc.style = GetClassStyle();
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hIcon = NULL;
    wc.lpfnWndProc = CWindowWnd::__WndProc;
    wc.hInstance = CPaintManagerUI::GetInstance();
    wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = NULL;
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = GetWindowClassName();
    ATOM ret = ::RegisterClass(&wc);
    ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
    return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Exemple #11
0
BOOL	NativeWindow::RegisterSuperClass()
{
	WNDCLASSEX wc = {0};
	wc.cbSize = sizeof(WNDCLASSEX);
	if(!::GetClassInfoEx(NULL, GetSuperClassName(), &wc))
	{
		if( !::GetClassInfoEx(NULL, GetSuperClassName(), &wc) ) 
		{
			return FALSE;
		}
	}
	old_window_proc_ = wc.lpfnWndProc;
	wc.lpfnWndProc = NativeWindow::StaticHandleMessages;
	wc.hInstance = NULL;
	wc.lpszClassName = GetWindowClassName();
	ATOM result = ::RegisterClassEx(&wc);
	return result != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Exemple #12
0
BOOL	NativeWindow::RegisterWindowClass()
{
	WNDCLASSEX wcx = {0}; 
	wcx.cbSize = sizeof(WNDCLASSEX);							// size of structure 
	wcx.style = CS_HREDRAW | CS_VREDRAW;						// redraw if size changes 
	wcx.lpfnWndProc = NativeWindow::StaticHandleMessages;		// points to window procedure 
	wcx.cbClsExtra = 0;											// no extra class memory 
	wcx.cbWndExtra = 0;											// no extra window memory 
	wcx.hInstance = NULL;										// handle to instance 
	wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);				// predefined app. icon 
	wcx.hCursor = LoadCursor(NULL, IDC_ARROW);					// predefined arrow 
	wcx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);	// white background brush 
	wcx.lpszMenuName = NULL;									// name of menu resource 
	wcx.lpszClassName = GetWindowClassName();						// name of window class 
	wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);				// small class icon 

	return RegisterClassEx(&wcx) != 0 || 
		::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Exemple #13
0
    HWND WindowWnd::Create(HWND hWndParent, LPCTSTR pstrName, DWORD dwStyple, DWORD dwExStyle, int x /*= CW_USEDEFAULT*/, int y /*= CW_USEDEFAULT*/, int cx /*= CW_USEDEFAULT*/, int cy /*= CW_USEDEFAULT*/, HMENU hMenu /*= NULL*/)
    {
        try
        {

            if( GetSuperClassName() != nullptr )
                RegisterSuperClass();   //如果SuperClassName存在的话就创建SuperClass
            else
                RegisterWindowClass();
            m_hWnd = CreateWindowEx( dwExStyle, GetWindowClassName(), pstrName, dwStyple, x, y, cx, cy, hWndParent, hMenu, SystemInfo::GetInstance()->GetProcessInstance(),this);
            
            assert( m_hWnd != NULL );
            return m_hWnd;
        }
        catch( ... )
        {
            throw;
        }
    }
Exemple #14
0
bool CWindowWnd::RegisterSuperclass()
{
    // Get the class information from an existing
    // window so we can subclass it later on...
    WNDCLASSEX wc = { 0 };
    wc.cbSize = sizeof(WNDCLASSEX);
    if( !::GetClassInfoEx(NULL, GetSuperClassName(), &wc) ) {
        if( !::GetClassInfoEx(CPaintManagerUI::GetInstance(), GetSuperClassName(), &wc) ) {
            ASSERT(!"Unable to locate window class");
            return NULL;
        }
    }
    m_OldWndProc = wc.lpfnWndProc;
    wc.lpfnWndProc = CWindowWnd::__ControlProc;
    wc.hInstance = CPaintManagerUI::GetInstance();
    wc.lpszClassName = GetWindowClassName();
    ATOM ret = ::RegisterClassEx(&wc);
    ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
    return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
bool CWindowWnd::RegisterWindowClass()
{
	WNDCLASS wc = { 0 };
	wc.style = GetClassStyle();
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hIcon = NULL;
	wc.lpfnWndProc = CWindowWnd::__WndProc;
	wc.hInstance = CPaintManagerUI::GetInstance();
#if defined(UI_BUILD_FOR_WIN32) && !defined(UI_BUILD_FOR_WINCE)
	wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
#else
	wc.hCursor = NULL;
#endif
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = GetWindowClassName();
	ATOM ret = ::RegisterClass(&wc);
	ASSERT(ret!=NULL || ::GetLastError()==ERROR_CLASS_ALREADY_EXISTS);
	return ret != NULL || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;
}
Exemple #16
0
void MsgRecordForm::ShowMsg(const nim::IMMessage &msg, bool first, bool show_time)
{
	const std::string &bubble_id = msg.client_msg_id_;
	if(bubble_id.empty())
	{
		QLOG_WAR(L"msg id empty");
		return;
	}

	IdBubblePair::iterator it = id_bubble_pair_.find(bubble_id);
	if(it != id_bubble_pair_.end())
	{
		QLOG_WAR(L"repeat msg: {0}") <<bubble_id;
		return;
	}

	MsgBubbleItem* item = NULL;

	if (msg.type_ == nim::kNIMMessageTypeText)
		item = new MsgBubbleText;
	else if (msg.type_ == nim::kNIMMessageTypeImage)
		item = new MsgBubbleImage;
	else if (msg.type_ == nim::kNIMMessageTypeAudio)
		item = new MsgBubbleAudio;
	else if (msg.type_ == nim::kNIMMessageTypeFile)
		item = new MsgBubbleFile;
	else if (msg.type_ == nim::kNIMMessageTypeLocation)
		item = new MsgBubbleLocation;
	else if (msg.type_ == nim::kNIMMessageTypeNotification)
	{
		id_bubble_pair_[bubble_id] = NULL;

		MsgBubbleNotice* cell = new MsgBubbleNotice;
		GlobalManager::FillBoxWithCache(cell, L"session/cell_notice.xml");
		if(first)
			msg_list_->AddAt(cell, 0);
		else
			msg_list_->Add(cell);
		cell->InitControl();
		cell->InitInfo(msg, session_id_);
		return;
	}
	else if (msg.type_ == nim::kNIMMessageTypeCustom)
	{
		Json::Value json;
		if (StringToJson(msg.attach_, json))
		{
			int sub_type = json["type"].asInt();
			if (sub_type == CustomMsgType_Jsb) //finger
			{
				item = new MsgBubbleFinger;
			}
			else if (sub_type == CustomMsgType_SnapChat)
			{
				item = new MsgBubbleSnapChat;
			}
			else if (sub_type == CustomMsgType_Sticker)
			{
				item = new MsgBubbleSticker;
			}
			else if (sub_type == CustomMsgType_Rts)
			{
				if (json["data"].isObject())
				{
					int flag = json["data"]["flag"].asInt();
					if (flag == 0)
					{
						item = new MsgBubbleText;
					}
					else if (flag == 1)
					{
						id_bubble_pair_[bubble_id] = NULL;

						MsgBubbleNotice* cell = new MsgBubbleNotice;
						GlobalManager::FillBoxWithCache(cell, L"session/cell_notice.xml");
						if (first)
							msg_list_->AddAt(cell, 0);
						else
							msg_list_->Add(cell);
						cell->InitControl();
						cell->InitInfo(msg, session_id_);
						return;
					}
				}
			}
		}
	}

	if (item == nullptr)
	{
		QLOG_WAR(L"unknown msg: cid={0} msg_type={1}") << bubble_id << msg.type_;
		item = new MsgBubbleUnknown;
	}

	bool bubble_right = IsBubbleRight(msg);
	if(bubble_right)
		GlobalManager::FillBoxWithCache( item, L"session/bubble_right.xml" );
	else
		GlobalManager::FillBoxWithCache( item, L"session/bubble_left.xml" );

	if(first)
		msg_list_->AddAt(item, 0);
	else
		msg_list_->Add(item);

	id_bubble_pair_[bubble_id] = item;

	std::string sid = nbase::UTF16ToUTF8(GetWindowClassName());

	item->InitControl(bubble_right);
	item->InitInfo(msg);
	item->SetSessionId(sid);
	item->SetSessionType(session_type_);
	item->SetActionMenu(false);
	item->SetShowTime(show_time);
	if (bubble_right || msg.session_type_ == nim::kNIMSessionTypeP2P)
		item->SetShowName(false, "");
	else
	{
		auto iter = team_member_info_list_.find(msg.sender_accid_);
		if (iter != team_member_info_list_.cend() && !iter->second.GetNick().empty())
			item->SetShowName(true, iter->second.GetNick()); //显示群名片
		else
		{
			std::string show_name = nbase::UTF16ToUTF8(UserService::GetInstance()->GetUserName(msg.sender_accid_));
			item->SetShowName(true, show_name); //显示备注名或昵称
		}
	}

	if (msg.type_ == nim::kNIMMessageTypeAudio)
		item->SetPlayed(true);

	if( item->NeedDownloadResource() )
	{
		nim::NOS::FetchMedia(msg, nbase::Bind(&MsgRecordForm::OnDownloadCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), nim::NOS::ProgressCallback());
	}
}
Exemple #17
0
HWND AxWnd::Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, HMENU hMenu)
{
	if (!RegisterWindowClass() ) return NULL;
	m_hWnd = ::CreateWindowEx(dwExStyle, GetWindowClassName(), pstrName, dwStyle, x, y, cx, cy, hwndParent, hMenu, (HINSTANCE)GetModuleHandle(0), this);
	return m_hWnd;
}