Changeset 9519 for trunk/src


Ignore:
Timestamp:
Dec 17, 2002, 3:16:47 PM (23 years ago)
Author:
sandervl
Message:

Merged dialog directory functions with latest Rewind

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/windlg.cpp

    r9297 r9519  
    1 /* $Id: windlg.cpp,v 1.35 2002-09-26 16:04:35 sandervl Exp $ */
     1/* $Id: windlg.cpp,v 1.36 2002-12-17 14:16:47 sandervl Exp $ */
    22/*
    33 * Win32 dialog apis for OS/2
     
    624624//******************************************************************************
    625625//******************************************************************************
    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 }
    672626/**********************************************************************
    673627 *           DIALOG_DlgDirSelect
     
    676630 */
    677631static 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 )
    680633{
    681634    char *buffer, *ptr;
     
    684637    HWND listbox = GetDlgItem( hwnd, id );
    685638
     639    dprintf(("%04x '%s' %d\n", hwnd, str, id ));
    686640    if (!listbox) return FALSE;
    687641
    688     item = SendMessageA(listbox, combo ? CB_GETCURSEL
    689                                              : LB_GETCURSEL, 0, 0 );
     642    item = SendMessageA(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 );
    690643    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 );
    693645    if (size == LB_ERR) return FALSE;
    694646
    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 */
    701652    {
    702653        if (buffer[1] == '-')  /* drive */
     
    714665    else ptr = buffer;
    715666
    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    }
    717672    else lstrcpynA( str, ptr, len );
    718 
    719     free( buffer );
     673    HeapFree( GetProcessHeap(), 0, buffer );
     674    dprintf(("Returning %d '%s'\n", ret, str ));
    720675    return ret;
    721676}
     
    723678
    724679/**********************************************************************
    725  *      DIALOG_DlgDirList
     680 *          DIALOG_DlgDirList
    726681 *
    727682 * Helper function for DlgDirList*
    728683 */
    729684static 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{
    733687    HWND hwnd;
    734688    LPSTR orig_spec = spec;
     
    738692                             : SendMessageA( hwnd, msg, wparam, lparam ))
    739693
    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 ));
    747696
    748697    /* 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 = "*.*";
    750699    else
    751700    {
    752701        char *p, *p2;
    753702        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;
    756705        if (p != spec)
    757706        {
    758707            char sep = *p;
    759708            *p = 0;
    760             if (!DRIVE_Chdir( drive, spec ))
     709            if (!SetCurrentDirectoryA( spec ))
    761710            {
    762711                *p = sep;  /* Restore the original spec */
     
    766715        }
    767716    }
     717
     718    dprintf(( "mask=%s\n", spec ));
    768719
    769720    if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
     
    794745    if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
    795746    {
    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 );
    801749        CharLowerA( temp );
    802750        /* Can't use PostMessage() here, because the string is on the stack */
     
    808756        /* Update the original file spec */
    809757        char *p = spec;
    810         while ((*orig_spec++ = *p++) != 0);
     758        while ((*orig_spec++ = *p++));
    811759    }
    812760
     
    817765
    818766/**********************************************************************
    819  *      DIALOG_DlgDirListW
     767 *          DIALOG_DlgDirListW
    820768 *
    821  * Helper function for DlgDirList*32W
     769 * Helper function for DlgDirList*W
    822770 */
    823771static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
    824                                INT idStatic, UINT attrib, BOOL combo )
     772                                 INT idStatic, UINT attrib, BOOL combo )
    825773{
    826774    if (spec)
     
    829777        INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
    830778                                       attrib, combo );
    831         lstrcpyAtoW( spec, specA );
     779        MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff );
    832780        HeapFree( GetProcessHeap(), 0, specA );
    833781        return ret;
     
    835783    return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
    836784}
    837 //******************************************************************************
    838 //******************************************************************************
    839 
     785
     786
     787/**********************************************************************
     788 *              DlgDirSelectExA (USER32.@)
     789 */
     790BOOL 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 */
     799BOOL 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 */
     808BOOL 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 */
     818BOOL 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 */
     828INT 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 */
     838INT 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 */
     848INT 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 */
     858INT 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.