⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nwnd.h

📁 EVC环境下用SDK开发WINCE的应用程序
💻 H
字号:
#ifndef _NWND_H_
#define _NWND_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "NAVMSG_.H"
#include "NString.h"

class CNWnd
{
protected:
// message handler
	// The following message handler could be override in derived class,
	// in base class, they send msgs to default window procedure.
	virtual void OnPaint(void);
	virtual void OnActivate(UINT nState, HWND hWndOther, BOOL bMinimized ); 
	virtual void OnKeyDown(WPARAM wParam, LPARAM lParam);
	virtual void OnClose();
	virtual void OnDestroy();
	virtual BOOL OnEraseBkgnd(HDC hdc);
	virtual BOOL OnInitDialog();
	virtual void OnMouseMove(UINT nFlags, POINT point);
	virtual void OnLButtonDown(UINT nFlags, POINT point);
	virtual void OnLButtonUp(UINT nFlags, POINT point);
	virtual void OnLButtonDblClk(UINT nFlags, POINT point);
	virtual void OnRButtonDown(UINT nFlags, POINT point);
	virtual void OnRButtonUp(UINT nFlags, POINT point);
	virtual void OnTimer(UINT nIDEvent);
	virtual HBRUSH OnCtlColor(HDC hdc,HWND hwnd, UINT nCtlColor);
// Control message handler member functions
	virtual void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);

// Window create functions and window procedures
protected:
	virtual LRESULT WndProc(HWND hWnd, UINT uMsg,
		WPARAM wParam, LPARAM lParam);
	
	virtual void GetWndClass(WNDCLASS & wc);

	static LRESULT CALLBACK WindowProc(HWND hWnd,
		UINT uMsg, WPARAM wParam, LPARAM lParam);
	
	// If msgs not processed, send them to default windowproc
	LRESULT Default(UINT uMsg,	WPARAM wParam, LPARAM lParam);

public:
// Construction/Destruction
	CNWnd(void);
	virtual ~CNWnd(void);

	// handle of the window attached with this CNWnd object.
	HWND  m_hWnd;
	// pointer to parent window if it has one, it can be setted explicitly
	// by calling SetParent().
	// if we don't care about it's parent window, it's ok to set it to nll
	CNWnd *m_pParentWnd;

	virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,
				   DWORD dwStyle, const RECT& rect,
				   CNWnd* pParentWnd, UINT nID);
	virtual BOOL DestroyWindow();

	virtual BOOL CreateEx(DWORD dwExStyle,
		LPCTSTR lpszClass, LPCTSTR lpszName, DWORD dwStyle,
		int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu);
	
	BOOL RegisterClass(LPCTSTR lpszClass, HINSTANCE hInst);
	virtual WPARAM MessageLoop(void);

// Operations
	HDC GetWindowDC(void) const;
	int ReleaseDC(HDC hdc) const;
	HDC GetDC(void) const;
	HWND GetSafeHwnd(void);
	BOOL GetClientRect(RECT *pRect) const;
	BOOL GetWindowRect(RECT *pRect) const;
	CNWnd* GetParent() const;
	CNWnd* SetParent(CNWnd* pParentWnd);
// always indirectly accessed via NavGetNavWndProc
	WNDPROC NavGetNavWndProc(void);

// Update/Painting Functions
	BOOL ShowWindow(int nCmdShow) const;
	BOOL UpdateWindow(void) const;
	void InvalidateRect( LPCRECT lpRect, BOOL bErase = TRUE );
	virtual HRGN GetUpdateRgn();

// Window State Functions
	BOOL IsWindowEnabled(void) const;
	BOOL EnableWindow(BOOL bEnable = TRUE);
	BOOL ShowWindow( int nCmdShow );
	BOOL IsWindowVisible() const;
	BOOL SetWindowPos (HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags ); 

	// if it's mem window, draw it in MemDC then copy it to screen, else
	// we draw it in screen directly as what it do according windows mechanism.
	// defaut value is TRUE.
	BOOL m_bIsMemWindow;
	BOOL IsMemWindow() const {return m_bIsMemWindow;}
	BOOL SetMemWindow(BOOL bMemWindow) { return m_bIsMemWindow = bMemWindow;}
// Timer Functions
	UINT SetTimer(UINT nIDEvent, UINT nElapse,
		void (CALLBACK* lpfnTimer)(HWND, UINT, UINT, DWORD));
	BOOL KillTimer(UINT nIDEvent);

// Window Text Functions
	void SetWindowText(LPCTSTR lpszString);
	int GetWindowText(LPTSTR lpszStringBuf, int nMaxCount) const;
	int GetWindowText(CNString& rString) const;
	int GetWindowTextLength() const;
	void SetFont(HFONT hFont, BOOL bRedraw = TRUE);
	HFONT	GetFont();
// Message Functions
	LRESULT SendMessage(UINT Msg,WPARAM wParam,LPARAM lParam);
	LRESULT SendMessage(UINT Msg,WPARAM wParam,LPARAM lParam) const;
	LRESULT PostMessage(UINT Msg,WPARAM wParam,LPARAM lParam);
	LRESULT PostMessage(UINT Msg,WPARAM wParam,LPARAM lParam) const;

// subclassing/unsubclassing functions
	virtual void PreSubclassWindow(void);
	BOOL SubclassWindow(HWND hWnd);
	BOOL SubclassDlgItem(UINT nID, CNWnd* pParent);
	HWND UnsubclassWindow(void);
	BOOL Attach(HWND hWndNew);
	HWND Detach();

//	static 	HDC m_hdcDialog;
//	static  HBITMAP m_bmpDialog;

protected:
	// for subclassing of controls, the original windowporc addr
	// will be saved here.
	WNDPROC m_pfnSuper; 

// Message processing
	BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
	BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	BOOL OnCmdMsg(UINT nID, UINT nCode, void *pExtra, void *pHandlerInfo);

private:
	DECLARE_MESSAGE_MAP()
};



// interface for CNavCtrl
class CNCtrl:public CNWnd
{
public:
	CNCtrl(){};
	virtual ~CNCtrl(){};

	virtual BOOL Create(LPCTSTR lpszWindowName,
				   DWORD dwStyle, const RECT& rect,
				   CNWnd* pParentWnd, UINT nID);
	virtual void OnPaint();
	virtual void OnDraw(HDC hdc);
};


/*
// interface for CNApp
class CNApp
{
public:
	CNApp(HINSTANCE hInstance);
	virtual ~CNApp();
	virtual int MessageLoop();
	virtual HINSTANCE  GetInstanceHandle() {return m_hInstance;}
	static CNApp* GetApp() {return sm_pTheApp;}

private:
	HINSTANCE m_hInstance;
	static CNApp* sm_pTheApp;
	CNWnd	*m_pMainWnd;
};
CNApp* GetApp();
*/
#endif //_NWND_H_

⌨️ 快捷键说明

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