vc下关于CreateWindowEx的问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vc下关于CreateWindowEx的问题相关的知识,希望对你有一定的参考价值。

BOOL CWnd::CreateEx(
DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu or child-window identifier
HANDLE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
)

m_hWnd = ::CreateWindowEx(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
if(m_hWnd != NULL)
return TRUE;
else
return FALSE;
提示错误为:error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *'为什么啊?
感谢您的知道。交流邮箱luciajojo25@yahoo.com.cn

m_hWnd = ::CreateWindowEx(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);

改为

m_hWnd = ::CreateWindowEx(
    dwExStyle,
    lpClassName,
    lpWindowName,
    dwStyle,
    x,y,nWidth,nHeight,
    hWndParent,
    hMenu,
    (HINSTANCE)hInstance,
    lpParam);
参考技术A 你的函数参数不对,不应该用“HANDLE”,而应该用HINSTANCE
BOOL CWnd::CreateEx(
DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu or child-window identifier
HANDLE hInstance, // handle to application instance ×××这个地方不对
LPVOID lpParam // pointer to window-creation data
)
参考技术B m_hWnd 是如何定义的?

改成HWND hWnd = ::CreateWindowEx(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
参考技术C hInstance 是什么类型?
你把代码多发点
参考技术D m_hWnd
=
::CreateWindowEx(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
改为
m_hWnd
=
::CreateWindowEx(
dwExStyle,
lpClassName,
lpWindowName,
dwStyle,
x,y,nWidth,nHeight,
hWndParent,
hMenu,
(HINSTANCE)hInstance,
lpParam);

以上是关于vc下关于CreateWindowEx的问题的主要内容,如果未能解决你的问题,请参考以下文章

[转]MFC下关于“建立空文档失败”问题的分析

请教下关于CKEditor富文本编辑框设置字体颜色的问题

linux下关于PostgreSQL数据库同步的问题!slony

Ubuntu 下关于 IDEA 或应用程序图标在 Dock 栏下显示异常的问题

python下关于np.random.choice()的问题

Linux环境下关于权限的一些小问题