OK, I figured it out... forgot to put a break in my DialogProc. Anyway, here is what I have... It works but I want to know if it is right?
Code:
LRESULT CALLBACK MainWinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_CREATE:
{
std::string str;
DialogBoxParam(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_NEWUSER),
hWnd,
NewUserDlgProc,
(LPARAM)&str);
}
BringWindowToTop(hWnd);
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hWnd, Msg, wParam, lParam);
}
return 0;
}
BOOL CALLBACK NewUserDlgProc(HWND hDialog, UINT Msg, WPARAM wParam, LPARAM lParam)
{
static std::string *str;
switch (Msg)
{
case WM_INITDIALOG:
str = (std::string*)lParam;
break;
case WM_COMMAND:
switch (LOWORD(wParam) )
{
case IDB_OK:
{
char chStr[80];
GetDlgItemText(hDialog, IDE_EDIT, chStr, 80);
*str = chStr;
SendMessage(hDialog, WM_CLOSE, NULL, NULL);
}
break;
}
break;
case WM_CLOSE:
EndDialog(hDialog, (LPARAM)str);
break;
default:
return FALSE;
}
return TRUE;
}