Hello

The purpose is to be able to go File->Save, and the current MDI window document saves to the filepath of that file. (without the save as process) My program sets the filepath of that file as each MDI window's title, so when I use GetDlgItemText(g_hMDIClient, IDC_CHILD_EDIT, szFileName, MAX_PATH); I want to get the filepath from the current MDI window title.

Code:
BOOL SaveTextFileFromEdit(HWND hEdit, LPCTSTR pszFileName)
{
	HANDLE hFile;
	BOOL bSuccess = FALSE;

	hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL,
		CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if(hFile != INVALID_HANDLE_VALUE)
	{
		DWORD dwTextLength;

		dwTextLength = GetWindowTextLength(hEdit);
		// No need to bother if there's no text.
		if(dwTextLength > 0)
		{
			LPSTR pszText;
			DWORD dwBufferSize = dwTextLength + 1;

			pszText = (LPSTR)GlobalAlloc(GPTR, dwBufferSize);
			if(pszText != NULL)
			{
				if(GetWindowText(hEdit, pszText, dwBufferSize))
				{
					DWORD dwWritten;

					if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
						bSuccess = TRUE;
				}
				GlobalFree(pszText);
			}
		}
		CloseHandle(hFile);
	}
	return bSuccess;
}

void Save(HWND hwnd)
{ 
     char szFileName[MAX_PATH] = "";

     // Problem is below - it needs to get the correct, current MDI window filename associated with that window
     GetDlgItemText(g_hMDIClient, IDC_CHILD_EDIT, szFileName, MAX_PATH);
     HWND hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
     if(SaveTextFileFromEdit(hEdit, szFileName))
     {
			SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM)"Saved...");
			SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM)szFileName);

			SetWindowText(hwnd, szFileName);
     }
}
Thank you