Help with text program...
The Problem:
szFileName can't be read from the ShellExecute command.
The Code(This is part of the WinProc):
Code:
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case ID_FILE_NEW:
{
DestroyWindow(hEdit);
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0, 0, 800, 600, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
}
break;
case ID_FILE_EXIT:
{
SendMessage(hwnd, WM_CLOSE, 0, 0);
}
break;
case ID_FILE_SAVE:
{
OPENFILENAME sfn;
char szFileName[MAX_PATH] = ""; //definition of szFileName
ZeroMemory(&sfn, sizeof(sfn));
sfn.lStructSize = sizeof(sfn); // SEE NOTE BELOW
sfn.hwndOwner = hwnd;
sfn.lpstrFilter = "HTML Files (*.htm)\0*.htm\0Text Files(*.txt)\0*.txt\0RPGCode Files(*.prg)\0*.prg\0All Files (*.*)\0*.*\0";
sfn.lpstrFile = szFileName;
sfn.nMaxFile = MAX_PATH;
sfn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
sfn.lpstrDefExt = "html";
if(GetSaveFileName(&sfn))
{
SaveTextFileFromEdit(hEdit, szFileName);
}
}
break;
case ID_FILE_OPEN:
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = ""; //definition of szFileName
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "HTML Files (*.htm)\0*.htm\0Text Files(*.txt)\0*.txt\0RPGCode Files(*.prg)\0*.prg\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "html";
if(GetOpenFileName(&ofn))
{
LoadTextFileToEdit(hEdit, szFileName);
}
}
break;
case ID_HELP_ABOUT:{
DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
}
break;
case ID_EDIT_PREVIEW:{
ShellExecute(hwnd, "open", szFileName, NULL, NULL, SW_MAXIMIZE); //Shell Execute Command
}
The Specifics:
I want ShellExecute to open the file(If it's HTML in the Default Browser and nobody is dumb enough to preview a .txt file :P)
The program opens ASCII files. Whoopee.