123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808 |
- /*
- * IRS Skin Library
- * Designed by Kilo(110i@110i.net)
- * (C)CopyRight, 2003-2004, IRS, All Right Reserved
- * iRacer.Studio - HttP://wWw.110i.nEt
- */
- #include "stdafx.h"
- #include "library.h"
- #include "YLGL.h"
- #include "BitmapEx.h"
- #include "DialogExt.h"
- #include "CheckBoxExt.h"
- #include "RadioExt.h"
- #include "ComboBoxExt.h"
- #include "ScrollBarExt.h"
- #include "ButtonExt.h"
- #include "EditExt.h"
- #include "GroupBoxExt.h"
- #include ".\scrollbar\coolscroll.h"
- #include ".\scrollbar\coolsb_detours.h"
- #pragma comment (lib, "coolsb.lib")
- #pragma comment (lib, "detours.lib")
- #pragma comment (lib, "coolsb_detours.lib")
- #pragma comment(lib, "Msimg32.lib")
- HHOOK globalWndHookEx;
- BOOL g_bDrawBk=0;
- CMapPtrToPtr g_ctrlMap;//保存对话框状态 DrawScrollBars
- CArray<DWORD,DWORD>g_wndstatelist;//窗口状态
- COLORREF g_crDialogbkColor=0 ; // 窗口背景颜色
- HBRUSH g_frameedgebrush=NULL; //窗口边框颜色画刷
- HPEN g_frameedgepen=NULL; //窗口边框颜色画笔
- BOOL bReg=0;
- HINSTANCE g_dllinst;
- HINSTANCE g_maininst;
- #define SCROLLAREA 0 //滚动条区域
- #define SCROLLTOPARROW 1 //上箭头
- #define SCROLLBOTTOMARROW 2 //下箭头
- #define SCROLLLEFTARROW 3 //左箭头
- #define SCROLLRIGHTARROW 4 //右箭头
- #define SCROLLTHUMB 5 //移动块
- #define SCROLLAREANULL 6 //滚动条空区域
- #define SCROLLALL 7 //所有区域
- // SCROLLXP 结构,所有的代码都是围绕这个结构而编写的 DrawScrollBars
- typedef struct tagSCROLLXP
- {
- RECT m_ThumbRect;
- RECT m_ThumbRectOld;
- RECT m_BottomArrowRect;
- RECT m_TopArrowRect;
- RECT m_LeftArrowRect;
- RECT m_RightArrowRect;
- RECT m_SizeArea;
- RECT m_AreaRect ;
- BOOL m_bMouseDownArrowForback; //上移
- BOOL m_bMouseDownArrowForwad; //下移
- BOOL m_bMouseDown;
- POINT m_MouseDownPoint;
- UINT m_MouseDownTime;
- BOOL m_bDragging; //正在拖动
- UINT m_nThumbTrackPos;
- }SCROLLXP, * PSCROLLXP;
- COLORREF gChecks_crGradientXP[][4] =
- {
- {0x00A5B2B5, 0x00CED7D6, 0x00CED7D6, 0x00DEEFF7},
- {0x00CEF3FF, 0x0063CBFF, 0x0063CBFF, 0x0031B2FF},
- {0x00D6DFDE, 0x00EFF3F7, 0x00EFF3F7, 0x00FFFFFF},
- {0x0021A221, 0x0021A221, 0x00187A18, 0x00187A18},
- };
- int FindPos(DWORD str, CArray<DWORD,DWORD> &array)
- {
- int count=array.GetSize ();
- for(int i=0; i<count; i++)
- {
- if(str==array.ElementAt (i))
- return i;
- }
- return -1;
- }
- int GetPosFromHwnd(HWND hWnd)
- {
- return FindPos((DWORD)hWnd, g_wndstatelist);
- }
- // 绘制渐变矩形 ReleaseMemDCXP
- VOID GradientRectXP(HDC hDC, LPRECT pRect,COLORREF crColor[4])
- {
- int i;
- TRIVERTEX Tve[4];
- GRADIENT_RECT GRect;
- GRADIENT_TRIANGLE GTrg;
- for (i = 0; i < 4; i++)
- {
- Tve[i].Red = ((COLOR16) GetRValue(crColor[i])) << 8;
- Tve[i].Green = ((COLOR16) GetGValue(crColor[i])) << 8;
- Tve[i].Blue = ((COLOR16) GetBValue(crColor[i])) << 8;
- Tve[i].Alpha = ((COLOR16) (crColor[i] >> 24)) << 8;
- }
- Tve[0].x = pRect->left;
- Tve[0].y = pRect->top;
- Tve[1].x = pRect->right;
- Tve[1].y = pRect->top;
- Tve[2].x = pRect->left;
- Tve[2].y = pRect->bottom;
- Tve[3].x = pRect->right;
- Tve[3].y = pRect->bottom;
- if ((crColor[0] == crColor[2]) &&
- (crColor[1] == crColor[3]))
- i = GRADIENT_FILL_RECT_H;
- if ((crColor[0] == crColor[1]) &&
- (crColor[2] == crColor[3]))
- i = GRADIENT_FILL_RECT_V;
- else
- i = GRADIENT_FILL_TRIANGLE;
- if (i == GRADIENT_FILL_TRIANGLE)
- {
- GTrg.Vertex1 = 0;
- GTrg.Vertex2 = 1;
- GTrg.Vertex3 = 2;
- }
- else
- {
- GRect.UpperLeft = 0;
- GRect.LowerRight = 3;
- }
- GradientFill(hDC, Tve, 4,
- ((i == GRADIENT_FILL_TRIANGLE) ? ((PVOID) >rg) : ((PVOID) &GRect)), 1, i);
- if (i == GRADIENT_FILL_TRIANGLE)
- {
- GTrg.Vertex1 = 3;
- GradientFill(hDC,Tve, 4, >rg, 1, GRADIENT_FILL_TRIANGLE);
- }
- }
- // 绘制 Thumb 块
- VOID ScrollDrowThumbXP(HDC hDC, RECT Rect, LONG lState)
- {
- int i;
- HANDLE hHandle;
- static COLORREF s_crGradientXP[][4] =
- {
- {0x00EFF3F7, 0x00DEE7E7, 0x00DEE3E7, 0x00DEE3E7},
- {0x00DEAEA5, 0x00F7CBBD, 0x00DE8273, 0x00F7C7B5},
- {0x00EFC7B5, 0x00E7AE94, 0x00DEA284, 0x00DEA68C},
- {0x00FFE3D6, 0x00F7CBBD, 0x00F7C3AD, 0x00F7C7B5},
- {0x00F7F7F7, 0x00EFF3F7, 0x00EFF3F7, 0x00EFF3F7},
- {0x00DEC3BD, 0x00DEB6AD, 0x00FFE3DE, 0x00F7E3DE},
- {0x00EFDBCE, 0x00EFCFC6, 0x00E7CFC6, 0x00E7CBBD},
- {0x00FFEFE7, 0x00FFE7DE, 0x00FFE3DE, 0x00F7E3DE},
- {0x00F7F7F7, 0x00E7EFEF, 0x00E7EBEF, 0x00DEE7E7},
- {0x00F78E6B, 0x00F79684, 0x00EF9E8C, 0x00EFDFD6},
- {0x00FFFFFF, 0x00FFE3CE, 0x00FFDFC6, 0x00FFDBBD},
- {0x00FFEBE7, 0x00FFCFBD, 0x00FFCBB5, 0x00F7CBAD},
- {0x00EFF3F7, 0x00DEE7E7, 0x00EFF3F7, 0x00DEE3E7},//水平滚条
- {0x00DEAEA5, 0x00F7CBBD, 0x00DEAEA5, 0x00F7C7B5},
- {0x00EFC7B5, 0x00E7AE94, 0x00EFC7B5, 0x00DEA68C},
- {0x00FFE3D6, 0x00F7CBBD, 0x00FFE3D6, 0x00F7C7B5},
- {0x00DEE7E7, 0x00DEE7E7, 0x00DEE3E7, 0x00DEE3E7},//垂直滚条
- {0x00F7CBBD, 0x00F7CBBD, 0x00DE8273, 0x00F7C7B5},
- {0x00EFC7B5, 0x00EFC7B5, 0x00E7AE94, 0x00DEA68C},
- {0x00F7CBBD, 0x00F7CBBD, 0x00F7C3AD, 0x00F7C7B5},
- };
- if (lState & CXPH_HASFRAME) //画外框阴影
- {
- Rect.right--;
- Rect.bottom--;
- FrameRect(hDC, &Rect, (HBRUSH )GetStockObject(WHITE_BRUSH));
- hHandle = (HANDLE) SelectObject(hDC,
- CreatePen(PS_SOLID, 1, (lState & CXPS_DISABLED) ? 0x00BDCFCE : 0x00D6B69C));
- MoveToEx(hDC, Rect.right, Rect.top + 2, NULL);
- LineTo(hDC, Rect.right, Rect.bottom - 2);
- LineTo(hDC, Rect.right - 2, Rect.bottom);
- LineTo(hDC, Rect.left + 1, Rect.bottom);
- LineTo(hDC, Rect.left - 1, Rect.bottom - 2);
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- InflateRect(&Rect, -1, -1);
- }
- // 绘制 Thumb 外框
- if (lState & CXPS_DISABLED)
- i = 0;
- else if (lState & CXPS_PRESSED)
- i = 1;
- else if (lState & CXPS_HOTLIGHT)
- i = 2;
- else
- i = 3;
- if(lState & CXPH_AREA) //只绘滚条内区
- {
- i += 12;
- if(lState & CXPS_HORIZON)
- {
- i += 4;
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
- }
- else
- {
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
- }
- return;
- }
- else //画按钮
- {
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
- // 绘制下拉外框拐角像素
- SetPixel(hDC, Rect.left, Rect.top, s_crGradientXP[i + 4][0]);
- SetPixel(hDC, Rect.right - 1, Rect.top, s_crGradientXP[i + 4][1]);
- SetPixel(hDC, Rect.left, Rect.bottom - 1, s_crGradientXP[i + 4][2]);
- SetPixel(hDC, Rect.right - 1, Rect.bottom - 1, s_crGradientXP[i + 4][3]);
- // 绘制 Thumb 内框
- InflateRect(&Rect, -1, -1);
- GradientRectXP(hDC, &Rect, s_crGradientXP[i + 8]);
- }
- // 绘制 Thumb 标志
- Rect.left += (Rect.right - Rect.left) / 2;
- Rect.top += (Rect.bottom - Rect.top) / 2;
- if (lState & CXPH_DROPHANDLE)
- {
- hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1, 0x00FFF7EF));
- for (i = -4; i <= 2; i += 2)
- {
- if (lState & CXPS_HORIZON)
- {
- MoveToEx(hDC, Rect.left + i, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + i, Rect.top + 3);
- }
- else
- {
- MoveToEx(hDC, Rect.left - 3, Rect.top + i, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top + i);
- }
- }
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1, 0x00FFB28C));
- for (i = -3; i <= 3; i += 2)
- {
- if (lState & CXPS_HORIZON)
- {
- MoveToEx(hDC, Rect.left + i, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left + i, Rect.top + 4);
- }
- else
- {
- MoveToEx(hDC, Rect.left - 2, Rect.top + i, NULL);
- LineTo(hDC, Rect.left + 4, Rect.top + i);
- }
- }
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- }
- else
- {
- hHandle = (HANDLE) SelectObject(hDC,
- CreatePen(PS_SOLID, 1, (lState & CXPS_DISABLED) ? 0x00C6CBCE : 0x0084614A));
- if (lState & CXPH_SMALLARROW)
- {
- if (lState & CXPH_LEFTWARDS)
- {
- MoveToEx(hDC, Rect.left - 2, Rect.top, NULL);
- LineTo(hDC, Rect.left - 2, Rect.top + 1);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top + 2);
- MoveToEx(hDC, Rect.left, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 3);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top);
- MoveToEx(hDC, Rect.left + 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top + 4);
- }
- else if (lState & CXPH_UPWARDS)
- {
- MoveToEx(hDC, Rect.left - 3, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left, Rect.top + 1);
- MoveToEx(hDC, Rect.left + 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left + 4, Rect.top + 1);
- MoveToEx(hDC, Rect.left - 2, Rect.top, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top - 1);
- MoveToEx(hDC, Rect.left, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top - 2);
- }
- else if (lState & CXPH_RIGHTWARDS)
- {
- MoveToEx(hDC, Rect.left + 2, Rect.top, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top + 1);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top + 2);
- MoveToEx(hDC, Rect.left, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 3);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top);
- MoveToEx(hDC, Rect.left - 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top + 4);
- }
- else if (lState & CXPH_DOWNWARDS)
- {
- MoveToEx(hDC, Rect.left - 3, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left, Rect.top - 1);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left + 4, Rect.top - 1);
- MoveToEx(hDC, Rect.left - 2, Rect.top, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top);
- MoveToEx(hDC, Rect.left - 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top + 1);
- MoveToEx(hDC, Rect.left, Rect.top + 2, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top + 2);
- }
- }
- else if (lState & CXPH_LARGEARROW)
- {
- if (lState & CXPH_LEFTWARDS)
- {
- MoveToEx(hDC, Rect.left + 1, Rect.top - 4, NULL);
- LineTo(hDC, Rect.left - 3, Rect.top);
- LineTo(hDC, Rect.left + 2, Rect.top + 5);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left - 2, Rect.top);
- LineTo(hDC, Rect.left + 2, Rect.top + 4);
- MoveToEx(hDC, Rect.left + 2, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top);
- LineTo(hDC, Rect.left + 3, Rect.top + 4);
- }
- else if (lState & CXPH_UPWARDS)
- {
- MoveToEx(hDC, Rect.left - 4, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left, Rect.top - 3);
- LineTo(hDC, Rect.left + 5, Rect.top + 2);
- MoveToEx(hDC, Rect.left - 3, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left, Rect.top - 2);
- LineTo(hDC, Rect.left + 4, Rect.top + 2);
- MoveToEx(hDC, Rect.left - 3, Rect.top + 2, NULL);
- LineTo(hDC, Rect.left, Rect.top - 1);
- LineTo(hDC, Rect.left + 4, Rect.top + 3);
- }
- else if (lState & CXPH_RIGHTWARDS)
- {
- MoveToEx(hDC, Rect.left - 1, Rect.top - 4, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top);
- LineTo(hDC, Rect.left - 2, Rect.top + 5);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top);
- LineTo(hDC, Rect.left - 2, Rect.top + 4);
- MoveToEx(hDC, Rect.left - 2, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top);
- LineTo(hDC, Rect.left - 3, Rect.top + 4);
- }
- else if (lState & CXPH_DOWNWARDS)
- {
- MoveToEx(hDC, Rect.left - 4, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 2);
- LineTo(hDC, Rect.left + 5, Rect.top - 3);
- MoveToEx(hDC, Rect.left - 3, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 1);
- LineTo(hDC, Rect.left + 4, Rect.top - 3);
- MoveToEx(hDC, Rect.left - 3, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left, Rect.top);
- LineTo(hDC, Rect.left + 4, Rect.top - 4);
- }
- }
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- }
- }
- void DrawScrollBar(HWND m_hWnd, HDC hDC, const RECT& rect, int nType, BOOL bScrollbarCtrl )
- {
- int nScrollSize = GetSystemMetrics( SM_CXHSCROLL );
- // The minimal thumb size depends on the system version
- // For Windows 98 minimal thumb size is a half of scrollbar size
- // and for Windows NT is always 8 pixels regardless of system metrics.
- // I really don't know why.
- int nMinThumbSize;
- if ( GetVersion() & 0x80000000 ) // Windows 98 code
- nMinThumbSize = nScrollSize / 2;
- else
- nMinThumbSize = 8;
- // Calculate the arrow rectangles
- RECT rc1 = rect, rc2 = rect;
- if ( nType == SB_HORZ )
- {
- if ( ( rect.right - rect.left ) < 2 * nScrollSize )
- nScrollSize = ( rect.right - rect.left ) / 2;
- rc1.right = rect.left + nScrollSize;
- rc2.left = rect.right - nScrollSize;
- ScrollDrowThumbXP( hDC, rc1, CXPH_LARGEARROW|CXPH_LEFTWARDS);
- ScrollDrowThumbXP( hDC, rc2, CXPH_LARGEARROW|CXPH_RIGHTWARDS);
- }
- else // SB_VERT
- {
- if ( ( rect.bottom - rect.top ) < 2 * nScrollSize )
- nScrollSize = ( rect.bottom - rect.top ) / 2;
- rc1.bottom = rect.top + nScrollSize;
- rc2.top = rect.bottom - nScrollSize;
- ScrollDrowThumbXP( hDC, rc1, CXPH_LARGEARROW|CXPH_UPWARDS);
- ScrollDrowThumbXP( hDC, rc2, CXPH_LARGEARROW|CXPH_DOWNWARDS);
- }
- // Disabled scrollbar never have a thumb
- if ( bScrollbarCtrl == TRUE && IsWindowEnabled( m_hWnd ) == FALSE )
- return;
- /* SCROLLINFO si;
- si.cbSize = sizeof( SCROLLINFO );
- si.fMask = SIF_ALL;
- GetScrollInfo( m_hWnd, bScrollbarCtrl ? SB_CTL : nType, &si );*/
- int pos=GetPosFromHwnd(m_hWnd);
- if(pos==-1)return;
- pos++;
- MYSCROLL *sb=(MYSCROLL*)g_wndstatelist.ElementAt (pos);
- SCROLLINFO *si=&(sb->VertInfo) ;
- // Calculate the size and position of the thumb
- int nRange = si->nMax - si->nMin + 1;
- if ( nRange )
- {
- int nScrollArea = ( nType == SB_VERT ? ( rect.bottom - rect.top ) : ( rect.right - rect.left ) ) - 2 * nScrollSize;
- int nThumbSize;
- if ( si->nPage == 0 ) // If nPage is not set then thumb has default size
- nThumbSize = GetSystemMetrics( SM_CXHTHUMB );
- else
- nThumbSize = max( MulDiv( si->nPage ,nScrollArea, nRange ), nMinThumbSize );
- if ( nThumbSize >= nScrollArea )
- {
- nThumbSize = nScrollArea;
- if ( bScrollbarCtrl == FALSE )
- return;
- }
- int nThumbPos;
- if ( UINT( nRange ) == si->nPage )
- {
- nThumbPos = 0;
- nThumbSize--;
- }
- else
- nThumbPos = MulDiv( si->nPos - si->nMin, nScrollArea - nThumbSize, nRange - si->nPage );
- if ( nType == SB_VERT )
- {
- rc1.top += nScrollSize + nThumbPos;
- rc1.bottom = rc1.top + nThumbSize;
- }
- else // SB_HORZ
- {
- rc1.left += nScrollSize + nThumbPos;
- rc1.right = rc1.left + nThumbSize;
- }
- if ( nThumbSize <= nScrollArea ) // Don't draw the thumb when it's larger than the scroll area
- {
- ScrollDrowThumbXP( hDC, rc1, CXPH_HASFRAME|CXPH_AREA);
- }
- }
- }
- void DrawScrollBars(HWND m_hWnd, HDC hDC, const RECT& rect )
- {
- const int nFrameSize = GetSystemMetrics( SM_CXEDGE );
- const int nScrollSize = GetSystemMetrics( SM_CXHSCROLL );
- RECT rc;
- // DWORD dwStyle = GetWindowLong( m_hWnd, GWL_STYLE );
- int pos=GetPosFromHwnd(m_hWnd);
- if(pos==-1)return;
- pos++;
- MYSCROLL *sb=(MYSCROLL*)g_wndstatelist.ElementAt (pos);
- DWORD dwStyle = sb->style ;
- if ( dwStyle & WS_HSCROLL && dwStyle & WS_VSCROLL )
- {
- rc.left = rect.left + nFrameSize; rc.top = rect.bottom - nFrameSize - nScrollSize;
- rc.right = rect.right - nFrameSize - nScrollSize; rc.bottom = rect.bottom - nFrameSize;
- DrawScrollBar(m_hWnd, hDC, rc, SB_HORZ );
- rc.left = rect.right - nFrameSize - nScrollSize; rc.top = rect.top + nFrameSize;
- rc.right = rect.right - nFrameSize; rc.bottom = rect.bottom - nFrameSize - nScrollSize;
- DrawScrollBar(m_hWnd, hDC, rc, SB_VERT );
- }
- else if ( dwStyle & WS_VSCROLL )
- {
- rc.left = rect.right - nFrameSize - nScrollSize;
- rc.top = rect.top + nFrameSize;
- rc.right = rect.right - nFrameSize;
- rc.bottom = rect.bottom - nFrameSize;
- DrawScrollBar(m_hWnd, hDC, rc, SB_VERT );
- }
- else if ( dwStyle & WS_HSCROLL )
- {
- rc.left = rect.left + nFrameSize; rc.top = rect.bottom - nFrameSize - nScrollSize;
- rc.right = rect.right - nFrameSize; rc.bottom = rect.bottom - nFrameSize;
- DrawScrollBar(m_hWnd, hDC, rc, SB_HORZ );
- }
- }
- // 获取窗口的内存兼容设备场景
- HDC GetMemDCXP(LPMEMDCXP pMdcxp)
- {
- RECT ctrlRect;
- GetWindowRect(pMdcxp->hWnd, &ctrlRect);
- // 创建兼容内存兼容设备场景并设置为透明模式
- pMdcxp->hDC = GetWindowDC(pMdcxp->hWnd);
- pMdcxp->hMemDC = CreateCompatibleDC(pMdcxp->hDC);;
- SetBkMode(pMdcxp->hMemDC, TRANSPARENT);
- // 是否已经指定了位图句柄
- if (pMdcxp->hBitmap)
- {
- // 选择位图对象
- SelectObject(pMdcxp->hMemDC, pMdcxp->hBitmap);
- }
- else
- {
- // 创建并选择位图对象
- pMdcxp->hBitmap = (HBITMAP) SelectObject(pMdcxp->hMemDC,
- CreateCompatibleBitmap(pMdcxp->hDC, ctrlRect.right - ctrlRect.left, ctrlRect.bottom - ctrlRect.top));
- #ifdef NEW_SKIN
- if(g_pMainWnd2->m_pBk && g_bDrawBk)
- {
- g_bDrawBk=0;
- HWND parenthwnd=::GetParent (pMdcxp->hWnd);
- DWORD style=GetWindowLong(parenthwnd, GWL_STYLE);
- BOOL bInDlg=1;
- if((style & WS_CHILD) == WS_CHILD||(style & WS_CAPTION) != WS_CAPTION)
- {
- bInDlg=0;
- }
- CRect parentrc;
- ::GetClientRect (parenthwnd, parentrc);
- Graphics graph(pMdcxp->hMemDC);
- Rect destinationRect(0,0,ctrlRect.right - ctrlRect.left,ctrlRect.bottom - ctrlRect.top);
- CRect rc=g_pMainWnd2->m_rcarray.ElementAt (16);
- CRect rc2=ctrlRect;
- CPoint pt1,pt2;
- pt1=rc2.TopLeft ();
- pt2=rc2.BottomRight ();
- ::ScreenToClient (::GetParent (pMdcxp->hWnd), &pt1);
- ::ScreenToClient (::GetParent (pMdcxp->hWnd), &pt2);
- rc2.left =pt1.x;
- rc2.top =pt1.y;
- rc2.right =pt2.x;
- rc2.bottom =pt2.y;
- float fscalex=1.0;
- float fscaley=1.0;
- if(bInDlg)
- {
- fscalex=(float)parentrc.Width ()/(float)rc.Width ();
- fscaley=(float)parentrc.Height ()/(float)rc.Height ();
- }
- rc2.left /=fscalex ;
- rc2.right /=fscalex ;
- rc2.top /=fscaley ;
- rc2.bottom /=fscaley ;
- rc2.left +=rc.left ;
- rc2.right +=rc.left ;
- rc2.top +=rc.top ;
- rc2.bottom +=rc.top ;
- rc=rc2;
- rc.left /=g_fscalex;
- rc.right /=g_fscalex;
- rc.top /=g_fscaley;
- rc.bottom /=g_fscaley;
- /* rc.left *=fscalex;
- rc.right *=fscalex;
- rc.top *=fscaley;
- rc.bottom *=fscaley;*/
- graph.DrawImage(g_pMainWnd2->m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel);
- }
- #endif
- // ::FillRect (pMdcxp->hMemDC, CRect(0,0,ctrlRect.right - ctrlRect.left, ctrlRect.bottom - ctrlRect.top), (HBRUSH)::GetStockObject (NULL_BRUSH));
- }
- // 如果要传送数据
- if (pMdcxp->bTransfer == TRUE)
- {
- BitBlt(pMdcxp->hMemDC, 0 , 0,
- ctrlRect.right - ctrlRect.left, ctrlRect.bottom - ctrlRect.top, pMdcxp->hDC, 0 , 0, SRCCOPY);
- }
- return pMdcxp->hMemDC;
- }
- VOID ReleaseMemDCXP(LPMEMDCXP pMdcxp)
- {
- RECT Rect;
- // 如果要传送数据
- if (pMdcxp->bTransfer == TRUE)
- {
- GetWindowRect(pMdcxp->hWnd, &Rect);
- BitBlt(pMdcxp->hDC, 0 , 0,Rect.right - Rect.left, Rect.bottom - Rect.top, pMdcxp->hMemDC, 0 ,0, SRCCOPY);
- }
- if (pMdcxp->hBitmap)
- DeleteObject(SelectObject(pMdcxp->hMemDC, pMdcxp->hBitmap));
- DeleteDC(pMdcxp->hMemDC);
- ReleaseDC(pMdcxp->hWnd, pMdcxp->hDC);
- }
- /*
- * Windows Hook Procduce Routine
- * nCode - hook code
- * wParam - current-process flag
- * lParam - message data
- */
- extern BOOL CALLBACK EnumChildProcDlg(HWND hwnd,LPARAM lParam);
- LRESULT CALLBACK IRCallWndProc( int nCode, WPARAM wParam, LPARAM lParam )
- {
- PCWPSTRUCT pcs = (PCWPSTRUCT) lParam;
- HWND hWnd = pcs->hwnd;
- WNDPROC WndProc;
- if( hWnd )
- {
- char sClassName[201] = "\0";
- GetClassName( hWnd, sClassName, 200 );
- if( strcmp( sClassName, "Button" ) == 0 )
- {
- CWnd *pWnd = CWnd::FromHandle( hWnd );
- DWORD dwStyle = pWnd->GetStyle();
- if ( ( dwStyle & BS_OWNERDRAW ) == BS_OWNERDRAW )
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- else if ( ( dwStyle & BS_GROUPBOX ) == BS_GROUPBOX )//groupbox
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- else if( (dwStyle & SS_TYPEMASK)==BS_DEFPUSHBUTTON || (dwStyle & SS_TYPEMASK)==BS_PUSHBUTTON )
- {
- WNDPROC WndProc;
- WndProc = (WNDPROC) GetWindowLong( hWnd, GWL_WNDPROC );
- if( CButtonExt::m_cWndProc != NULL && WndProc != CButtonExt::m_cWndProc )
- {
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- }
- if( WndProc != (WNDPROC) CButtonExt::DefWindowProc )
- {
- WndProc = (WNDPROC) SetWindowLong( hWnd, GWL_WNDPROC, (LONG) CButtonExt::DefWindowProc );
- CButtonExt::m_cWndProc = WndProc;
- }
- }
- /* else if ( ( dwStyle & BS_AUTOCHECKBOX ) == BS_AUTOCHECKBOX ||
- ( dwStyle & BS_CHECKBOX ) == BS_CHECKBOX ||
- ( dwStyle & BS_3STATE ) == BS_3STATE )//checkbox
- {
- WndProc = (WNDPROC) GetWindowLong( hWnd, GWL_WNDPROC );
- if( CCheckBoxExt::m_cWndProc != NULL && \
- WndProc != CCheckBoxExt::m_cWndProc )
- {
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- }
- if( WndProc != (WNDPROC) CCheckBoxExt::DefWindowProc )
- {
- g_wndstatelist.Add ((DWORD)hWnd);
- g_wndstatelist.Add ((DWORD)0);
- WndProc = (WNDPROC) SetWindowLong( hWnd, GWL_WNDPROC, (LONG) CCheckBoxExt::DefWindowProc );
- CCheckBoxExt::m_cWndProc = WndProc;
- }
- }
- else if ( ( dwStyle & BS_AUTORADIOBUTTON ) == BS_AUTORADIOBUTTON ||
- ( dwStyle & BS_RADIOBUTTON ) == BS_RADIOBUTTON )//radio
- {
- WndProc = (WNDPROC) GetWindowLong( hWnd, GWL_WNDPROC );
- if( CRadioExt::m_cWndProc != NULL && \
- WndProc != CRadioExt::m_cWndProc )
- {
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- }
- if( WndProc != (WNDPROC) CRadioExt::DefWindowProc )
- {
- g_wndstatelist.Add ((DWORD)hWnd);
- g_wndstatelist.Add ((DWORD)0);
- WndProc = (WNDPROC) SetWindowLong( hWnd, GWL_WNDPROC, (LONG) CRadioExt::DefWindowProc );
- CRadioExt::m_cWndProc = WndProc;
- }
- }*/
- }
- else if(0)// strcmp( sClassName, "ComboBox" ) == 0 )//combobox
- {
- WndProc = (WNDPROC) GetWindowLong( hWnd, GWL_WNDPROC );
- if( CComboBoxExt::m_cWndProc != NULL && \
- WndProc != CComboBoxExt::m_cWndProc )
- {
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- }
- if( WndProc != (WNDPROC) CComboBoxExt::DefWindowProc )
- {
- WndProc = (WNDPROC) SetWindowLong( hWnd, GWL_WNDPROC, (LONG) CComboBoxExt::DefWindowProc );
- CComboBoxExt::m_cWndProc = WndProc;
- }
- }
- else if(0)//strcmp( sClassName, "#32770" ) == 0 )//dialog
- {
- CWnd *pWnd = CWnd::FromHandle( hWnd );
- DWORD style=GetWindowLong(hWnd, GWL_STYLE);
- if(0)//(style & WS_CHILD) == WS_CHILD||(style & WS_CAPTION) != WS_CAPTION)
- {
- EnumChildWindows(hWnd,(WNDENUMPROC)EnumChildProcDlg,0);
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- }
- WndProc = (WNDPROC) GetWindowLong( hWnd, GWL_WNDPROC );
- if( WndProc != (WNDPROC) CDialogExt::DefWindowProc )
- {
- WndProc = (WNDPROC) SetWindowLong( hWnd, GWL_WNDPROC, (LONG) CDialogExt::DefWindowProc );
- DWORD style = GetWindowLong( hWnd, GWL_STYLE );
- WNDSTATE *m_wndstate;
- if ( !g_ctrlMap.Lookup( hWnd, (void*&)m_wndstate) )
- {
- m_wndstate=new WNDSTATE;
- m_wndstate->m_sizable =style & WS_SIZEBOX;
- m_wndstate->m_minable =style & WS_MINIMIZEBOX;
- m_wndstate->m_maxable =style & WS_MAXIMIZEBOX;
- m_wndstate->oldWndProc =WndProc;
- g_ctrlMap.SetAt( hWnd, m_wndstate );
- }
- style &= ~WS_MINIMIZEBOX;//去掉最小化钮
- style &= ~WS_MAXIMIZEBOX;
- SetWindowLong( hWnd, GWL_STYLE, style);
- }
- }
- }
- return CallNextHookEx( globalWndHookEx, nCode, wParam, lParam );
- }
- //按钮的外边框
- CPen m_BoundryPen;
- //鼠标指针置于按钮之上时按钮的内边框
- CPen m_InsideBoundryPenLeft;
- CPen m_InsideBoundryPenRight;
- CPen m_InsideBoundryPenTop;
- CPen m_InsideBoundryPenBottom;
- //按钮获得焦点时按钮的内边框
- CPen m_InsideBoundryPenLeftSel;
- CPen m_InsideBoundryPenRightSel;
- CPen m_InsideBoundryPenTopSel;
- CPen m_InsideBoundryPenBottomSel;
- //按钮的底色,包括有效和无效两种状态
- CBrush m_FillActive;
- CBrush m_FillInactive;
- BOOL IRStartup( HINSTANCE hModule, DWORD dwThreadID )
- {//return 1;
- // CoolSB_InitializeApp();
- // CDialogExt::Init();
- m_BoundryPen.CreatePen(PS_INSIDEFRAME | PS_SOLID, 1, RGB(0, 0, 0));
- m_InsideBoundryPenLeft.CreatePen(PS_INSIDEFRAME | PS_SOLID, 3, RGB(250, 196, 88));
- m_InsideBoundryPenRight.CreatePen(PS_INSIDEFRAME | PS_SOLID, 3, RGB(251, 202, 106));
- m_InsideBoundryPenTop.CreatePen(PS_INSIDEFRAME | PS_SOLID, 2, RGB(252, 210, 121));
- m_InsideBoundryPenBottom.CreatePen(PS_INSIDEFRAME | PS_SOLID, 2, RGB(229, 151, 0));
- m_FillActive.CreateSolidBrush(RGB(223, 222, 236));
- m_FillInactive.CreateSolidBrush(RGB(222, 223, 236));
- m_InsideBoundryPenLeftSel.CreatePen(PS_INSIDEFRAME | PS_SOLID, 3, RGB(153, 198, 252));
- m_InsideBoundryPenTopSel.CreatePen(PS_INSIDEFRAME | PS_SOLID, 2, RGB(162, 201, 255));
- m_InsideBoundryPenRightSel.CreatePen(PS_INSIDEFRAME | PS_SOLID, 3, RGB(162, 189, 252));
- m_InsideBoundryPenBottomSel.CreatePen(PS_INSIDEFRAME | PS_SOLID, 2, RGB(162, 201, 255));
- globalWndHookEx = SetWindowsHookEx(
- WH_CALLWNDPROC, (HOOKPROC) IRCallWndProc, hModule, dwThreadID );
- return TRUE;
- }
- BOOL IRComplete( void )
- {//return 1;
- UnhookWindowsHookEx( globalWndHookEx );
- m_BoundryPen.DeleteObject();
- m_InsideBoundryPenLeft.DeleteObject();
- m_InsideBoundryPenRight.DeleteObject();
- m_InsideBoundryPenTop.DeleteObject();
- m_InsideBoundryPenBottom.DeleteObject();
- m_FillActive.DeleteObject();
- m_FillInactive.DeleteObject();
- m_InsideBoundryPenLeftSel.DeleteObject();
- m_InsideBoundryPenTopSel.DeleteObject();
- m_InsideBoundryPenRightSel.DeleteObject();
- m_InsideBoundryPenBottomSel.DeleteObject();
- return TRUE;
- }
|