9/11/2008 2:53 PM | |
Posts: 168 Rating:
|
Hi, do it like this: 1. Extract the attached files into your application directory structure "...\library" 2. Put this code on the "Open" button mouse action event: [code] #pragma code("comdlg32.dll") #include "commdlg.h" #pragma code() OPENFILENAME ofn; char szFilter[] = "Text CSV (.csv)|*.csv|Text TXT (.txt)|*.txt|"; // Put your file filter here char* psz; char szFile[_MAX_PATH+1]; char szFileTitle[_MAX_PATH+1]; char szInitialDir[_MAX_PATH+1]; char szAuxOpenDir[_MAX_PATH+1]; for(psz=szFilter; *psz; psz++) { if(*psz == '|') { *psz = 0; } } strcpy(szInitialDir, "C:\\Program Files\\Siemens"); // Put your initial directory here strcpy(szFileTitle, "untitled.csv"); // Put your initial file name here ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = FindWindow(NULL, "WinCC-Runtime - "); ofn.lpstrFilter = szFilter; ofn.lpstrFile = szFile; ofn.nMaxFile = _MAX_PATH+1; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = _MAX_PATH+1; ofn.lpstrInitialDir = szInitialDir; ofn.Flags = OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST; ofn.lpstrDefExt = "csv"; // Put the default file extention here if(GetOpenFileName(&ofn)) { printf("The choosen path is %s\r\n", ofn.lpstrFile); } } [/code] 3. Feedback me if something doesn't work Best Regards, Dimitri. Attachmentfiles.zip (341 Downloads) |
This contribution was helpful to
2 thankful Users |
9/13/2008 11:47 AM | |
Posts: 37 Rating:
|
Hello, It works perfect! Thank You very much. Best Regards, P. |
Follow us on