Okay nevermind, it wasn't giving me the error message while the program continued to close on me because I forgot the break; or erased it or something... but as soon as I fixed that problem with the program closing, it decided to not work out that way and again I receive the 1407: Cannot find window class. error. Here is my code that all deals with creating the richedit controls:
in my WM_CREATE message I have the following code:
Code:
.
.
.
// initialize the program and any structs needed
Initialize();
CreateStatus();
break;
then in my Initialize() function I have:
Code:
// load richedit library
hLib = LoadLibrary(TEXT("MSFTEDIT.DLL"));
if( !hLib ) {
hLib = LoadLibrary(TEXT("RICHED32.DLL"));
if( !hLib ) {
hLib = LoadLibrary(TEXT("RICHED20.DLL"));
if( !hLib ) {
MessageBox(NULL, TEXT("Failed to load rich edit library!"), TEXT("Initialization Error"), MB_OK | MB_ICONERROR);
return;
}
else { lstrcpy(chCntrlName, TEXT("RICHEDIT")); }
}
else { lstrcpy(chCntrlName, RICHEDIT_CLASS); }
}
else { lstrcpy(chCntrlName, RICHEDIT_CLASS); }
the above code has already been pasted but I'm making it easier to clarify what is happening in my program by posting it again all in one post... the next code is in my CreateStatus() function:
Code:
char error[45];
int err;
MDICREATESTRUCT mcs;
mcs.szTitle = "Status: Atraeon";
mcs.szClass = g_szStatus;
mcs.hOwner = g_hInst;
mcs.x = CW_USEDEFAULT;
mcs.cx = 600;
mcs.y = CW_USEDEFAULT;
mcs.cy = 500;
mcs.style = MDIS_ALLCHILDSTYLES;
g_hStatus = (HWND)SendMessage(g_hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
if( g_hStatus == NULL ) {
err = GetLastError();
sprintf(error, "Status window creation failed. (%d)", err);
MessageBox(NULL, error, TEXT("Creation Failure"), MB_ICONERROR | MB_OK);
}
ShowWindow(g_hMDIClient, SW_SHOW);
The above deals with creating the window in my MDI client. The next bit of code is found under the WM_CREATE in my StatusWndProc procedure which deals with the Status window.
Code:
HWND hDisplay; // defined at the beginning of the windows procedure
hDisplay = CreateWindowEx(WS_EX_CLIENTEDGE, "RICHEDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_DISABLED | ES_MULTILINE, rect.left, rect.top, rect.right - rect.left, rect.bottom - 17 - rect.top, hwnd, (HMENU)IDC_MYRICHEDIT, g_hInst, NULL); // creating text display area
if( hDisplay == NULL ) {
error = GetLastError();
sprintf(buffer, "Failure to create richedit control for status window. (%d)", error);
MessageBox(NULL, buffer, "Error", MB_OK);
}
Thats all the code that deals with creating my first richedit control for the program. I've also added the HMENU (defined at the beginning of the program as 40000) and added it to the CreateWindowEx call. None of it works. I've tried placing "RichEdit20A", "RichEdit20W", RICHEDIT_CLASS, "RICHEDIT", and various other "classes" into the CreateWindowEx call under my StatusWndProc call (in WM_CREATE) but none of them work. I've tried using the chCntrlName as well that is set under the Initialize() function. I'm getting no errors besides the ones outputted by my Message Boxes throughout the code. And the only one I get relating to this series of code is the 1407 error returned by GetLastError when the handle is returned as NULL.
Any help would be greatly appreciated!
Tyouk