/*********************************************************************** * COMDLG32_FR_CheckPartial [internal] * Check various fault conditions in the supplied parameters that * cause an extended error to be reported. * RETURNS * TRUE: Success * FALSE: Failure */ static BOOL COMDLG32_FR_CheckPartial( const FINDREPLACEA *pfr, /* [in] Find structure */ BOOL Replace /* [in] True if called as replace */ ) { if(!pfr) { COMDLG32_SetCommDlgExtendedError(CDERR_GENERALCODES); return FALSE; } if(pfr->lStructSize != sizeof(FINDREPLACEA)) { COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); return FALSE; } if(!IsWindow(pfr->hwndOwner)) { COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE); return FALSE; } if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat) ||(Replace && (pfr->wReplaceWithLen < 1 || !pfr->lpstrReplaceWith))) { COMDLG32_SetCommDlgExtendedError(FRERR_BUFFERLENGTHZERO); return FALSE; } if((FindReplaceMessage = RegisterWindowMessageA(FINDMSGSTRINGA)) == 0) { COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); return FALSE; } if((HelpMessage = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); return FALSE; } if((pfr->Flags & FR_ENABLEHOOK) && !pfr->lpfnHook) { COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK); return FALSE; } if((pfr->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE)) && !pfr->hInstance) { COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE); return FALSE; } if((pfr->Flags & FR_ENABLETEMPLATE) && !pfr->lpTemplateName) { COMDLG32_SetCommDlgExtendedError(CDERR_NOTEMPLATE); return FALSE; } return TRUE; }
/*********************************************************************** * COMDLG32_AllocMem (internal) * Get memory for internal datastructure plus stringspace etc. * RETURNS * Success: Pointer to a heap block * Failure: null */ LPVOID COMDLG32_AllocMem( int size /* [in] Block size to allocate */ ) { LPVOID ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if(!ptr) { COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE); return NULL; } return ptr; }
/*********************************************************************** * PRINTDLG_WMInitDialog [internal] */ static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam, PRINT_PTRA16* ptr16) { PRINT_PTRA *PrintStructures = &ptr16->print32; LPPRINTDLG16 lppd = ptr16->lpPrintDlg16; DEVNAMES *pdn; DEVMODEA *pdm; char *name = NULL; UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4; /* load Collate ICONs */ PrintStructures->hCollateIcon = LoadIconA(COMDLG32_hInstance, "PD32_COLLATE"); PrintStructures->hNoCollateIcon = LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE"); if(PrintStructures->hCollateIcon == 0 || PrintStructures->hNoCollateIcon == 0) { ERR("no icon in resourcefile\n"); COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); EndDialog(hDlg, FALSE); } /* load Paper Orientation ICON */ /* FIXME: not implemented yet */ /* * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message * must be registered and the Help button must be shown. */ if (lppd->Flags & PD_SHOWHELP) { if((PrintStructures->HelpMessageID = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); return FALSE; } } else PrintStructures->HelpMessageID = 0; if (!(lppd->Flags & PD_PRINTSETUP)) { /* We have a print quality combo box. What shall we do? */ if (GetDlgItem(hDlg,cmb1)) { char buf [20]; FIXME("Print quality only displaying currently.\n"); pdm = GlobalLock16(lppd->hDevMode); if(pdm) { switch (pdm->u1.s1.dmPrintQuality) { case DMRES_HIGH : strcpy(buf,"High"); break; case DMRES_MEDIUM : strcpy(buf,"Medium"); break; case DMRES_LOW : strcpy(buf,"Low"); break; case DMRES_DRAFT : strcpy(buf,"Draft"); break; case 0 : strcpy(buf,"Default"); break; default : sprintf(buf,"%ddpi",pdm->u1.s1.dmPrintQuality); break; } GlobalUnlock16(lppd->hDevMode); } else strcpy(buf,"Default"); SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf); SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0); EnableWindow(GetDlgItem(hDlg,cmb1),FALSE); } } /* FIXME: I allow more freedom than either Win95 or WinNT, * which do not agree to what errors should be thrown or not * in case nToPage or nFromPage is out-of-range. */ if (lppd->nMaxPage < lppd->nMinPage) lppd->nMaxPage = lppd->nMinPage; if (lppd->nMinPage == lppd->nMaxPage) lppd->Flags |= PD_NOPAGENUMS; if (lppd->nToPage < lppd->nMinPage) lppd->nToPage = lppd->nMinPage; if (lppd->nToPage > lppd->nMaxPage) lppd->nToPage = lppd->nMaxPage; if (lppd->nFromPage < lppd->nMinPage) lppd->nFromPage = lppd->nMinPage; if (lppd->nFromPage > lppd->nMaxPage) lppd->nFromPage = lppd->nMaxPage; /* If the printer combo box is in the dialog, fill it */ if (GetDlgItem(hDlg,comboID)) { /* Fill Combobox */ pdn = GlobalLock16(lppd->hDevNames); pdm = GlobalLock16(lppd->hDevMode); if(pdn) name = (char*)pdn + pdn->wDeviceOffset; else if(pdm) name = (char*)pdm->dmDeviceName; PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name); if(pdm) GlobalUnlock16(lppd->hDevMode); if(pdn) GlobalUnlock16(lppd->hDevNames); /* Now find selected printer and update rest of dlg */ name = HeapAlloc(GetProcessHeap(),0,256); if (GetDlgItemTextA(hDlg, comboID, name, 255)) PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); } else { /* else just use default printer */ char name[200]; DWORD dwBufLen = sizeof(name); BOOL ret = GetDefaultPrinterA(name, &dwBufLen); if (ret) PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); else FIXME("No default printer found, expect problems!\n"); } HeapFree(GetProcessHeap(),0,name); return TRUE; }
/*********************************************************************** * COMDLG32_FR_DoFindReplace [internal] * Actual load and creation of the Find/Replace dialog. * RETURNS * Window handle to created dialog:Success * NULL:Failure */ static HWND COMDLG32_FR_DoFindReplace( COMDLG32_FR_Data *pdata /* [in] Internal data structure */ ) { HWND hdlgwnd = 0; HGLOBAL loadrc; DWORD error; LPDLGTEMPLATEW rcs; TRACE("hInst=%p, Flags=%08x\n", pdata->fr.hInstance, pdata->fr.Flags); if(!(pdata->fr.Flags & FR_ENABLETEMPLATEHANDLE)) { HMODULE hmod = COMDLG32_hInstance; HRSRC htemplate; if(pdata->fr.Flags & FR_ENABLETEMPLATE) { hmod = pdata->fr.hInstance; if(pdata->fr.Flags & FR_WINE_UNICODE) { htemplate = FindResourceW(hmod, (LPCWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOG); } else { htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOG); } } else { int rcid = pdata->fr.Flags & FR_WINE_REPLACE ? REPLACEDLGORD : FINDDLGORD; htemplate = FindResourceA(hmod, MAKEINTRESOURCEA(rcid), (LPCSTR)RT_DIALOG); } if(!htemplate) { error = CDERR_FINDRESFAILURE; goto cleanup; } loadrc = LoadResource(hmod, htemplate); } else { loadrc = (HGLOBAL)pdata->fr.hInstance; } if(!loadrc) { error = CDERR_LOADRESFAILURE; goto cleanup; } if((rcs = (LPDLGTEMPLATEW)LockResource(loadrc)) == NULL) { error = CDERR_LOCKRESFAILURE; goto cleanup; } hdlgwnd = CreateDialogIndirectParamA(COMDLG32_hInstance, rcs, pdata->fr.hwndOwner, COMDLG32_FindReplaceDlgProc, (LPARAM)pdata); if(!hdlgwnd) { error = CDERR_DIALOGFAILURE; cleanup: COMDLG32_SetCommDlgExtendedError(error); HeapFree(GetProcessHeap(), 0, pdata); } return hdlgwnd; }