Code:
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HWND hEdit;
HWND hList;
HWND hInput;
HFONT hfDefault;
char szWindowText[1000];
GetWindowText(hwnd, szWindowText, 1000);
// Main Edit Window
hEdit = CreateWindowEx(0, "RICHEDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_DISABLENOSCROLL |
ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL, 0, 0, 100, 100,
hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL);
hfDefault = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
// Input Window
hInput = CreateWindowEx(0, "EDIT", "", WS_CHILD | WS_BORDER | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN,
0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_INPUT, GetModuleHandle(NULL), NULL);
SendMessage(hInput, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
wndEdit = (WNDPROC)SetWindowLong(hInput, GWL_WNDPROC, (LONG)EditWndProc);
SetFocus(hInput);
// If Channel Window Create NickList
if(szWindowText[0] == '#')
{
hList = CreateWindowEx(0, "ListBox", "", LBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE |
WS_VSCROLL | LBS_EXTENDEDSEL | LBS_NOINTEGRALHEIGHT | LBS_STANDARD,
0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_LIST, GetModuleHandle(NULL), NULL);
// Random Nicks
char szNick[10];
for ( int i = 0; i < 100; i++ )
{
if(i < 20) { sprintf(szNick, "_Nick%i", i); }
if( (i > 20) && (i < 60) ) { sprintf(szNick, "@_Nick%i", i); }
if( (i > 60) && (i < 100) ) { sprintf(szNick, "+_Nick%i", i); }
SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)szNick);
}
SendMessage(hList, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
}
}
break;
case WM_SIZE:
{
HWND hEdit;
HWND hList;
HWND hInput;
RECT rcClient;
GetClientRect(hwnd, &rcClient);
char szWindowText[1000];
GetWindowText(hwnd, szWindowText, 1000);
hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
hInput = GetDlgItem(hwnd, IDC_CHILD_INPUT);
SetWindowPos(hInput, NULL, 0, rcClient.bottom - 22, rcClient.right, rcClient.bottom, SWP_NOZORDER);
if(szWindowText[0] == '#')
{
hList = GetDlgItem(hwnd, IDC_CHILD_LIST);
SetWindowPos(hList, NULL, rcClient.right - 120, 0, rcClient.right, rcClient.bottom - 22, SWP_NOZORDER);
SetWindowPos(hEdit, NULL, 0, 0, rcClient.right - 120, rcClient.bottom - 22, SWP_NOZORDER);
}
else
{
SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom - 22, SWP_NOZORDER);
}
}
return DefMDIChildProc(hwnd, msg, wParam, lParam);
case WM_CLOSE:
{
char szWindowText[1000];
GetWindowText(hwnd, szWindowText, 1000);
if(!IsStringMatch(szWindowText, "Status"))
{
SendMessage(g_hMDIClient, WM_MDIDESTROY, (WPARAM)hwnd, 0);
PartChannel(szWindowText);
}
}
break;
default:
return DefMDIChildProc(hwnd, msg, wParam, lParam);
}
return 0;
}
I'm really stumped as to whats going wrong.