[475] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[3] | 3 | #include "common.h"
|
---|
| 4 |
|
---|
| 5 | extern RGBQUAD DefaultColorTable16[16];
|
---|
| 6 |
|
---|
| 7 | BOOL CALLBACK DlgIconColorProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
|
---|
| 8 | extern HANDLE hHeap;
|
---|
| 9 | extern MDIINFO MdiInfo[MAX_WNDNUM];
|
---|
| 10 | extern COLORREF TransparentClrRef;
|
---|
| 11 | int i,i2,WndNum;
|
---|
| 12 | RGBQUAD *pRgbq;
|
---|
| 13 | RECT rect;
|
---|
| 14 | POINT pos,pos2;
|
---|
| 15 | COLORREF ColorRef;
|
---|
| 16 | HDC hdc;
|
---|
| 17 |
|
---|
| 18 | switch(message){
|
---|
| 19 | case WM_LBUTTONDOWN:
|
---|
| 20 | case WM_RBUTTONDOWN:
|
---|
| 21 | pos.x=LOWORD(lParam);
|
---|
| 22 | pos.y=HIWORD(lParam);
|
---|
| 23 |
|
---|
| 24 | WndNum=GetWndNum(GetParent(hwnd));
|
---|
| 25 |
|
---|
| 26 | pos2=pos;
|
---|
| 27 | ClientToScreen(hwnd,&pos2);
|
---|
| 28 | ScreenToClient(GetDlgItem(hwnd,IDC_STATIC_COLOR),&pos2);
|
---|
| 29 |
|
---|
| 30 | if((8+1)*15<pos2.x&&pos2.x<(8+1)*15+13&&
|
---|
| 31 | 0<pos2.y&&pos2.y<13){
|
---|
| 32 | //透明色をクリックした場合
|
---|
| 33 | if(message==WM_LBUTTONDOWN)
|
---|
| 34 | MdiInfo[WndNum].MdiIconEditInfo->MainColor=TransparentClrRef;
|
---|
| 35 | else
|
---|
| 36 | MdiInfo[WndNum].MdiIconEditInfo->SubColor=TransparentClrRef;
|
---|
| 37 | InvalidateRect(hwnd,NULL,0);
|
---|
| 38 | return 1;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | if(pos2.x%15==0||pos2.x%15>=12||
|
---|
| 42 | pos2.y%15==0||pos2.y%15>=12||
|
---|
| 43 | 0>pos2.x||pos2.x/15>=8||
|
---|
| 44 | 0>pos2.y||pos2.y/15>=2){
|
---|
| 45 | //パディング部分をクリックした場合は抜け出す
|
---|
| 46 | return 1;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | //選択カラーを取得
|
---|
| 50 | hdc=GetDC(hwnd);
|
---|
| 51 | ColorRef=GetPixel(hdc,pos.x,pos.y);
|
---|
| 52 | ReleaseDC(hwnd,hdc);
|
---|
| 53 |
|
---|
| 54 | if(message==WM_LBUTTONDOWN)
|
---|
| 55 | MdiInfo[WndNum].MdiIconEditInfo->MainColor=ColorRef;
|
---|
| 56 | else
|
---|
| 57 | MdiInfo[WndNum].MdiIconEditInfo->SubColor=ColorRef;
|
---|
| 58 |
|
---|
| 59 | InvalidateRect(hwnd,NULL,0);
|
---|
| 60 | return 1;
|
---|
| 61 | case WM_PAINT:
|
---|
| 62 | WndNum=GetWndNum(GetParent(hwnd));
|
---|
| 63 | if(WndNum==-1) break;
|
---|
| 64 |
|
---|
| 65 | ////////////////////////
|
---|
| 66 | // カラーテーブルを表示
|
---|
| 67 | PAINTSTRUCT ps;
|
---|
| 68 | HPEN hPen,hOldPen;
|
---|
| 69 | HBRUSH hBrush,hOldBrush;
|
---|
| 70 |
|
---|
| 71 | GetWindowRect(GetDlgItem(hwnd,IDC_STATIC_COLOR),&rect);
|
---|
| 72 | pos.x=rect.left;
|
---|
| 73 | pos.y=rect.top;
|
---|
| 74 | ScreenToClient(hwnd,&pos);
|
---|
| 75 | GetWindowRect(GetDlgItem(hwnd,IDC_NOWCOLOR),&rect);
|
---|
| 76 | pos2.x=rect.left;
|
---|
| 77 | pos2.y=rect.top;
|
---|
| 78 | ScreenToClient(hwnd,&pos2);
|
---|
| 79 |
|
---|
| 80 | //カラーテーブルを取得
|
---|
| 81 | pRgbq=(RGBQUAD *)(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+sizeof(BITMAPINFOHEADER));
|
---|
| 82 |
|
---|
| 83 | hdc=BeginPaint(hwnd,&ps);
|
---|
| 84 | hPen=CreatePen(PS_SOLID,0,RGB(0,0,0));
|
---|
| 85 | hOldPen=(HPEN)SelectObject(hdc,hPen);
|
---|
| 86 | if(MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biBitCount==4){
|
---|
| 87 | ////////
|
---|
| 88 | // 16色
|
---|
| 89 |
|
---|
| 90 | //カラーテーブルを描画
|
---|
| 91 | i2=16;
|
---|
| 92 | for(i=0;i<i2;i++){
|
---|
| 93 | hBrush=CreateSolidBrush(RGB(pRgbq[i].rgbRed,pRgbq[i].rgbGreen,pRgbq[i].rgbBlue));
|
---|
| 94 | hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
|
---|
| 95 | if(i<i2/2){
|
---|
| 96 | Rectangle(hdc,
|
---|
| 97 | pos.x+i*15,
|
---|
| 98 | pos.y,
|
---|
| 99 | pos.x+i*15+13,
|
---|
| 100 | pos.y+13);
|
---|
| 101 | }
|
---|
| 102 | else{
|
---|
| 103 | Rectangle(hdc,
|
---|
| 104 | pos.x+(i-i2/2)*15,
|
---|
| 105 | pos.y+15,
|
---|
| 106 | pos.x+(i-i2/2)*15+13,
|
---|
| 107 | pos.y+15+13);
|
---|
| 108 | }
|
---|
| 109 | SelectObject(hdc,hOldBrush);
|
---|
| 110 | DeleteObject(hBrush);
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | else{
|
---|
| 114 | /////////
|
---|
| 115 | // 256色
|
---|
| 116 |
|
---|
| 117 | //カラーテーブルを描画
|
---|
| 118 | i2=16;
|
---|
| 119 | for(i=0;i<i2;i++){
|
---|
| 120 | hBrush=CreateSolidBrush(RGB(DefaultColorTable16[i].rgbRed,DefaultColorTable16[i].rgbGreen,DefaultColorTable16[i].rgbBlue));
|
---|
| 121 | hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
|
---|
| 122 | if(i<i2/2){
|
---|
| 123 | Rectangle(hdc,
|
---|
| 124 | pos.x+i*15,
|
---|
| 125 | pos.y,
|
---|
| 126 | pos.x+i*15+13,
|
---|
| 127 | pos.y+13);
|
---|
| 128 | }
|
---|
| 129 | else{
|
---|
| 130 | Rectangle(hdc,
|
---|
| 131 | pos.x+(i-i2/2)*15,
|
---|
| 132 | pos.y+15,
|
---|
| 133 | pos.x+(i-i2/2)*15+13,
|
---|
| 134 | pos.y+15+13);
|
---|
| 135 | }
|
---|
| 136 | SelectObject(hdc,hOldBrush);
|
---|
| 137 | DeleteObject(hBrush);
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | //透明色カラーを表示
|
---|
| 142 | hBrush=CreateSolidBrush(TransparentClrRef);
|
---|
| 143 | hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
|
---|
| 144 | Rectangle(hdc,
|
---|
| 145 | pos.x+(i2/2+1)*15,
|
---|
| 146 | pos.y,
|
---|
| 147 | pos.x+(i2/2+1)*15+13,
|
---|
| 148 | pos.y+13);
|
---|
| 149 | SelectObject(hdc,hOldBrush);
|
---|
| 150 | DeleteObject(hBrush);
|
---|
| 151 |
|
---|
| 152 | MoveToEx(hdc,pos.x+(i2/2+1)*15,pos.y,NULL);
|
---|
| 153 | LineTo(hdc,pos.x+(i2/2+1)*15+13,pos.y+13);
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 | //現在選択中のサブカラーを表示
|
---|
| 157 | hBrush=CreateSolidBrush(MdiInfo[WndNum].MdiIconEditInfo->SubColor);
|
---|
| 158 | hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
|
---|
| 159 | Rectangle(hdc,
|
---|
| 160 | pos2.x+10,
|
---|
| 161 | pos2.y+10,
|
---|
| 162 | pos2.x+23,
|
---|
| 163 | pos2.y+23);
|
---|
| 164 | SelectObject(hdc,hOldBrush);
|
---|
| 165 | DeleteObject(hBrush);
|
---|
| 166 |
|
---|
| 167 | //現在選択中のメインカラーを表示
|
---|
| 168 | hBrush=CreateSolidBrush(MdiInfo[WndNum].MdiIconEditInfo->MainColor);
|
---|
| 169 | hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
|
---|
| 170 | Rectangle(hdc,
|
---|
| 171 | pos2.x+3,
|
---|
| 172 | pos2.y+3,
|
---|
| 173 | pos2.x+16,
|
---|
| 174 | pos2.y+16);
|
---|
| 175 | SelectObject(hdc,hOldBrush);
|
---|
| 176 | DeleteObject(hBrush);
|
---|
| 177 |
|
---|
| 178 | SelectObject(hdc,hOldPen);
|
---|
| 179 | DeleteObject(hPen);
|
---|
| 180 | EndPaint(hwnd,&ps);
|
---|
| 181 | return 1;
|
---|
| 182 | }
|
---|
| 183 | return 0;
|
---|
| 184 | }
|
---|