我想用一个窗口来接收PCM的消息,所以想从CWnd中继承一个类,这个窗口类的父窗口是现在的主窗口(对话框),我有如下代码: WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle(); if (!(::GetClassInfo(hInst, _T("MyClass"), &wndcls)))
{
// otherwise we need to register a new class
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = _T("MyClass") ; if (!AfxRegisterClass(&wndcls))
{
AfxThrowResourceException();
}
}
int a = m_pSouChat->Create(_T("MyClass"),_T(""),WS_OVERLAPPED|WS_VISIBLE,CRect(0,0,100,100),pDlg,1234) ;a的返回值总为0,请问这段代码该放在哪里好??
谢谢了!!
解决方案 »
- VC与Java通信的问题
- 求构建目录算法
- 奇怪的错误“此文件不是一个有效的复合文件”
- IDispatch::Invoke如何通过dispid调用方法?
- 我用CPropertySheet::Create()函数创建的无模式属性页,为什么添加的页面中的控件不显示?
- 如何在状态栏中添加按钮?
- 用gethostname函数,需要包含那些东西呀?
- 贪吃蛇
- 一个菜鸟的问题,很简单。大家快来
- 各位师兄,我一个类CMyWinThread是从CWinThred继承过来的,我想再建一个类继承CMyWinThread,但是在new class的时候无法选择到CMyWinThread,请指教,谢谢!
- 环境的不同吗??
- 如何用ClassWizard创建一个派生自CBitmap的新类?
Create只用于child窗口
virtual BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
ResCreates a Windows child window and attaches it to the CWnd object. You construct a child window in two steps. First, call the constructor, which constructs the CWnd object. Then call Create, which creates the Windows child window and attaches it to CWnd. Create initializes the window’s class name and window name and registers values for its style, parent, and ID.
BOOL CreateEx( DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hwndParent, HMENU nIDorHMenu, LPVOID lpParam = NULL );BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam = NULL);
ResCreates an overlapped, pop-up, or child window with the extended style specified in dwExStyle. The CreateEx parameters specify the WNDCLASS, window title, window style, and (optionally) initial position and size of the window. CreateEx also specifies the window’s parent (if any) and ID.