Ignore:
Timestamp:
Jul 21, 2008, 12:51:44 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

CreateGrayIconで落ちることがあったので、エラーチェックをしっかりと行うようにした。user32.libをGetModuleHandleで得るように変更。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/abdev/SubOperation.cpp

    r681 r698  
    66
    77void ScreenToClient(HWND hwnd,RECT *pRect){
    8     ScreenToClient(hwnd,(POINT *)pRect);
    9     ScreenToClient(hwnd,(POINT *)(((long)(void *)pRect)+sizeof(POINT)));
     8    ScreenToClient(hwnd,reinterpret_cast<POINT*>(pRect));
     9    ScreenToClient(hwnd,reinterpret_cast<POINT*>(reinterpret_cast<char*>(pRect)+sizeof(POINT)));
    1010}
    1111void ClientToScreen(HWND hwnd,RECT *pRect){
    12     ClientToScreen(hwnd,(POINT *)pRect);
    13     ClientToScreen(hwnd,(POINT *)(((long)(void *)pRect)+sizeof(POINT)));
     12    ClientToScreen(hwnd,reinterpret_cast<POINT*>(pRect));
     13    ClientToScreen(hwnd,reinterpret_cast<POINT*>(reinterpret_cast<char*>(pRect)+sizeof(POINT)));
    1414}
    1515
     
    556556
    557557    ICONINFO IconInfo;
    558     GetIconInfo(hBaseIcon,&IconInfo);
    559 
     558    if(GetIconInfo(hBaseIcon,&IconInfo) == FALSE){
     559        return 0;
     560    }
    560561
    561562    //ビットマップを加工
    562563    BITMAP Bitmap;
    563     GetObject(IconInfo.hbmColor,sizeof(Bitmap),&Bitmap);
     564    if(GetObject(IconInfo.hbmColor,sizeof(Bitmap),&Bitmap) == 0){
     565        return 0;
     566    }
    564567
    565568    BITMAPINFO BitmapInfo;
     
    572575    BitmapInfo.bmiHeader.biCompression=BI_RGB;
    573576
    574     HDC hdc;
    575     hdc=GetDC(GetDesktopWindow());
    576 
    577     BYTE *pByte;
    578     pByte=(BYTE *)HeapAlloc(hHeap,0,Bitmap.bmWidth*Bitmap.bmHeight*sizeof(COLORREF));
     577    HDC hdc=GetDC(0);
     578
     579    BYTE *pByte=(BYTE *)HeapAlloc(hHeap,0,Bitmap.bmWidth*Bitmap.bmHeight*sizeof(COLORREF));
     580    if(pByte==0){
     581        return 0;
     582    }
    579583    GetDIBits(hdc,
    580584        IconInfo.hbmColor,
     
    741745    extern FWINLAYER pSetLayeredWindowAttributes;
    742746    extern HINSTANCE hUser32Lib;
    743     hUser32Lib=LoadLibrary("user32.dll");
    744     pSetLayeredWindowAttributes=(FWINLAYER)GetProcAddress(hUser32Lib,"pSetLayeredWindowAttributes");
     747    hUser32Lib=GetModuleHandle("user32.dll");
     748    pSetLayeredWindowAttributes=reinterpret_cast<FWINLAYER>(GetProcAddress(hUser32Lib,"SetLayeredWindowAttributes"));
    745749
    746750
     
    11651169    FreeLibrary(hIconResInst);
    11661170    FreeLibrary(hLib_LuxCtrl);
    1167 
    1168     //アルファブレンド用のAPIを解放
    1169     extern HINSTANCE hUser32Lib;
    1170     FreeLibrary(hUser32Lib);
    11711171}
    11721172
     
    12531253            }
    12541254            else{
    1255                 if(hFind=FindFirstFile(MdiInfo[WndNum]->path.c_str(),&wfd)){
    1256                     if(hFind==INVALID_HANDLE_VALUE){
    1257                         if(!SaveDocument(hChild,NULL)) return 0;
    1258                     }
    1259                     else FindClose(hFind);
     1255                hFind=FindFirstFile(MdiInfo[WndNum]->path.c_str(),&wfd);
     1256                if(hFind==INVALID_HANDLE_VALUE){
     1257                    if(!SaveDocument(hChild,NULL)) return 0;
    12601258                }
     1259                else FindClose(hFind);
    12611260            }
    12621261        }
Note: See TracChangeset for help on using the changeset viewer.