Code:
void LoadArchive(HWND hWnd)
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
char szFile[260];
ofn.hwndOwner = hWnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 260;
ofn.lpstrFilter = "CX4 Dateien (*.CX4)\0*.CX4\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(::GetOpenFileName(&ofn)==TRUE)
{
FILE* pFile = fopen((char*)ofn.lpstrFile,"rb");
if(!pFile)
return;
nCount = 0;
ListView_DeleteAllItems(hWnd_LstFiles);
files.clear();
while(1)
{
if(feof(pFile)) break;
int nName;
fread(&nName,1,sizeof(int),pFile);
char* cName = new char[nName];
fread(&cName,1,nName,pFile);
int nData;
fread(&nData,1,sizeof(int),pFile);
char* cData = new char[nData];
fread(&cData,1,nData,pFile);
int nSize = GetDecompressedBufferSize(&cData);
char* content = new char[nSize];
if(DecompressBuffer(&cData,&content)==0)
break;
AddFileToList(cName,nSize,content);
}
fclose(pFile);
}
}
der dialog öffnet sich wie gesagt nur bei nem button!
in der wndproc:
Code:
case ID_MENU_FILE_OPEN:
{
LoadArchive(hWndMain);
}break;
case ID_BUTTON_OPEN:
{
LoadArchive(hWndMain);
}break;
also 2 mal der gleiche aufruf!
nur der untere klappt!