#define OEMRESOURCE // setting this gets OBM_ constants in windows.h #include #include "ctls.h" #pragma hdrstop #define MyModuleHandle GetModuleHandle( NULL ) #define MYASSERT(x) #define MyFree(x) LocalFree( x ) PWSTR DuplicateString( PWSTR pszOriginal ) { PWSTR pszCopy; pszCopy = LocalAlloc( LPTR, ( 1 + lstrlenW( pszOriginal ) ) * sizeof( *pszOriginal ) ); if ( NULL != pszCopy ) { lstrcpy( pszCopy, pszOriginal ); } return pszCopy; } //////////////////////////////////////////// // // Bitmap control // //////////////////////////////////////////// PCWSTR szBMPCLASS = L"_mybmp"; LRESULT BmpClassWndProc( IN HWND hwnd, IN UINT msg, IN WPARAM wParam, IN LPARAM lParam ); BOOL InitializeBmpClass( VOID ) { WNDCLASS wc; BOOL b; if(GetClassInfo(MyModuleHandle,szBMPCLASS,&wc)) { b = TRUE; } else { wc.lpszClassName = szBMPCLASS; wc.style = CS_GLOBALCLASS; wc.lpfnWndProc = BmpClassWndProc; wc.hInstance = MyModuleHandle; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; b = RegisterClass(&wc); } return(b); } VOID DestroyBmpClass( VOID ) { WNDCLASS wc; if(GetClassInfo(MyModuleHandle,szBMPCLASS,&wc)) { // // Hope there are no more windows using the class! // MYASSERT(!FindWindow(szBMPCLASS,NULL)); UnregisterClass(szBMPCLASS,MyModuleHandle); } } VOID BmpClassPaint( IN HWND hwnd ) { PAINTSTRUCT ps; unsigned BmpId; HDC hdc, hdcMem; HBITMAP hbm,hbmOld; BITMAP bm; BmpId = GetDlgCtrlID(hwnd); hdc = BeginPaint(hwnd,&ps); if(hbm = LoadBitmap((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),MAKEINTRESOURCE(BmpId))) { GetObject(hbm, sizeof(bm),&bm); if(hdcMem = CreateCompatibleDC(hdc)) { if(hbmOld = SelectObject(hdcMem,hbm)) { BitBlt(hdc,0,0,bm.bmWidth,bm.bmHeight,hdcMem,0,0,SRCCOPY); SelectObject(hdcMem,hbmOld); } DeleteDC(hdcMem); } DeleteObject(hbm); } EndPaint(hwnd,&ps); } LRESULT BmpClassWndProc( IN HWND hwnd, IN UINT msg, IN WPARAM wParam, IN LPARAM lParam ) { switch(msg) { case WM_NCCREATE: SetWindowLong( hwnd, GWL_STYLE, GetWindowLong(hwnd,GWL_STYLE) | WS_BORDER ); return(TRUE); case WM_PAINT: BmpClassPaint(hwnd); return(0); } return(DefWindowProc(hwnd,msg,wParam,lParam)); } //////////////////////////////////////////// // // Action item list control // //////////////////////////////////////////// // // Define locations in extra window storage // #define AIL_FONT (0) #define AIL_BOLDFONT (sizeof(LONG)) #define AIL_BOLDITEM (2*sizeof(LONG)) #define AIL_TEXT (3*sizeof(LONG)) #define AIL_LINECOUNT (4*sizeof(LONG)) #define AIL_FREEFONTS (5*sizeof(LONG)) #define AIL_EXTRA 6 PCWSTR szActionItemListClassName = L"$$$ActionItemList"; VOID ActionItemListPaint( IN HWND hwnd ) { PAINTSTRUCT PaintStruct; PWSTR p,Text; UINT LineCount; HFONT OldFont,Font,BoldFont; UINT HighlightedItem; UINT i; int Length; int y; int yDelta; HBITMAP Bitmap,OldBitmap; BITMAP bitmap; HDC MemoryDC; SIZE Size; RECT rect; int Spacing; #define BORDER 3 if(!BeginPaint(hwnd,&PaintStruct)) { return; } // // If no text, nothing to do. // if(Text = (PWSTR)GetWindowLong(hwnd,AIL_TEXT)) { LineCount = (UINT)GetWindowLong(hwnd,AIL_LINECOUNT); } if(!Text || !LineCount) { return; } // // Get value indicating which item is to be bolded. // HighlightedItem = (UINT)GetWindowLong(hwnd,AIL_BOLDITEM); // // Get font handles. // Font = (HFONT)GetWindowLong(hwnd,AIL_FONT); BoldFont = (HFONT)GetWindowLong(hwnd,AIL_BOLDFONT); // // Select the non-boldface font to get the handle of // the currently selected font. // OldFont = SelectObject(PaintStruct.hdc,Font); // // Set text background color. // SetBkColor(PaintStruct.hdc,GetSysColor(COLOR_3DFACE)); // // Load the little triangle bitmap and create a compatible DC for it. // Bitmap = LoadBitmap(NULL,MAKEINTRESOURCE(OBM_MNARROW)); if(MemoryDC = CreateCompatibleDC(PaintStruct.hdc)) { OldBitmap = SelectObject(MemoryDC,Bitmap); GetObject(Bitmap,sizeof(BITMAP),&bitmap); } Spacing = GetSystemMetrics(SM_CXICON) / 2; // // Treat the text as a series of lines and draw each one. // p = Text; y = 0; for(i=0; i