Пример #1
0
static int winFileDlgGetSelectedFile(Ihandle* ih, HWND hWnd, char* filename)
{
  int ret = CommDlg_OpenSave_GetFilePath(GetParent(hWnd), filename, IUP_MAX_FILENAME_SIZE);
  if (ret < 0)
    return 0;

  if (iupAttribGetBoolean(ih, "MULTIPLEFILES"))
  {
    /* check if there are more than 1 files and return only the first one */
    int found = 0;
    while(*filename != 0)
    {            
      if (*filename == '"')
      {
        if (!found)
          found = 1;
        else
        {
          *(filename-1) = 0;
          return 1;
        }
      }
      if (found)
        *filename = *(filename+1);
      filename++;
    }
  }

  return 1;
}
Пример #2
0
BOOL CGetFileNameDialog::OnFileNameOK()
{
  BOOL rVal = CFileDialog::OnFileNameOK();

  if (!rVal && ((m_ofn.Flags & OFN_EXPLORER) == 0) || ((GetVersion() & 0xff) < 4))
  //if the filename passed the parent tests
  //then put it throught our own tests
  {
    //check for overwrite if that flag is used, since the file open
    //common dialog will not bother looking at this flag
    if (m_ofn.Flags & OFN_OVERWRITEPROMPT)
    {
      //Retrieve the filename selected
      TCHAR sPath[_MAX_PATH];
      CommDlg_OpenSave_GetFilePath(GetParent()->m_hWnd, sPath, _MAX_PATH);

      //check to see if the file already exists
      CFileStatus fs;
      if (CFile::GetStatus(sPath, fs))
      {
        CString sMessage;
        AfxFormatString1(sMessage, IDS_DDX_GF_OVERWRITE_PROMPT, sPath);

        //ensure the title is the same as the common dialog caption
        CString sCaption;
        GetParent()->GetWindowText(sCaption);
        rVal = (MessageBox(sMessage, sCaption, MB_YESNO | MB_ICONQUESTION) != IDYES);
      }
    }
  }


  return rVal;
}
void OpenFileDlg::OnFileNameChange( )
	{
	char cFileName[4096];
	CommDlg_OpenSave_GetFilePath(GetParent()->m_hWnd, cFileName, sizeof(cFileName)); 
	LoadWfdiscRecords(cFileName);
	return;
	}
Пример #4
0
    static UINT_PTR CALLBACK openCallback (HWND hdlg, UINT uiMsg, WPARAM /*wParam*/, LPARAM lParam)
    {
        if (uiMsg == WM_INITDIALOG)
        {
            Component* customComp = ((FileChooserCallbackInfo*) (((OPENFILENAMEW*) lParam)->lCustData))->customComponent;

            HWND dialogH = GetParent (hdlg);
            jassert (dialogH != 0);
            if (dialogH == 0)
                dialogH = hdlg;

            RECT r, cr;
            GetWindowRect (dialogH, &r);
            GetClientRect (dialogH, &cr);

            SetWindowPos (dialogH, 0,
                          r.left, r.top,
                          customComp->getWidth() + jmax (150, (int) (r.right - r.left)),
                          jmax (150, (int) (r.bottom - r.top)),
                          SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);

            customComp->setBounds (cr.right, cr.top, customComp->getWidth(), cr.bottom - cr.top);
            customComp->addToDesktop (0, dialogH);
        }
        else if (uiMsg == WM_NOTIFY)
        {
            LPOFNOTIFY ofn = (LPOFNOTIFY) lParam;

            if (ofn->hdr.code == CDN_SELCHANGE)
            {
                FileChooserCallbackInfo* info = (FileChooserCallbackInfo*) ofn->lpOFN->lCustData;
                FilePreviewComponent* comp = dynamic_cast<FilePreviewComponent*> (info->customComponent->getChildComponent(0));

                if (comp != nullptr)
                {
                    WCHAR path [MAX_PATH * 2] = { 0 };
                    CommDlg_OpenSave_GetFilePath (GetParent (hdlg), (LPARAM) &path, MAX_PATH);

                    comp->selectedFileChanged (File (path));
                }
            }
        }

        return 0;
    }
