1 #include "solitaire.h"
2
3 CardRegion *pDeck;
4 CardRegion *pPile;
5 CardRegion *pSuitStack[4];
6 CardRegion *pRowStack[NUM_ROW_STACKS];
7
8 HBITMAP hbmBitmap;
9 HDC hdcBitmap;
10 int yRowStackCardOffset;
11
CreateSol()12 void CreateSol()
13 {
14 int i;
15
16 // hbmBitmap = (HBITMAP)LoadImage(0,"test.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
17 // SolWnd.SetBackImage(hbmBitmap);
18
19 activepile.Clear();
20
21 // Compute the value for yRowStackCardOffset based on the height of the card, so the card number isn't hidden on larger cards
22 yRowStackCardOffset = (int)(__cardheight / 6.7);
23
24 pDeck = SolWnd.CreateRegion(DECK_ID, true, X_BORDER, Y_BORDERWITHFRAME, 2, 1);
25 pDeck->SetEmptyImage(CS_EI_CIRC);
26 pDeck->SetThreedCount(6);
27 pDeck->SetDragRule(CS_DRAG_NONE, 0);
28 pDeck->SetDropRule(CS_DROP_NONE, 0);
29 pDeck->SetClickProc(DeckClickProc);
30 pDeck->SetDblClickProc(DeckClickProc);
31 pDeck->SetFaceDirection(CS_FACE_DOWN, 0);
32
33 pPile = SolWnd.CreateRegion(PILE_ID, true, X_BORDER + __cardwidth + X_PILE_BORDER, Y_BORDERWITHFRAME, CS_DEFXOFF, 1);
34 pPile->SetEmptyImage(CS_EI_NONE);
35 pPile->SetDragRule(CS_DRAG_TOP, 0);
36 pPile->SetDropRule(CS_DROP_NONE, 0);
37 pPile->SetDblClickProc(PileDblClickProc);
38 pPile->SetRemoveCardProc(PileRemoveProc);
39 pPile->SetClickProc(PileClickProc);
40
41 //
42 // Create the suit stacks
43 //
44 for(i = 0; i < 4; i++)
45 {
46 pSuitStack[i] = SolWnd.CreateRegion(SUIT_ID+i, true, 0, Y_BORDERWITHFRAME, 0, 0);
47 pSuitStack[i]->SetEmptyImage(CS_EI_SUNK);
48 pSuitStack[i]->SetPlacement(CS_XJUST_CENTER, 0, i * (__cardwidth + X_SUITSTACK_BORDER) , 0);
49
50 pSuitStack[i]->SetDropRule(CS_DROP_CALLBACK, SuitStackDropProc);
51 pSuitStack[i]->SetDragRule(CS_DRAG_TOP);
52 pSuitStack[i]->SetClickProc(SuitStackClickProc);
53
54 pSuitStack[i]->SetAddCardProc(SuitStackAddProc);
55 }
56
57 //
58 // Create the row stacks
59 //
60 for(i = 0; i < NUM_ROW_STACKS; i++)
61 {
62 pRowStack[i] = SolWnd.CreateRegion(ROW_ID+i, true, 0, Y_BORDERWITHFRAME + __cardheight + Y_ROWSTACK_BORDER, 0, yRowStackCardOffset);
63 pRowStack[i]->SetEmptyImage(CS_EI_SUNK);
64 pRowStack[i]->SetFaceDirection(CS_FACE_DOWNUP, i);
65
66 pRowStack[i]->SetPlacement(CS_XJUST_CENTER, 0,
67 (i - NUM_ROW_STACKS/2) * (__cardwidth + X_ROWSTACK_BORDER), 0);
68
69 pRowStack[i]->SetEmptyImage(CS_EI_NONE);
70
71 pRowStack[i]->SetDragRule(CS_DRAG_CALLBACK, RowStackDragProc);
72 pRowStack[i]->SetDropRule(CS_DROP_CALLBACK, RowStackDropProc);
73 pRowStack[i]->SetClickProc(RowStackClickProc);
74 pRowStack[i]->SetDblClickProc(RowStackDblClickProc);
75 }
76 }
77