Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

cardwindow.cpp

Go to the documentation of this file.
00001 //
00002 //    CardLib - CardWindow class
00003 //
00004 //    Freeware
00005 //    Copyright J Brown 2001
00006 //
00007 #include <windows.h>
00008 #include <tchar.h>
00009 #include <stdlib.h>
00010 
00011 #include "globals.h"
00012 #include "cardlib.h"
00013 #include "cardbutton.h"
00014 #include "cardregion.h"
00015 #include "cardwindow.h"
00016 #include "cardcolor.h"
00017 
00018 extern HPALETTE __holdplacepal;
00019 
00020 HPALETTE UseNicePalette(HDC hdc, HPALETTE hPalette)
00021 {
00022     HPALETTE hOld;
00023 
00024     hOld = SelectPalette(hdc, hPalette, FALSE);
00025     RealizePalette(hdc);
00026 
00027     return hOld;
00028 }
00029 
00030 void RestorePalette(HDC hdc, HPALETTE hOldPal)
00031 {
00032     SelectPalette(hdc, hOldPal, TRUE);
00033 }
00034 
00035 HPALETTE MakePaletteFromCols(COLORREF cols[], int nNumColours);
00036 void     PaintRect(HDC hdc, RECT *rect, COLORREF colour);
00037 HBITMAP  CreateSinkBmp(HDC hdcCompat, HDC hdc, COLORREF col, int width, int height);
00038 void     GetSinkCols(COLORREF crBase, COLORREF *fg, COLORREF *bg, COLORREF *sh1, COLORREF *sh2);
00039 
00040 void     LoadCardBitmaps();
00041 void     FreeCardBitmaps();
00042 
00043 static TCHAR szCardName[]   = _T("CardWnd32");
00044 static bool  fRegistered    = false;
00045 static LONG  uCardBitmapRef = 0;
00046 
00047 
00048 void RegisterCardWindow()
00049 {
00050     WNDCLASSEX wc;
00051 
00052     //Window class for the main application parent window
00053     wc.cbSize            = sizeof(wc);
00054     wc.style            = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
00055     wc.lpfnWndProc        = CardWindow::CardWndProc;
00056     wc.cbClsExtra        = 0;
00057     wc.cbWndExtra        = sizeof(CardWindow *);
00058     wc.hInstance        = GetModuleHandle(0);
00059     wc.hIcon            = 0;
00060     wc.hCursor            = LoadCursor (NULL, IDC_ARROW);
00061     wc.hbrBackground    = 0;
00062     wc.lpszMenuName        = 0;
00063     wc.lpszClassName    = szCardName;
00064     wc.hIconSm            = 0;
00065 
00066     RegisterClassEx(&wc);
00067 }
00068 
00069 CardWindow::CardWindow() : m_hWnd(0)
00070 {
00071     HDC hdc = GetDC(0);
00072 
00073     nNumButtons       = 0;
00074     nNumCardRegions   = 0;
00075     nNumDropZones     = 0;
00076     nBackCardIdx      = 53;
00077 
00078     ResizeWndCallback = 0;
00079     hbmBackImage      = 0;
00080     hdcBackImage      = 0;
00081 
00082     srand((unsigned)GetTickCount());
00083 
00084     //All colours (buttons, highlights, decks)
00085     //are calculated off this single base colour
00086     crBackgnd = PALETTERGB(0,80,0);//PALETTERGB(0,64,100);
00087 
00088     // If uCardBitmapRef was previously zero, then
00089     // load the card bitmaps
00090     if(1 == InterlockedIncrement(&uCardBitmapRef))
00091     {
00092         LoadCardBitmaps();
00093 
00094         __hPalette  = CreateCardPalette();
00095 
00096         __hdcPlaceHolder  = CreateCompatibleDC(hdc);
00097 
00098         __holdplacepal  = UseNicePalette(__hdcPlaceHolder, __hPalette);
00099 
00100         __hbmPlaceHolder  = CreateSinkBmp(hdc, __hdcPlaceHolder, crBackgnd, __cardwidth, __cardheight);
00101 
00102     }
00103 
00104     ReleaseDC(0, hdc);
00105 
00106     //register the window class if necessary
00107     if(!fRegistered)
00108     {
00109         fRegistered = true;
00110         RegisterCardWindow();
00111     }
00112 
00113 }
00114 
00115 BOOL CardWindow::Create(HWND hwndParent, DWORD dwExStyle, DWORD dwStyle, int x, int y, int width, int height)
00116 {
00117     if(m_hWnd)
00118         return FALSE;
00119 
00120     //Create the window associated with this object
00121     m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, szCardName, 0,
00122         WS_CHILD | WS_VISIBLE,
00123         0,0,100,100,
00124         hwndParent, 0, GetModuleHandle(0), this);
00125 
00126     return TRUE;
00127 }
00128 
00129 BOOL CardWindow::Destroy()
00130 {
00131     DestroyWindow(m_hWnd);
00132     m_hWnd = 0;
00133 
00134     return TRUE;
00135 }
00136 
00137 CardWindow::~CardWindow()
00138 {
00139     if(m_hWnd)
00140         DestroyWindow(m_hWnd);
00141 
00142     DeleteAll();
00143 
00144     if(0 == InterlockedDecrement(&uCardBitmapRef))
00145     {
00146         FreeCardBitmaps();
00147 
00148         DeleteObject(__hbmPlaceHolder);
00149         DeleteDC    (__hdcPlaceHolder);
00150 
00151         RestorePalette(__hdcPlaceHolder, __holdplacepal);
00152 
00153         if(__hPalette)
00154             DeleteObject(__hPalette);
00155     }
00156 }
00157 
00158 bool CardWindow::DeleteAll()
00159 {
00160     int i;
00161 
00162     for(i = 0; i < nNumCardRegions; i++)
00163     {
00164         delete Regions[i];
00165     }
00166 
00167     for(i = 0; i < nNumButtons; i++)
00168     {
00169         delete Buttons[i];
00170     }
00171 
00172     for(i = 0; i < nNumDropZones; i++)
00173     {
00174         delete dropzone[i];
00175     }
00176 
00177     nNumCardRegions = nNumButtons = nNumDropZones = 0;
00178 
00179     return true;
00180 }
00181 
00182 void CardWindow::SetBackColor(COLORREF cr)
00183 {
00184     crBackgnd = cr;
00185     int i;
00186 
00187     //
00188     // Create the exact palette we need to render the buttons/stacks
00189     //
00190     RestorePalette(__hdcPlaceHolder, __holdplacepal);
00191 
00192     if(__hPalette)
00193         DeleteObject(__hPalette);
00194 
00195     __hPalette = CreateCardPalette();
00196 
00197     //
00198     // re-create the place-holder!
00199     HDC hdc = GetDC(m_hWnd);
00200 
00201     DeleteObject(__hbmPlaceHolder);
00202 
00203     __holdplacepal = UseNicePalette(__hdcPlaceHolder, __hPalette);
00204 
00205     __hbmPlaceHolder = CreateSinkBmp(hdc, __hdcPlaceHolder, crBackgnd, __cardwidth, __cardheight);
00206     //SelectObject(__hdcPlaceHolder, __hbmPlaceHolder);
00207 
00208     //reset all buttons to same colour
00209     for(i = 0; i < nNumButtons; i++)
00210     {
00211         if(Buttons[i]->GetStyle() & CB_PUSHBUTTON)
00212         {
00213             Buttons[i]->SetBackColor(ColorScaleRGB(crBackgnd, RGB(255,255,255), 0.1));
00214         }
00215         else
00216         {
00217             Buttons[i]->SetBackColor(crBackgnd);
00218         }
00219     }
00220 
00221     for(i = 0; i < nNumCardRegions; i++)
00222     {
00223         Regions[i]->SetBackColor(crBackgnd);
00224     }
00225 
00226 
00227     ReleaseDC(m_hWnd, hdc);
00228 }
00229 
00230 COLORREF CardWindow::GetBackColor()
00231 {
00232     return crBackgnd;
00233 }
00234 
00235 CardButton* CardWindow::CardButtonFromPoint(int x, int y)
00236 {
00237     CardButton *bptr = 0;
00238 
00239     POINT pt;
00240     pt.x = x;
00241     pt.y = y;
00242 
00243     //Search BACKWARDS...to reflect the implicit Z-order that
00244     //the button creation provided
00245     for(int i = nNumButtons - 1; i >= 0; i--)
00246     {
00247         bptr = Buttons[i];
00248         if(PtInRect(&bptr->rect, pt) && bptr->fVisible)
00249             return bptr;
00250     }
00251 
00252     return 0;
00253 }
00254 
00255 CardRegion* CardWindow::CardRegionFromPoint(int x, int y)
00256 {
00257     POINT pt;
00258     pt.x = x;
00259     pt.y = y;
00260 
00261     //Search BACKWARDS...to reflect the implicit Z-order that
00262     //the stack creation provided
00263     for(int i = nNumCardRegions - 1; i >= 0; i--)
00264     {
00265         if(Regions[i]->IsPointInStack(x, y))
00266             return Regions[i];
00267     }
00268 
00269     return 0;
00270 }
00271 
00272 //
00273 //    Forward all window messages onto the appropriate
00274 //  class instance
00275 //
00276 LRESULT CALLBACK CardWindow::CardWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
00277 {
00278     CardWindow *cw = (CardWindow *)GetWindowLongPtr(hwnd, 0);
00279     return cw->WndProc(hwnd, iMsg, wParam, lParam);
00280 }
00281 
00282 void CardWindow::Paint(HDC hdc)
00283 {
00284     int i;
00285     RECT rect;
00286     HPALETTE hOldPal;
00287 
00288     hOldPal = UseNicePalette(hdc, __hPalette);
00289 
00290     //
00291     //    Clip the card stacks so that they won't
00292     //    get painted over
00293     //
00294     for(i = 0; i < nNumCardRegions; i++)
00295     {
00296         Regions[i]->Clip(hdc);
00297     }
00298 
00299     //
00300     //    Clip the buttons
00301     //
00302     for(i = 0; i < nNumButtons; i++)
00303     {
00304         Buttons[i]->Clip(hdc);
00305     }
00306 
00307 
00308     //    Now paint the whole screen with background colour,
00309     //
00310     GetClientRect(m_hWnd, &rect);
00311 
00312     //PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));
00313     PaintCardRgn(hdc, 0, 0, rect.right, rect.bottom, 0, 0);
00314     SelectClipRgn(hdc, NULL);
00315 
00316     //    Don't let cards draw over buttons, so clip buttons again
00317     //
00318     for(i = 0; i < nNumButtons; i++)
00319     {
00320         Buttons[i]->Clip(hdc);
00321     }
00322 
00323     //    Paint each card stack in turn
00324     //
00325     for(i = 0; i < nNumCardRegions; i++)
00326     {
00327         Regions[i]->Render(hdc);
00328     }
00329 
00330     //    Paint each button now
00331     //
00332     SelectClipRgn(hdc, NULL);
00333 
00334     for(i = 0; i < nNumButtons; i++)
00335     {
00336         Buttons[i]->Redraw();
00337     }
00338 
00339     RestorePalette(hdc, hOldPal);
00340 }
00341 
00342 
00343 
00344 
00345 LRESULT CALLBACK CardWindow::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
00346 {
00347     HDC hdc;
00348     PAINTSTRUCT ps;
00349 
00350     CREATESTRUCT *cs;
00351 
00352     static CardButton *buttonptr   = 0;
00353     static CardRegion *stackptr    = 0;
00354 
00355     int x, y, i;
00356 
00357     switch(iMsg)
00358     {
00359     case WM_NCCREATE:
00360 
00361         // When we created this window, we passed in the
00362         // pointer to the class object (CardWindow *) in the
00363         // call to CreateWindow.
00364         cs = (CREATESTRUCT *)lParam;
00365 
00366         //
00367         // associate this class with the window
00368         //
00369         SetWindowLongPtr(hwnd, 0, (LONG_PTR)cs->lpCreateParams);
00370 
00371         return 1;
00372 
00373     case WM_NCDESTROY:
00374         // Don't delete anything here..
00375         break;
00376 
00377     case WM_SIZE:
00378         nWidth = LOWORD(lParam);
00379         nHeight = HIWORD(lParam);
00380 
00381         //
00382         // reposition all the stacks and buttons
00383         // in case any of them are centered, right-justified etc
00384         //
00385         for(i = 0; i < nNumCardRegions; i++)
00386         {
00387             Regions[i]->AdjustPosition(nWidth, nHeight);
00388         }
00389 
00390         for(i = 0; i < nNumButtons; i++)
00391         {
00392             Buttons[i]->AdjustPosition(nWidth, nHeight);
00393         }
00394 
00395         //
00396         // Call the user-defined resize proc AFTER all the stacks
00397         // have been positioned
00398         //
00399         if(ResizeWndCallback)
00400             ResizeWndCallback(nWidth, nHeight);
00401 
00402         return 0;
00403 
00404     case WM_PAINT:
00405 
00406         hdc = BeginPaint(hwnd, &ps);
00407 
00408         Paint(hdc);
00409 
00410         EndPaint(hwnd, &ps);
00411         return 0;
00412 
00413     case WM_TIMER:
00414 
00415         //find the timer object in the registered funcs
00416         /*if(wParam >= 0x10000)
00417         {
00418             for(i = 0; i < nRegFuncs; i++)
00419             {
00420                 if(RegFuncs[i].id == wParam)
00421                 {
00422                     KillTimer(hwnd, wParam);
00423 
00424                     //call the registered function!!
00425                     RegFuncs[i].func(RegFuncs[i].dwParam);
00426 
00427                     RegFuncs[i] = RegFuncs[nRegFuncs-1];
00428                     nRegFuncs--;
00429                 }
00430             }
00431         }
00432         else*/
00433         {
00434             //find the cardstack
00435             CardRegion *stackobj = (CardRegion *)wParam;//CardStackFromId(wParam);
00436             stackobj->DoFlash();
00437         }
00438 
00439         return 0;
00440 
00441     case WM_LBUTTONDBLCLK:
00442 
00443         x = (short)LOWORD(lParam);
00444         y = (short)HIWORD(lParam);
00445 
00446         if((buttonptr = CardButtonFromPoint(x, y)) != 0)
00447         {
00448             buttonptr->OnLButtonDown(hwnd, x, y);
00449             return 0;
00450         }
00451 
00452         if((stackptr = CardRegionFromPoint(x, y)) != 0)
00453         {
00454             stackptr->OnLButtonDblClk(x, y);
00455             stackptr = 0;
00456         }
00457 
00458         return 0;
00459 
00460     case WM_LBUTTONDOWN:
00461 
00462         x = (short)LOWORD(lParam);
00463         y = (short)HIWORD(lParam);
00464 
00465         //if clicked on a button
00466         if((buttonptr = CardButtonFromPoint(x, y)) != 0)
00467         {
00468             if(buttonptr->OnLButtonDown(hwnd, x, y) == 0)
00469                 buttonptr = 0;
00470 
00471             return 0;
00472         }
00473 
00474         if((stackptr = CardRegionFromPoint(x, y)) != 0)
00475         {
00476             if(!stackptr->OnLButtonDown(x, y))
00477                 stackptr = 0;
00478         }
00479 
00480         return 0;
00481 
00482     case WM_LBUTTONUP:
00483 
00484         x = (short)LOWORD(lParam);
00485         y = (short)HIWORD(lParam);
00486 
00487         //
00488         // if we were clicking a button
00489         //
00490         if(buttonptr != 0)
00491         {
00492             buttonptr->OnLButtonUp(hwnd, x, y);
00493             buttonptr = 0;
00494             return 0;
00495         }
00496 
00497         if(stackptr != 0)
00498         {
00499             stackptr->OnLButtonUp(x, y);
00500             stackptr = 0;
00501             return 0;
00502         }
00503 
00504         if ((stackptr = CardRegionFromPoint(x, y)) != 0)
00505         {
00506             stackptr->ClickRelease(x, y);
00507             stackptr = 0;
00508         }
00509 
00510         return 0;
00511 
00512     case WM_MOUSEMOVE:
00513 
00514         x = (short)LOWORD(lParam);
00515         y = (short)HIWORD(lParam);
00516 
00517         // if we were clicking a button
00518         if(buttonptr != 0)
00519         {
00520             buttonptr->OnMouseMove(hwnd, x, y);
00521             return 0;
00522         }
00523 
00524         if(stackptr != 0)
00525         {
00526             return stackptr->OnMouseMove(x, y);
00527         }
00528 
00529         return 0;
00530 
00531     }
00532 
00533       return DefWindowProc (hwnd, iMsg, wParam, lParam);
00534 }
00535 
00536 
00537 CardRegion* CardWindow::CardRegionFromId(int id)
00538 {
00539     for(int i = 0; i < nNumCardRegions; i++)
00540     {
00541         if(Regions[i]->id == id)
00542             return Regions[i];
00543     }
00544 
00545     return 0;
00546 }
00547 
00548 CardButton* CardWindow::CardButtonFromId(int id)
00549 {
00550     for(int i = 0; i < nNumButtons; i++)
00551     {
00552         if(Buttons[i]->id == id)
00553             return Buttons[i];
00554     }
00555 
00556     return 0;
00557 }
00558 
00559 void CardWindow::Redraw()
00560 {
00561     InvalidateRect(m_hWnd, 0, 0);
00562     UpdateWindow(m_hWnd);
00563 }
00564 
00565 bool CardWindow::DeleteButton(CardButton *pButton)
00566 {
00567     for(int i = 0; i < nNumButtons; i++)
00568     {
00569         if(Buttons[i] == pButton)
00570         {
00571             CardButton *cb = Buttons[i];
00572 
00573             //shift any after this one backwards
00574             for(int j = i; j < nNumButtons - 1; j++)
00575             {
00576                 Buttons[j] = Buttons[j + 1];
00577             }
00578 
00579             delete cb;
00580             nNumButtons--;
00581 
00582             return true;
00583         }
00584     }
00585 
00586     return false;
00587 }
00588 
00589 bool CardWindow::DeleteRegion(CardRegion *pRegion)
00590 {
00591     for(int i = 0; i < nNumCardRegions; i++)
00592     {
00593         if(Regions[i] == pRegion)
00594         {
00595             CardRegion *cr = Regions[i];
00596 
00597             //shift any after this one backwards
00598             for(int j = i; j < nNumCardRegions - 1; j++)
00599             {
00600                 Regions[j] = Regions[j + 1];
00601             }
00602 
00603             delete cr;
00604             nNumCardRegions--;
00605 
00606             return true;
00607         }
00608     }
00609 
00610     return false;
00611 }
00612 
00613 void CardWindow::EmptyStacks(void)
00614 {
00615     for(int i = 0; i < nNumCardRegions; i++)
00616     {
00617         Regions[i]->Clear();
00618         Regions[i]->Update();
00619     }
00620 
00621     Redraw();
00622 }
00623 
00624 bool CardWindow::DistributeStacks(int nIdFrom, int nNumStacks, UINT xJustify, int xSpacing, int nStartX)
00625 {
00626     int numvisiblestacks = 0;
00627     int curx = nStartX;
00628     int startindex = -1;
00629     int i;
00630 
00631     //find the stack which starts with our ID
00632     for(i = 0; i < nNumCardRegions; i++)
00633     {
00634         if(Regions[i]->Id() == nIdFrom)
00635         {
00636             startindex = i;
00637             break;
00638         }
00639     }
00640 
00641     //if didn't find, return
00642     if(i == nNumCardRegions) return false;
00643 
00644     //count the stacks that are visible
00645     for(i = startindex; i < startindex + nNumStacks; i++)
00646     {
00647         if(Regions[i]->IsVisible())
00648             numvisiblestacks++;
00649     }
00650 
00651     if(xJustify == CS_XJUST_CENTER)
00652     {
00653         //startx -= ((numvisiblestacks + spacing) * cardwidth - spacing) / 2;
00654         int viswidth;
00655         viswidth = numvisiblestacks * __cardwidth;
00656         viswidth += xSpacing * (numvisiblestacks - 1);
00657         curx = -(viswidth  - __cardwidth) / 2;
00658 
00659         for(i = startindex; i < startindex + nNumStacks; i++)
00660         {
00661             if(Regions[i]->IsVisible())
00662             {
00663                 Regions[i]->xadjust = curx;
00664                 Regions[i]->xjustify = CS_XJUST_CENTER;
00665                 curx += Regions[i]->width + xSpacing;
00666             }
00667 
00668         }
00669     }
00670 
00671     if(xJustify == CS_XJUST_RIGHT)
00672     {
00673         nStartX -= ((numvisiblestacks + xSpacing) * __cardwidth - xSpacing);
00674     }
00675 
00676     if(xJustify == CS_XJUST_NONE)
00677     {
00678         for(i = startindex; i < startindex + nNumStacks; i++)
00679         {
00680             if(Regions[i]->IsVisible())
00681             {
00682                 Regions[i]->xpos = curx;
00683                 curx += Regions[i]->width + xSpacing;
00684                 Regions[i]->UpdateSize();
00685             }
00686 
00687         }
00688     }
00689 
00690     return 0;
00691 }
00692 
00693 void CardWindow::Update()
00694 {
00695     for(int i = 0; i < nNumCardRegions; i++)
00696     {
00697         Regions[i]->AdjustPosition(nWidth, nHeight);
00698     }
00699 }
00700 
00701 
00702 void CardWindow::SetResizeProc(pResizeWndProc proc)
00703 {
00704     ResizeWndCallback = proc;
00705 }
00706 
00707 
00708 HPALETTE CardWindow::CreateCardPalette()
00709 {
00710     COLORREF cols[10];
00711     int nNumCols;
00712 
00713 
00714     //include button text colours
00715     cols[0] = RGB(0, 0, 0);
00716     cols[1] = RGB(255, 255, 255);
00717 
00718     //include the base background colour
00719     cols[2] = crBackgnd;
00720 
00721     //include the standard button colours...
00722     cols[3] = CardButton::GetHighlight(crBackgnd);
00723     cols[4] = CardButton::GetShadow(crBackgnd);
00724     cols[5] = CardButton::GetFace(crBackgnd);
00725 
00726     //include the sunken image bitmap colours...
00727     GetSinkCols(crBackgnd, &cols[6], &cols[7], &cols[8], &cols[9]);
00728 
00729     nNumCols = 10;
00730 
00731     return MakePaletteFromCols(cols, nNumCols);
00732 }
00733 
00734 void CardWindow::SetBackCardIdx(UINT uBackIdx)
00735 {
00736     if(uBackIdx >= 52 && uBackIdx <= 68)
00737         nBackCardIdx = uBackIdx;
00738 
00739     for(int i = 0; i < nNumCardRegions; i++)
00740         Regions[i]->SetBackCardIdx(uBackIdx);
00741 
00742 }
00743 
00744 UINT CardWindow::GetBackCardIdx()
00745 {
00746     return nBackCardIdx;
00747 }
00748 
00749 void CardWindow::PaintCardRgn(HDC hdc, int dx, int dy, int width, int height, int sx, int sy)
00750 {
00751     RECT rect;
00752 
00753     //if just a solid background colour
00754     if(hbmBackImage == 0)
00755     {
00756         SetRect(&rect, dx, dy, dx+width, dy+height);
00757 
00758         /*if(GetVersion() < 0x80000000)
00759         {
00760             PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));
00761         }
00762         else*/
00763         {
00764             HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBackgnd));
00765             FillRect(hdc, &rect, hbr);
00766             DeleteObject(hbr);
00767         }
00768     }
00769     //otherwise, paint using the bitmap
00770     else
00771     {
00772         // Draw whatever part of background we can
00773         BitBlt(hdc, dx, dy, width, height, hdcBackImage, sx, sy, SRCCOPY);
00774 
00775         // Now we need to paint any area outside the bitmap,
00776         // just in case the bitmap is too small to fill whole window
00777         if(0)//sx + width > bm.bmWidth || sy + height > bm.bmHeight)
00778         {
00779             // Find out size of bitmap
00780             BITMAP bm;
00781             GetObject(hbmBackImage, sizeof(bm), &bm);
00782 
00783             HRGN hr1 = CreateRectRgn(sx, sy, sx+width, sy+height);
00784             HRGN hr2 = CreateRectRgn(0, 0, bm.bmWidth, bm.bmHeight);
00785             HRGN hr3 = CreateRectRgn(0,0, 1, 1);
00786             HRGN hr4 = CreateRectRgn(0,0, 1, 1);
00787 
00788             CombineRgn(hr3, hr1, hr2, RGN_DIFF);
00789 
00790             GetClipRgn(hdc, hr4);
00791 
00792             CombineRgn(hr3, hr4, hr3, RGN_AND);
00793             SelectClipRgn(hdc, hr3);
00794 
00795             // Fill remaining space not filled with bitmap
00796             HBRUSH hbr = CreateSolidBrush(crBackgnd);
00797             FillRgn(hdc, hr3, hbr);
00798             DeleteObject(hbr);
00799 
00800             // Clean up
00801             SelectClipRgn(hdc, hr4);
00802 
00803             DeleteObject(hr1);
00804             DeleteObject(hr2);
00805             DeleteObject(hr3);
00806             DeleteObject(hr4);
00807         }
00808     }
00809 }
00810 
00811 void CardWindow::SetBackImage(HBITMAP hBitmap)
00812 {
00813     //delete current image?? NO!
00814     if(hdcBackImage == 0)
00815     {
00816         hdcBackImage = CreateCompatibleDC(0);
00817     }
00818 
00819     hbmBackImage = hBitmap;
00820 
00821     if(hBitmap)
00822         SelectObject(hdcBackImage, hBitmap);
00823 }

Generated on Thu Feb 9 04:59:29 2012 for ReactOS by doxygen 1.6.3

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.