Пример #5
0
static UINT_PTR APIENTRY frompc_hook_proc(HWND hwnd, UINT uimsg, WPARAM wparam, LPARAM lparam){
  HWND preview;
  char filename[256];
  LVCOLUMNA column;

  preview = GetDlgItem(hwnd, IDC_PREVIEW);
  switch (uimsg) {
  case WM_INITDIALOG:
    column.mask = LVCF_TEXT | LVCF_WIDTH;
    column.pszText = "No.";
    column.cx = 40;
    ListView_InsertColumn(preview, 0, &column);
    column.pszText = "Name";
    column.cx = 160;
    ListView_InsertColumn(preview, 1, &column);
    column.pszText = "Start address";
    column.cx = 80;
    ListView_InsertColumn(preview, 2, &column);
    column.pszText = "End address";
    ListView_InsertColumn(preview, 3, &column);

    SendMessage(GetDlgItem(hwnd, IDC_C64_NAME), EM_LIMITTEXT, 16, 0);

    break;
  case WM_NOTIFY:
    {
      LPOFNOTIFY notify = (LPOFNOTIFY) lparam;
      if (notify->hdr.code == CDN_SELCHANGE) {
        ListView_DeleteAllItems(preview);
        SetDlgItemTextA(hwnd, IDC_C64_NAME, "");
        EnableWindow(GetDlgItem(hwnd, IDC_C64_NAME), FALSE);
        if (CommDlg_OpenSave_GetFilePath
            (notify->hdr.hwndFrom, filename, 256) >= 0)
          write_entries_to_window(hwnd, filename);
      }
      else if (notify->hdr.code == CDN_FILEOK) {
        int entry_num;
        struct simple_block_list_element **block = (struct simple_block_list_element **)notify->lpOFN->lCustData;
        FILE *fd = NULL;

        if (CommDlg_OpenSave_GetFilePath(notify->hdr.hwndFrom, filename, 256)
            < 0) {
          MessageBoxA(hwnd, "Cannot get selected file name", "WAV-PRG error",
                     MB_ICONERROR);
        }
        else
          fd = fopen(filename, "rb");
        if (fd == NULL) {
          MessageBoxA(hwnd, "Cannot open selected file", "WAV-PRG error",
                     MB_ICONERROR);
          SetWindowLong(hwnd, DWL_MSGRESULT, -1);
        }
        else
        {
          switch (detect_type(fd)) {
          case not_a_valid_file:
            MessageBoxA(hwnd, "Selected file is not a supported file",
                       "WAV-PRG error", MB_ICONERROR);
            break;
          case t64:
            {
              int index;
              struct simple_block_list_element **current_block = block;

              for (index = ListView_GetNextItem(preview, -1, LVNI_SELECTED); index != -1; index = ListView_GetNextItem(preview, index, LVNI_SELECTED)) {
                LVITEMA sel_item;
                char sel_num[6];

                sel_item.mask = LVIF_TEXT;
                sel_item.iItem = index;
                sel_item.iSubItem = 0;
                sel_item.pszText = sel_num;
                sel_item.cchTextMax = sizeof(sel_num);
                if (!ListView_GetItem(preview, &sel_item))
                  continue;
                entry_num = atoi(sel_num);
                add_simple_block_list_element(current_block);
                if (!get_entry(entry_num, fd, &(*current_block)->block)){
                  remove_simple_block_list_element(current_block);
                  continue;
                }
                current_block = &(*current_block)->next;
              }
            }
            if (*block == NULL)
              add_all_entries_from_file(block, fd);

            if (*block == NULL)
              MessageBoxA(hwnd, "You chose a T64 file with no entries",
                          "WAV-PRG error", MB_ICONERROR);
            break;
          case p00:
          case prg:
            add_simple_block_list_element(block);
            if (!get_first_entry(fd, &(*block)->block)) {
              MessageBoxA(hwnd, "Error in reading file", "WAV-PRG error",
                         MB_ICONERROR);
              remove_simple_block_list_element(block);;
            }
            else
            {
              int i;
              char pad_with_spaces = 0;

              GetDlgItemTextA(hwnd, IDC_C64_NAME, (*block)->block.info.name, 17);
              for (i = 0; i < 16; i++) {
                if ((*block)->block.info.name[i] == 0)
                  pad_with_spaces = 1;
                if (pad_with_spaces)
                  (*block)->block.info.name[i] = 32;
              }
            }
            break;
          default:
            break;
          }
        }
        if (fd != NULL)
          fclose(fd);
        if (*block == NULL){
          SetWindowLong(hwnd, DWL_MSGRESULT, -1);
          return 1;
        }
      }
      break;
    }
  default:
    break;
  }
  return 0;
}