Hi guys,
I'm new to this forum and fairly new to Windows programming as well. Anyway, I inherited some code from a previous engineer that works fine in 32-bit, but fails in 64-bit. In 64-bit, CreateWindowEx() fails, and GetLastError() returns code 1413, which is "invalid index". I haven't been able to find anything online mentioning any problem with CreateWindowEx() in 64-bit environments.
Any help is appreciated:
Code:
//call this function to creat the actual window.
bool CPrintWindow::Create(char* szWindowName,
DWORD dwStyle,
const RECT& rect,
HWND hParentWnd,
HINSTANCE hInst,
char* szClassName,
bool registerClass)
{
//TraceFunc("CPrintWindow::Create()");
if(registerClass) //local register requested
{
if(!szClassName) szClassName = "DefaultCPrintWindowName"; //if no name specified
m_wndClass.lpszClassName = szClassName;
m_wndClass.hInstance = hInst;
if(!GetClassInfo(hInst, szClassName, &m_wndClass))
{
//not yet registered, must register
m_classAtom = RegisterClass(&m_wndClass);
}
}
else if(!szClassName)
return false; //error, must have a WNDCLASS
m_hInstance = hInst;
//set the static variable to point to this instance so that
//the message loop can find it when it starts up
m_lastCPrintWindow = this;
m_hWndMain = CreateWindowEx(m_exStyle,
szClassName,
szWindowName,
dwStyle,
rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
hParentWnd,
NULL,
m_hInstance,
NULL);
if(m_hWndMain)
return true; //success
//Failed! - Give a detailed error message to show what went wrong
char szMessage[256];
DWORD result = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, result, 0, szMessage, 256, 0);
MessageBox(NULL, szMessage, "Error", MB_OK);
return false;
}
I'm not sure if it matters, but there is a thread created off the main thread, which then calls the Create() function above. I can post the code for that if you think it might be a problem.
Thanks,
Kenneth