Changeset 53

Show
Ignore:
Timestamp:
03/14/08 18:30:18 (7 months ago)
Author:
Chris Miller
Message:

Added to dfl.resources
Other minor changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/win32/dfl/base.d

    r51 r53  
    12221222    void dispose() 
    12231223    { 
     1224        assert(owned); 
    12241225        DestroyCursor(hcur); 
    12251226        hcur = HCURSOR.init; 
  • trunk/win32/dfl/control.d

    r51 r53  
    10521052     
    10531053     
     1054    /+ 
    10541055    deprecated void anchor(AnchorStyles a) // setter 
    10551056    { 
     
    10711072        return cast(AnchorStyles)(AnchorStyles.LEFT | AnchorStyles.TOP); 
    10721073    } 
     1074    +/ 
    10731075     
    10741076     
  • trunk/win32/dfl/drawing.d

    r50 r53  
    10801080    void dispose() 
    10811081    { 
     1082        assert(owned); 
    10821083        DeleteObject(hbm); 
    10831084        hbm = null; 
     
    24412442    void dispose() 
    24422443    { 
     2444        assert(owned); 
    24432445        DeleteDC(hdc); 
    24442446        hdc = null; 
     
    27672769    void dispose() 
    27682770    { 
     2771        assert(owned); 
    27692772        DestroyIcon(hi); 
    27702773        hi = null; 
  • trunk/win32/dfl/internal/winapi.d

    r49 r53  
    27932793    SHORT VkKeyScanW(wchar ch); 
    27942794    HRSRC FindResourceExA(HMODULE hModule, LPCSTR lpType, LPCSTR lpName, WORD wLanguage); 
     2795    HRSRC FindResourceExW(HMODULE hModule, LPCWSTR lpType, LPCWSTR lpName, WORD wLanguage); 
    27952796    HGLOBAL LoadResource(HMODULE hModule, HRSRC hResInfo); 
     2797    DWORD SizeofResource(HMODULE hModule, HRSRC hResInfo); 
    27962798    BOOL EnableMenuItem(HMENU hMenu, UINT uIDEnableItem, UINT uEnable); 
    27972799    BOOL IsMenu(HMENU hMenu); 
  • trunk/win32/dfl/listview.d

    r49 r53  
    25872587    { 
    25882588        //return _ins(index, cast(LPARAM)cast(void*)item, item.text, 0); 
    2589         return _ins(index, cast(LPARAM)cast(void*)item, item.text, 0, item._imgidx); 
     2589        version(DFL_NO_IMAGELIST) 
     2590        { 
     2591            return _ins(index, cast(LPARAM)cast(void*)item, item.text, 0, -1); 
     2592        } 
     2593        else 
     2594        { 
     2595            return _ins(index, cast(LPARAM)cast(void*)item, item.text, 0, item._imgidx); 
     2596        } 
    25902597    } 
    25912598     
  • trunk/win32/dfl/resources.d

    r5 r53  
    4545    void dispose() 
    4646    { 
     47        assert(_owned); 
    4748        //if(hinst != Application.getInstance()) // ? 
    4849            FreeLibrary(hinst); 
     
    99100    } 
    100101     
    101     /+ 
    102102    /// ditto 
    103103    final Icon getIcon(int id, int width, int height) 
     
    132132        return new Icon(hi, true); // Owned. 
    133133    } 
    134     +/ 
    135134     
    136135    deprecated alias getIcon loadIcon; 
     
    205204    body 
    206205    { 
    207         HRSRC hrc; 
    208         hrc = FindResourceExA(hinst, RT_STRING, cast(LPCSTR)cast(WORD)(id / 16 + 1), lang); 
    209         if(!hrc) 
    210             return null; 
    211         HGLOBAL hg; 
    212         LPCWSTR ws; 
    213         char[] result = null; 
    214         hg = LoadResource(hinst, hrc); 
    215         if(!hg) 
    216             return null; 
    217         ws = cast(LPCWSTR)LockResource(hg); 
     206        // Not casting to wchar[] because a resource isn't guaranteed to be the same size. 
     207        wchar* ws = cast(wchar*)_getData(cast(LPCWSTR)RT_STRING, cast(LPCWSTR)cast(WORD)(id / 16 + 1)).ptr; 
     208        char[] result; 
    218209        if(ws) 
    219210        { 
     
    224215            } 
    225216            result = utf16stringtoUtf8string((ws + 1)[0 .. cast(size_t)*ws]); 
    226             //UnlockResource(ws); // Obsolete / stub. 
    227217        } 
    228         FreeResource(hg); // Obsolete / stub. 
    229218        return result; 
    230219    } 
    231220     
    232221    deprecated alias getString loadString; 
     222     
     223     
     224    // Used internally 
     225    final void[] _getData(LPCWSTR type, LPCWSTR name) // internal 
     226    { 
     227        HRSRC hrc; 
     228        hrc = FindResourceExW(hinst, type, name, lang); 
     229        if(!hrc) 
     230            return null; 
     231        HGLOBAL hg = LoadResource(hinst, hrc); 
     232        if(!hg) 
     233            return null; 
     234        LPVOID pv = LockResource(hg); 
     235        if(!pv) 
     236            return null; 
     237        return pv[0 .. SizeofResource(hinst, hrc)]; 
     238    } 
     239     
     240    /// 
     241    final void[] getData(int type, int id) 
     242    in 
     243    { 
     244        assert(type >= WORD.min && type <= WORD.max); 
     245        assert(id >= WORD.min && id <= WORD.max); 
     246    } 
     247    body 
     248    { 
     249        return _getData(cast(LPCWSTR)type, cast(LPCWSTR)id); 
     250    } 
     251     
     252    /// ditto 
     253    final void[] getData(char[] type, int id) 
     254    in 
     255    { 
     256        assert(id >= WORD.min && id <= WORD.max); 
     257    } 
     258    body 
     259    { 
     260        return _getData(utf8stringToUtf16stringz(type), cast(LPCWSTR)id); 
     261    } 
     262     
     263    /// ditto 
     264    final void[] getData(int type, char[] name) 
     265    in 
     266    { 
     267        assert(type >= WORD.min && type <= WORD.max); 
     268    } 
     269    body 
     270    { 
     271        return _getData(cast(LPCWSTR)type, utf8stringToUtf16stringz(name)); 
     272    } 
     273     
     274    /// ditto 
     275    final void[] getData(char[] type, char[] name) 
     276    { 
     277        return _getData(utf8stringToUtf16stringz(type), utf8stringToUtf16stringz(name)); 
     278    } 
    233279     
    234280     
     
    247293     
    248294     
    249     /+ 
    250295    void _noload(char[] type) 
    251296    { 
    252297        throw new DflException("Unable to load " ~ type ~ " resource"); 
    253298    } 
    254     +/ 
    255299} 
    256300 
  • trunk/win32/dfl/splitter.d

    r49 r53  
    8181     
    8282     
     83    /+ 
    8384    override void anchor(AnchorStyles a) // setter 
    8485    { 
     
    8788     
    8889    alias Control.anchor anchor; // Overload. 
     90    +/ 
    8991     
    9092