Changeset 45

Show
Ignore:
Timestamp:
03/04/08 12:51:16 (6 months ago)
Author:
Chris Miller
Message:

Fixed actctx issue with Windows (ImageList? now shows with XP-styles)

Files:

Legend:

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

    r42 r45  
    238238                                            activateActCtx(hac, &ul); 
    239239                                             
    240                                             _initCommonControls(ICC_STANDARD_CLASSES); 
     240                                            _initCommonControls(ICC_STANDARD_CLASSES); // Yes. 
     241                                            //InitCommonControls(); // No. Doesn't work with common controls version 6! 
    241242                                             
    242                                             /+ // Not helping. 
    243                                             // Fix issue with image lists now showing... 
    244                                             PostMessageA(null, wmDfl, 0, 0); // Posts to this thread. 
    245                                             //Application.doEvents(); 
     243                                            // Ensure the actctx is actually associated with the message queue... 
     244                                            PostMessageA(null, wmDfl, 0, 0); 
    246245                                            { 
    247246                                                MSG msg; 
    248                                                 GetMessageA(&msg, null, wmDfl, wmDfl); 
     247                                                PeekMessageA(&msg, null, wmDfl, wmDfl, PM_REMOVE); 
    249248                                            } 
    250                                             +/ 
    251249                                        } 
    252250                                        else 
  • trunk/win32/dfl/imagelist.d

    r44 r45  
    6767         
    6868         
     69        import std.string: format; 
     70        import dfl.messagebox : msgBox; 
    6971        void _added(size_t idx, Image val) 
    7072        { 
    7173            if(isHandleCreated) 
    7274            { 
    73                 if(idx >= _images.length) 
     75                //if(idx >= _images.length) // Can't test for this here because -val- is already added to the array. 
     76                _addimg(val); 
     77            } 
     78        } 
     79         
     80         
     81        void _removed(size_t idx, Image val) 
     82        { 
     83            if(isHandleCreated) 
     84            { 
     85                if(size_t.max == idx) // Clear all. 
    7486                { 
    75                     _addimg(val); 
     87                    imageListRemove(handle, -1); 
    7688                } 
    7789                else 
    7890                { 
    79                     assert(0); 
    80                 } 
    81             } 
    82         } 
    83          
    84          
    85         void _removed(size_t idx, Image val) 
    86         { 
    87             if(isHandleCreated) 
    88             { 
    89                 if(size_t.max == idx) // Clear all. 
    90                 { 
    91                     ImageList_Remove(handle, -1); 
    92                 } 
    93                 else 
    94                 { 
    95                     ImageList_Remove(handle, idx); 
     91                    imageListRemove(handle, idx); 
    9692                } 
    9793            } 
     
    110106    this() 
    111107    { 
     108        InitCommonControls(); 
     109         
    112110        _cimages = new ImageCollection(); 
    113111        _transcolor = Color.transparent; 
     
    181179     
    182180     
     181    /+ // Actually, forget about these; just draw with the actual images. 
    183182    /// 
    184183    final void draw(Graphics g, Point pt, int index) 
     
    190189    final void draw(Graphics g, int x, int y, int index) 
    191190    { 
    192         ImageList_Draw(handle, index, g.handle, x, y, ILD_NORMAL); 
     191        imageListDraw(handle, index, g.handle, x, y, ILD_NORMAL); 
    193192    } 
    194193     
     
    204203            return; 
    205204         
    206         ImageList_DrawEx(handle, index, g.handle, x, y, width, height, 
     205        imageListDrawEx(handle, index, g.handle, x, y, width, height, 
    207206            CLR_NONE, CLR_NONE, ILD_NORMAL); // ? 
    208207    } 
     208    +/ 
    209209     
    210210     
     
    237237    { 
    238238        if(isHandleCreated) 
    239             ImageList_Destroy(_hil); 
     239            imageListDestroy(_hil); 
    240240        _hil = HIMAGELIST.init; 
    241241         
     
    268268        if(isHandleCreated) 
    269269        { 
    270             ImageList_Destroy(_hil); 
     270            imageListDestroy(_hil); 
    271271            _hil = HIMAGELIST.init; 
    272272        } 
     
    283283         
    284284        // Note: cGrow is not a limit, but how many images to preallocate each grow. 
    285         _hil = ImageList_Create(_w, _h, flags, _cimages._images.length, 4 + _cimages._images.length / 4); 
     285        _hil = imageListCreate(_w, _h, flags, _cimages._images.length, 4 + _cimages._images.length / 4); 
    286286        if(!_hil) 
    287287            throw new Exception("Unable to create image list"); 
     
    320320                        cr = _transcolor.toRgb(); 
    321321                    } 
    322                     result = ImageList_AddMasked(_hil, cast(HBITMAP)hgo, cr); 
     322                    result = imageListAddMasked(_hil, cast(HBITMAP)hgo, cr); 
    323323                } 
    324324                break; 
    325325             
    326326            case 2: 
    327                 result = ImageList_AddIcon(_hil, cast(HICON)hgo); 
     327                result = imageListAddIcon(_hil, cast(HICON)hgo); 
    328328                break; 
    329329             
     
    337337} 
    338338 
     339 
     340private extern(Windows) 
     341{ 
     342    // This was the only way I could figure out how to use the current actctx (Windows issue). 
     343     
     344    HIMAGELIST imageListCreate( 
     345        int cx, int cy, UINT flags, int cInitial, int cGrow) 
     346    { 
     347        alias typeof(&ImageList_Create) TProc; 
     348        static TProc proc = null; 
     349        if(!proc) 
     350            proc = cast(typeof(proc))GetProcAddress(GetModuleHandleA("comctl32.dll"), "ImageList_Create"); 
     351        return proc(cx, cy, flags, cInitial, cGrow); 
     352    } 
     353     
     354    int imageListAddIcon( 
     355        HIMAGELIST himl, HICON hicon) 
     356    { 
     357        alias typeof(&ImageList_AddIcon) TProc; 
     358        static TProc proc = null; 
     359        if(!proc) 
     360            proc = cast(typeof(proc))GetProcAddress(GetModuleHandleA("comctl32.dll"), "ImageList_AddIcon"); 
     361        return proc(himl, hicon); 
     362    } 
     363     
     364    int imageListAddMasked( 
     365        HIMAGELIST himl, HBITMAP hbmImage, COLORREF crMask) 
     366    { 
     367        alias typeof(&ImageList_AddMasked) TProc; 
     368        static TProc proc = null; 
     369        if(!proc) 
     370            proc = cast(typeof(proc))GetProcAddress(GetModuleHandleA("comctl32.dll"), "ImageList_AddMasked"); 
     371        return proc(himl, hbmImage, crMask); 
     372    } 
     373     
     374    BOOL imageListRemove( 
     375        HIMAGELIST himl, int i) 
     376    { 
     377        alias typeof(&ImageList_Remove) TProc; 
     378        static TProc proc = null; 
     379        if(!proc) 
     380            proc = cast(typeof(proc))GetProcAddress(GetModuleHandleA("comctl32.dll"), "ImageList_Remove"); 
     381        return proc(himl, i); 
     382    } 
     383     
     384    BOOL imageListDestroy( 
     385        HIMAGELIST himl) 
     386    { 
     387        alias typeof(&ImageList_Destroy) TProc; 
     388        static TProc proc = null; 
     389        if(!proc) 
     390            proc = cast(typeof(proc))GetProcAddress(GetModuleHandleA("comctl32.dll"), "ImageList_Destroy"); 
     391        return proc(himl); 
     392    } 
     393} 
     394