Changeset 9519 for trunk/src/user32/windlg.cpp
- Timestamp:
- Dec 17, 2002, 3:16:47 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/windlg.cpp
r9297 r9519 1 /* $Id: windlg.cpp,v 1.3 5 2002-09-26 16:04:35sandervl Exp $ */1 /* $Id: windlg.cpp,v 1.36 2002-12-17 14:16:47 sandervl Exp $ */ 2 2 /* 3 3 * Win32 dialog apis for OS/2 … … 624 624 //****************************************************************************** 625 625 //****************************************************************************** 626 INT WIN32API DlgDirListA(HWND hDlg, LPSTR spec, INT idLBox, INT idStatic, UINT attrib )627 {628 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );629 }630 //******************************************************************************631 //******************************************************************************632 int WIN32API DlgDirListW(HWND hDlg, LPWSTR spec, INT idLBox, INT idStatic, UINT attrib )633 {634 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );635 }636 //******************************************************************************637 //******************************************************************************638 INT WIN32API DlgDirListComboBoxA(HWND hDlg, LPSTR spec, INT idCBox, INT idStatic, UINT attrib )639 {640 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );641 }642 //******************************************************************************643 //******************************************************************************644 INT WIN32API DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox, INT idStatic, UINT attrib )645 {646 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );647 }648 //******************************************************************************649 //******************************************************************************650 BOOL WIN32API DlgDirSelectComboBoxExA(HWND hwnd, LPSTR str, INT len, INT id )651 {652 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, TRUE );653 }654 //******************************************************************************655 //******************************************************************************656 BOOL WIN32API DlgDirSelectComboBoxExW(HWND hwnd, LPWSTR str, INT len, INT id)657 {658 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, TRUE );659 }660 //******************************************************************************661 //******************************************************************************662 BOOL WIN32API DlgDirSelectExA(HWND hwnd, LPSTR str, INT len, INT id)663 {664 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, FALSE );665 }666 //******************************************************************************667 //******************************************************************************668 BOOL WIN32API DlgDirSelectExW(HWND hwnd, LPWSTR str, INT len, INT id)669 {670 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, FALSE );671 }672 626 /********************************************************************** 673 627 * DIALOG_DlgDirSelect … … 676 630 */ 677 631 static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len, 678 INT id, BOOL win32, BOOL unicode, 679 BOOL combo ) 632 INT id, BOOL unicode, BOOL combo ) 680 633 { 681 634 char *buffer, *ptr; … … 684 637 HWND listbox = GetDlgItem( hwnd, id ); 685 638 639 dprintf(("%04x '%s' %d\n", hwnd, str, id )); 686 640 if (!listbox) return FALSE; 687 641 688 item = SendMessageA(listbox, combo ? CB_GETCURSEL 689 : LB_GETCURSEL, 0, 0 ); 642 item = SendMessageA(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 ); 690 643 if (item == LB_ERR) return FALSE; 691 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN 692 : LB_GETTEXTLEN, 0, 0 ); 644 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN : LB_GETTEXTLEN, 0, 0 ); 693 645 if (size == LB_ERR) return FALSE; 694 646 695 if (!(buffer = (char *)malloc( size+1 ))) return FALSE; 696 697 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, 698 item, (LPARAM)buffer ); 699 700 if ((ret = (buffer[0] == '[')) != 0) /* drive or directory */ 647 if (!(buffer = (char *)HeapAlloc( GetProcessHeap(), 0, size+1 ))) return FALSE; 648 649 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, item, (LPARAM)buffer ); 650 651 if ((ret = (buffer[0] == '['))) /* drive or directory */ 701 652 { 702 653 if (buffer[1] == '-') /* drive */ … … 714 665 else ptr = buffer; 715 666 716 if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len ); 667 if (unicode) 668 { 669 if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, ptr, -1, (LPWSTR)str, len )) 670 ((LPWSTR)str)[len-1] = 0; 671 } 717 672 else lstrcpynA( str, ptr, len ); 718 719 free( buffer);673 HeapFree( GetProcessHeap(), 0, buffer ); 674 dprintf(("Returning %d '%s'\n", ret, str )); 720 675 return ret; 721 676 } … … 723 678 724 679 /********************************************************************** 725 * 680 * DIALOG_DlgDirList 726 681 * 727 682 * Helper function for DlgDirList* 728 683 */ 729 684 static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox, 730 INT idStatic, UINT attrib, BOOL combo ) 731 { 732 int drive; 685 INT idStatic, UINT attrib, BOOL combo ) 686 { 733 687 HWND hwnd; 734 688 LPSTR orig_spec = spec; … … 738 692 : SendMessageA( hwnd, msg, wparam, lparam )) 739 693 740 if (spec && spec[0] && (spec[1] == ':')) 741 { 742 drive = _toupper( spec[0] ) - 'A'; 743 spec += 2; 744 if (!DRIVE_SetCurrentDrive( drive )) return FALSE; 745 } 746 else drive = DRIVE_GetCurrentDrive(); 694 dprintf(("%04x '%s' %d %d %04x\n", 695 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib )); 747 696 748 697 /* If the path exists and is a directory, chdir to it */ 749 if (!spec || !spec[0] || DRIVE_Chdir( drive,spec )) spec = "*.*";698 if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = "*.*"; 750 699 else 751 700 { 752 701 char *p, *p2; 753 702 p = spec; 754 if ((p2 = strrchr( p, '\\' )) != 0) p = p2;755 if ((p2 = strrchr( p, '/' )) != 0) p = p2;703 if ((p2 = strrchr( p, '\\' ))) p = p2; 704 if ((p2 = strrchr( p, '/' ))) p = p2; 756 705 if (p != spec) 757 706 { 758 707 char sep = *p; 759 708 *p = 0; 760 if (! DRIVE_Chdir( drive,spec ))709 if (!SetCurrentDirectoryA( spec )) 761 710 { 762 711 *p = sep; /* Restore the original spec */ … … 766 715 } 767 716 } 717 718 dprintf(( "mask=%s\n", spec )); 768 719 769 720 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0)) … … 794 745 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0)) 795 746 { 796 char temp[512], curpath[512]; 797 int drive = DRIVE_GetCurrentDrive(); 798 strcpy( temp, "A:\\" ); 799 temp[0] += drive; 800 lstrcpynA( temp + 3, DRIVE_GetDosCwd(curpath, drive, sizeof(curpath)), sizeof(temp)-3 ); 747 char temp[MAX_PATH]; 748 GetCurrentDirectoryA( sizeof(temp), temp ); 801 749 CharLowerA( temp ); 802 750 /* Can't use PostMessage() here, because the string is on the stack */ … … 808 756 /* Update the original file spec */ 809 757 char *p = spec; 810 while ((*orig_spec++ = *p++) != 0);758 while ((*orig_spec++ = *p++)); 811 759 } 812 760 … … 817 765 818 766 /********************************************************************** 819 * 767 * DIALOG_DlgDirListW 820 768 * 821 * Helper function for DlgDirList* 32W769 * Helper function for DlgDirList*W 822 770 */ 823 771 static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, 824 INT idStatic, UINT attrib, BOOL combo )772 INT idStatic, UINT attrib, BOOL combo ) 825 773 { 826 774 if (spec) … … 829 777 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic, 830 778 attrib, combo ); 831 lstrcpyAtoW( spec, specA);779 MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff ); 832 780 HeapFree( GetProcessHeap(), 0, specA ); 833 781 return ret; … … 835 783 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo ); 836 784 } 837 //****************************************************************************** 838 //****************************************************************************** 839 785 786 787 /********************************************************************** 788 * DlgDirSelectExA (USER32.@) 789 */ 790 BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id ) 791 { 792 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE ); 793 } 794 795 796 /********************************************************************** 797 * DlgDirSelectExW (USER32.@) 798 */ 799 BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id ) 800 { 801 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, FALSE ); 802 } 803 804 805 /********************************************************************** 806 * DlgDirSelectComboBoxExA (USER32.@) 807 */ 808 BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len, 809 INT id ) 810 { 811 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, TRUE ); 812 } 813 814 815 /********************************************************************** 816 * DlgDirSelectComboBoxExW (USER32.@) 817 */ 818 BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len, 819 INT id) 820 { 821 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE ); 822 } 823 824 825 /********************************************************************** 826 * DlgDirListA (USER32.@) 827 */ 828 INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox, 829 INT idStatic, UINT attrib ) 830 { 831 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE ); 832 } 833 834 835 /********************************************************************** 836 * DlgDirListW (USER32.@) 837 */ 838 INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, 839 INT idStatic, UINT attrib ) 840 { 841 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE ); 842 } 843 844 845 /********************************************************************** 846 * DlgDirListComboBoxA (USER32.@) 847 */ 848 INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox, 849 INT idStatic, UINT attrib ) 850 { 851 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE ); 852 } 853 854 855 /********************************************************************** 856 * DlgDirListComboBoxW (USER32.@) 857 */ 858 INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox, 859 INT idStatic, UINT attrib ) 860 { 861 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE ); 862 }
Note:
See TracChangeset
for help on using the changeset viewer.