| 2523 | } |
| 2524 | |
| 2525 | UINT_PTR CALLBACK HL_OFN__hook_proc ( HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam ) |
| 2526 | { |
| 2527 | static UINT file_ok = 0; |
| 2528 | // static UINT lbl_ch = 0; |
| 2529 | static WCHAR last_selected[MAX_PATH]; |
| 2530 | // XP spec |
| 2531 | static BOOL take_call = FALSE ; |
| 2532 | // |
| 2533 | HWND hPar = GetParent(hdlg); |
| 2534 | switch ( uiMsg ) { |
| 2535 | case WM_NOTIFY: { |
| 2536 | OFNOTIFY *ofn = ( OFNOTIFY * ) lParam; |
| 2537 | NMHDR nm = ofn->hdr; |
| 2538 | switch ( nm.code ) { |
| 2539 | case CDN_FILEOK: { |
| 2540 | WCHAR buf[MAX_PATH]; |
| 2541 | WCHAR dir[MAX_PATH]; |
| 2542 | // |
| 2543 | #if 0 |
| 2544 | int len = GetDlgItemText(hPar, cmb13, buf, MAX_PATH); |
| 2545 | #else |
| 2546 | |
| 2547 | int len = CommDlg_OpenSave_GetSpec ( hPar , buf, MAX_PATH ); |
| 2548 | #endif |
| 2549 | // can return -1 !!! |
| 2550 | *dir = L'\0'; |
| 2551 | SendMessage(hPar, CDM_GETFOLDERPATH, MAX_PATH, (LPARAM)dir); |
| 2552 | // |
| 2553 | SetWindowLong ( hdlg , DWL_MSGRESULT , 1 ); |
| 2554 | HL_TRACE("OFN OK '%S' " , buf); |
| 2555 | if ( len ) { |
| 2556 | WCHAR out[MAX_PATH]; |
| 2557 | LPWSTR final_str = buf; |
| 2558 | if ( wcsstr ( last_selected , buf ) ) { |
| 2559 | final_str = last_selected; |
| 2560 | HL_TRACE ( "OFN drop window text %S " , buf ); |
| 2561 | } |
| 2562 | HL_TRACE("OFN input (%S) ", final_str); |
| 2563 | if ( !HL_Open_File_by_prefix ( final_str , dir , out ) ) { |
| 2564 | WCHAR mess[1024]; |
| 2565 | wsprintf ( mess , |
| 2566 | L"%s\nFile not found.\n" |
| 2567 | L"Additionally, no file name starting " |
| 2568 | L"with this string exists in this folder\n%s" |
| 2569 | , final_str , dir ); |
| 2570 | MessageBox ( hdlg , mess , WC_NOTEPAD2 , MB_OK | MB_ICONWARNING ); |
| 2571 | take_call = TRUE; |
| 2572 | return 0; |
| 2573 | } else { |
| 2574 | CommDlg_OpenSave_SetControlText ( hPar, cmb13 , ( LPARAM ) out ); |
| 2575 | lstrcpy ( ofn->lpOFN->lpstrFile , out ); |
| 2576 | HL_TRACE ( "OFN final result (%S) " , out ); |
| 2577 | SetWindowLong ( hdlg , DWL_MSGRESULT , 0 ); |
| 2578 | take_call = FALSE; |
| 2579 | } |
| 2580 | } |
| 2581 | } |
| 2582 | return 1; |
nothing calls this directly
no test coverage detected