- Commented out unused code.

- Code cleanup.
This commit is contained in:
spx 2010-12-25 08:43:26 +00:00
parent 34160d4038
commit a32ca014f7
2 changed files with 101 additions and 103 deletions

View File

@ -36,8 +36,8 @@ FPGETLITESTEPWND fpGetLitestepWnd = NULL;
typedef BOOL (*FPGETRCSTRING)(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen); typedef BOOL (*FPGETRCSTRING)(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen);
FPGETRCSTRING fpGetRCString = NULL; FPGETRCSTRING fpGetRCString = NULL;
typedef int (*FPGETRCINT)(LPCSTR lpKeyName, int nDefault); //typedef int (*FPGETRCINT)(LPCSTR lpKeyName, int nDefault);
FPGETRCINT fpGetRCInt = NULL; //FPGETRCINT fpGetRCInt = NULL;
typedef HINSTANCE (*FPLSEXECUTE)(HWND Owner, LPCSTR szCommand, int nShowCmd); typedef HINSTANCE (*FPLSEXECUTE)(HWND Owner, LPCSTR szCommand, int nShowCmd);
FPLSEXECUTE fpLSExecute = NULL; FPLSEXECUTE fpLSExecute = NULL;
@ -45,8 +45,8 @@ FPLSEXECUTE fpLSExecute = NULL;
typedef BOOL (*FPREMOVEBANGCOMMAND)(LPCSTR command); typedef BOOL (*FPREMOVEBANGCOMMAND)(LPCSTR command);
FPREMOVEBANGCOMMAND fpRemoveBangCommand = NULL; FPREMOVEBANGCOMMAND fpRemoveBangCommand = NULL;
typedef void (*FPTRANSPARENTBLTLS)(HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent); //typedef void (*FPTRANSPARENTBLTLS)(HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent);
FPTRANSPARENTBLTLS fpTransparentBltLS = NULL; //FPTRANSPARENTBLTLS fpTransparentBltLS = NULL;
typedef void (*FPVAREXPANSION)(LPSTR buffer, LPCSTR value); typedef void (*FPVAREXPANSION)(LPSTR buffer, LPCSTR value);
FPVAREXPANSION fpVarExpansion = NULL; FPVAREXPANSION fpVarExpansion = NULL;
@ -71,10 +71,10 @@ void InitalizeLitestep()
fpBitmapToRegion = (FPBITMAPTOREGION)GetProcAddress(h, "BitmapToRegion"); fpBitmapToRegion = (FPBITMAPTOREGION)GetProcAddress(h, "BitmapToRegion");
fpGetLitestepWnd = (FPGETLITESTEPWND)GetProcAddress(h, "GetLitestepWnd"); fpGetLitestepWnd = (FPGETLITESTEPWND)GetProcAddress(h, "GetLitestepWnd");
fpGetRCString = (FPGETRCSTRING)GetProcAddress(h, "GetRCString"); fpGetRCString = (FPGETRCSTRING)GetProcAddress(h, "GetRCString");
fpGetRCInt = (FPGETRCINT)GetProcAddress(h, "GetRCInt"); //fpGetRCInt = (FPGETRCINT)GetProcAddress(h, "GetRCInt");
fpLSExecute = (FPLSEXECUTE)GetProcAddress(h, "LSExecute"); fpLSExecute = (FPLSEXECUTE)GetProcAddress(h, "LSExecute");
fpRemoveBangCommand = (FPREMOVEBANGCOMMAND)GetProcAddress(h, "RemoveBangCommand"); fpRemoveBangCommand = (FPREMOVEBANGCOMMAND)GetProcAddress(h, "RemoveBangCommand");
fpTransparentBltLS = (FPTRANSPARENTBLTLS)GetProcAddress(h, "TransparentBltLS"); //fpTransparentBltLS = (FPTRANSPARENTBLTLS)GetProcAddress(h, "TransparentBltLS");
fpVarExpansion = (FPVAREXPANSION)GetProcAddress(h, "VarExpansion"); fpVarExpansion = (FPVAREXPANSION)GetProcAddress(h, "VarExpansion");
fpLSLog = (FPLSLOG)GetProcAddress(h, "_LSLog@12"); fpLSLog = (FPLSLOG)GetProcAddress(h, "_LSLog@12");
} }
@ -116,14 +116,14 @@ BOOL GetRCString(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen)
return false; return false;
} }
int GetRCInt(LPCSTR lpKeyName, int nDefault) //int GetRCInt(LPCSTR lpKeyName, int nDefault)
{ //{
// Use the lsapi.dll version of the method if possible // // Use the lsapi.dll version of the method if possible
if (fpGetRCInt) return fpGetRCInt(lpKeyName, nDefault); // if (fpGetRCInt) return fpGetRCInt(lpKeyName, nDefault);
//
// The stub implementation // // The stub implementation
return nDefault; // return nDefault;
} //}
void VarExpansion(LPSTR buffer, LPCSTR value) void VarExpansion(LPSTR buffer, LPCSTR value)
{ {
@ -218,17 +218,15 @@ HRGN BitmapToRegion(HBITMAP hbm, COLORREF clrTransp, COLORREF clrTolerance, int
while ( x < bm.bmWidth ) while ( x < bm.bmWidth )
{ {
p = p32 + 4 * x; p = p32 + 4 * x;
// if the pixel is non-transparent // if the pixel is non-transparent
{ if (*p < clrLoB || *p > clrHiB)
bool isOpaque = *p < clrLoB || *p > clrHiB; break;
p++; p++;
isOpaque |= *p < clrLoG || *p > clrHiG; if (*p < clrLoG || *p > clrHiG)
p++; break;
isOpaque |= *p < clrLoR || *p > clrHiR; p++;
if (isOpaque) if (*p < clrLoR || *p > clrHiR)
break; break;
}
x++; x++;
} }
@ -252,7 +250,7 @@ HRGN BitmapToRegion(HBITMAP hbm, COLORREF clrTransp, COLORREF clrTolerance, int
x++; x++;
} }
// if found one or more non-transparent pixels in a row, add them to the rgn... // if found one or more non-transparent pixels in a row, add them to the rgn...
if ((x - x0) > 0) if (x != x0)
{ {
HRGN hTempRgn = CreateRectRgn(x0 + xoffset, y + yoffset, x + xoffset, y + 1 + yoffset); HRGN hTempRgn = CreateRectRgn(x0 + xoffset, y + yoffset, x + xoffset, y + 1 + yoffset);
CombineRgn(hRgn, hRgn, hTempRgn, RGN_OR); CombineRgn(hRgn, hRgn, hTempRgn, RGN_OR);
@ -385,81 +383,81 @@ HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR sz
return si.hInstApp; return si.hInstApp;
} }
void TransparentBltLS(HDC hdcDst, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, COLORREF colorTransparent) //void TransparentBltLS(HDC hdcDst, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, COLORREF colorTransparent)
{ //{
// Use the lsapi.dll version of the method if possible // // Use the lsapi.dll version of the method if possible
if (fpTransparentBltLS) // if (fpTransparentBltLS)
{ // {
fpTransparentBltLS(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, colorTransparent); // fpTransparentBltLS(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, colorTransparent);
} // }
else // else
{ // {
HDC hdcMem, hdcMask, hdcDstCpy; // HDC hdcMem, hdcMask, hdcDstCpy;
HBITMAP hbmMask, hbmMem, hbmDstCpy; // HBITMAP hbmMask, hbmMem, hbmDstCpy;
HBITMAP hbmOldMem, hbmOldMask, hbmOldDstCpy; // HBITMAP hbmOldMem, hbmOldMask, hbmOldDstCpy;
//
// create a destination compatble dc containing // // create a destination compatble dc containing
// a copy of the destination dc // // a copy of the destination dc
hdcDstCpy = CreateCompatibleDC(hdcDst); // hdcDstCpy = CreateCompatibleDC(hdcDst);
hbmDstCpy = CreateCompatibleBitmap(hdcDst, nWidth, nHeight); // hbmDstCpy = CreateCompatibleBitmap(hdcDst, nWidth, nHeight);
hbmOldDstCpy = (HBITMAP)SelectObject(hdcDstCpy, hbmDstCpy); // hbmOldDstCpy = (HBITMAP)SelectObject(hdcDstCpy, hbmDstCpy);
//
BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcDst, nXDest, nYDest, SRCCOPY); // BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcDst, nXDest, nYDest, SRCCOPY);
//
// create a destination compatble dc containing // // create a destination compatble dc containing
// a copy of the source dc // // a copy of the source dc
hdcMem = CreateCompatibleDC(hdcDst); // hdcMem = CreateCompatibleDC(hdcDst);
hbmMem = CreateCompatibleBitmap(hdcDst, nWidth, nHeight); // hbmMem = CreateCompatibleBitmap(hdcDst, nWidth, nHeight);
hbmOldMem = (HBITMAP)SelectObject(hdcMem, hbmMem); // hbmOldMem = (HBITMAP)SelectObject(hdcMem, hbmMem);
//
BitBlt(hdcMem, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY); // BitBlt(hdcMem, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY);
//
// the transparent color should be selected as // // the transparent color should be selected as
// bkcolor into the memory dc // // bkcolor into the memory dc
SetBkColor(hdcMem, colorTransparent); // SetBkColor(hdcMem, colorTransparent);
//
// Create monochrome bitmap for the mask // // Create monochrome bitmap for the mask
hdcMask = CreateCompatibleDC(hdcDst); // hdcMask = CreateCompatibleDC(hdcDst);
hbmMask = CreateBitmap(nWidth, nHeight, 1, 1, NULL); // hbmMask = CreateBitmap(nWidth, nHeight, 1, 1, NULL);
hbmOldMask = (HBITMAP)SelectObject(hdcMask, hbmMask); // hbmOldMask = (HBITMAP)SelectObject(hdcMask, hbmMask);
//
// Create the mask from the memory dc // // Create the mask from the memory dc
BitBlt(hdcMask, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY); // BitBlt(hdcMask, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
//
// Set the background in hdcMem to black. Using SRCPAINT with black // // Set the background in hdcMem to black. Using SRCPAINT with black
// and any other color results in the other color, thus making // // and any other color results in the other color, thus making
// black the transparent color // // black the transparent color
SetBkColor(hdcMem, RGB(0, 0, 0)); // SetBkColor(hdcMem, RGB(0, 0, 0));
SetTextColor(hdcMem, RGB(255, 255, 255)); // SetTextColor(hdcMem, RGB(255, 255, 255));
//
BitBlt(hdcMem, 0, 0, nWidth, nHeight, hdcMask, 0, 0, SRCAND); // BitBlt(hdcMem, 0, 0, nWidth, nHeight, hdcMask, 0, 0, SRCAND);
//
// Set the foreground to black. See comment above. // // Set the foreground to black. See comment above.
SetBkColor(hdcDst, RGB(255, 255, 255)); // SetBkColor(hdcDst, RGB(255, 255, 255));
SetTextColor(hdcDst, RGB(0, 0, 0)); // SetTextColor(hdcDst, RGB(0, 0, 0));
//
BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcMask, 0, 0, SRCAND); // BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcMask, 0, 0, SRCAND);
//
// Combine the foreground with the background // // Combine the foreground with the background
BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCPAINT); // BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCPAINT);
//
// now we have created the image we want to blt // // now we have created the image we want to blt
// in the destination copy dc // // in the destination copy dc
BitBlt(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcDstCpy, 0, 0, SRCCOPY); // BitBlt(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcDstCpy, 0, 0, SRCCOPY);
//
SelectObject(hdcMask, hbmOldMask); // SelectObject(hdcMask, hbmOldMask);
DeleteObject(hbmMask); // DeleteObject(hbmMask);
DeleteDC(hdcMask); // DeleteDC(hdcMask);
//
SelectObject(hdcMem, hbmOldMem); // SelectObject(hdcMem, hbmOldMem);
DeleteObject(hbmMem); // DeleteObject(hbmMem);
DeleteDC(hdcMem); // DeleteDC(hdcMem);
//
SelectObject(hdcDstCpy, hbmOldDstCpy); // SelectObject(hdcDstCpy, hbmOldDstCpy);
DeleteObject(hbmDstCpy); // DeleteObject(hbmDstCpy);
DeleteDC(hdcDstCpy); // DeleteDC(hdcDstCpy);
} // }
} //}
std::string ConvertToAscii(LPCTSTR str) std::string ConvertToAscii(LPCTSTR str)
{ {

View File

@ -40,12 +40,12 @@ BOOL AddBangCommand(LPCSTR command, BangCommand f);
HRGN BitmapToRegion(HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance, int xoffset, int yoffset); HRGN BitmapToRegion(HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance, int xoffset, int yoffset);
HWND GetLitestepWnd(void); HWND GetLitestepWnd(void);
BOOL GetRCString(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen); BOOL GetRCString(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen);
int GetRCInt(LPCSTR lpKeyName, int nDefault); //int GetRCInt(LPCSTR lpKeyName, int nDefault);
HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd); HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd);
BOOL RemoveBangCommand(LPCSTR command); BOOL RemoveBangCommand(LPCSTR command);
void TransparentBltLS (HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent); //void TransparentBltLS (HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent);
void VarExpansion(LPSTR buffer, LPCSTR value); void VarExpansion(LPSTR buffer, LPCSTR value);
void LSSetVariable(const BSTR name, const BSTR value); //void LSSetVariable(const BSTR name, const BSTR value);
void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved); void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved);