rxgmoral 发表于 2006-2-7 18:53
请大家看看CWnd的问题
<P>请大家看看CWnd的问题<BR>想通过对话框的按键创建一个窗体<BR>例如:<BR><<<<<<<<<Dialog.h>>>>>>>><BR>CWnd *m_sch;<BR><<<<<<<<<Dialog.Cpp>>>>>>><BR>RECT rect;<BR>rect.top = 50;<BR>rect.left = 50;<BR>rect.right = 150;<BR>rect.bottom = 100;<BR>m_sch->Create(_T("CMyBtn"),NULL,WS_CHILD|WS_VISIBLE,rect,this,10000);<BR>m_sch->ShowWindow(SW_SHOW);<BR>m_sch->UpdateWindow();</P>
<P>编译成功,运行报错<BR>这句话有错<BR>m_sch->Create(_T("CMyBtn"),NULL,WS_CHILD|WS_VISIBLE,rect,this,10000);</P>
<P>请问错那了<BR>谢谢:)<BR></P>
冰镇柠檬汁儿 发表于 2006-2-8 08:24
<PRE>virtual BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);<BR>调用时机: <BR>窗口建立时 <BR>作为主窗口,大多在InitInstance()中将直接或间接调用Create <BR>作为子窗口,大多再父窗口建立后发出WM_CREATE消息,对其进行处理时OnCreate()中调用。 <BR>功能: <BR>控制建立细节 <BR>CWnd实现: <BR>....... <BR>//注册窗口类,调用API建立窗口 <BR>// allow modification of several common create parameters CREATESTRUCT cs; cs.dwExStyle = dwExStyle; cs.lpszClass = lpszClassName; cs.lpszName = lpszWindowName; cs.style = dwStyle; cs.x = x; cs.y = y; cs.cx = nWidth; cs.cy = nHeight; cs.hwndParent = hWndParent; cs.hMenu = nIDorHMenu; cs.hInstance = AfxGetInstanceHandle(); cs.lpCreateParams = lpParam; <BR>//在此调用虚拟函数PreCreateWindow,允许在实际建立之前“篡改”建立参数。 <BR>if (!PreCreateWindow(cs)) <BR>{ <BR>PostNcDestroy(); <BR>return FALSE; <BR>} <BR>AfxHookWindowCreate(this); <BR>HWND hWnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszClass, cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy, cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);<BR>#ifdef _DEBUG <BR>if (hWnd == NULL) <BR>{ <BR>TRACE1("Warning: Window creation failed: GetLastError returns 0x%8.8X\n", GetLastError()); <BR>}<BR>#endif <BR>if (!AfxUnhookWindowCreate()) <BR>PostNcDestroy(); <BR>// cleanup if CreateWindowEx fails too soon <BR>if (hWnd == NULL) <BR>return FALSE; <BR>ASSERT(hWnd == m_hWnd); <BR>// should have been set in send msg hook <BR>return TRUE;<BR>}<BR><BR>这是我能找到的材料,希望对你有帮助,我没弄懂。<BR>网址是:<a href="http://www.chinaaspx.com/archive/VC/1626.htm" target="_blank" >http://www.chinaaspx.com/archive/VC/1626.htm</A><BR><BR></PRE>
rxgmoral 发表于 2006-2-8 17:31
<P>谢谢你:)</P>
页:
[1]