Quote:> I am trying to send a keystroke to a DOS command prompt from a Dialog Box
Interesting trick: send a WM_DROPFILES to the console window, storing
the characters you want to deliver as the filename. From the Oct 98 Tech Tip
by D'Agostino:
void SendConsoleString(HWND hwnd, LPTSTR pCmdString)
{
HGLOBAL hDropFiles;
LPDROPFILES pDropFiles;
LPTSTR pFileNames;
DWORD dwLength, dwBytes;
//
// Alloc mem for DROPFILES structure and initialize. Filename
// list has one entry that is double null-terminated.
//
dwLength = lstrlen(pCmdString);
dwBytes = sizeof(DROPFILES) + (dwLength + 2) * sizeof(TCHAR);
hDropFiles = GlobalAlloc(GHND, dwBytes);
if (hDropFiles != NULL) {
pDropFiles = GlobalLock(hDropFiles);
if (pDropFiles != NULL) {
pDropFiles->pFiles = sizeof(DROPFILES);
#ifdef UNICODE
pDropFiles->fWide = TRUE;
#endif
pFileNames = (LPTSTR)((char *)pDropFiles + \
sizeof(DROPFILES));
lstrcpy(pFileNames, pCmdString);
GlobalUnlock(hDropFiles);
PostMessage(hwnd,WM_DROPFILES,(WPARAM) hDropFiles,0L);
}
}
Quote:}
Ron Burk
Windows Developer's Journal, www.wdj.com