エディットボックスの中を黒くしたい
Posted: 2012年8月05日(日) 11:32
見よう見まねねで、プログラムを作ってるんですが、エディットボックスが黒くしたいのですが文字の色は変わっても背景が黒くなりません。何処かおかしいですか
#include <tchar.h>
#include <windows.h>
#define IDB_Stop 1001
#define IDB_Start 1002
#define IDB_Hide 1003
#define IDB_Show 1004
#define ID_EDIT 1005
const TCHAR szWndClass[] = _T("MainWindow");
HWND hWnd;
HINSTANCE hInstance;
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG msg;
BOOL bRet;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = szWndClass;
if (!RegisterClass(&wc)) return FALSE;
hWnd = CreateWindowEx(WS_EX_LAYERED|WS_EX_ACCEPTFILES ,
szWndClass,
_T("UItest"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
SetLayeredWindowAttributes(hWnd,NULL,255,LWA_ALPHA);
if (!hWnd) return FALSE;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while (bRet = GetMessage(&msg, NULL, 0, 0)) {
if (bRet == -1) return FALSE;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hWndMinute, hWndStop, hWndStart,hWndSecond;
HBRUSH hbrEdit1;
HDC hdc,hdc2;
HBRUSH hBrush, hOldBrush;
PAINTSTRUCT ps,ps2;
switch (message) {
case WM_CREATE:
{
CreateWindow("edit","edit",WS_CHILD|WS_VISIBLE, 30,30, 250,108,hWnd, (HMENU)ID_EDIT, hInstance, NULL);
return 0;
}
case WM_CTLCOLOREDIT:
{
if ((HWND)lParam == GetDlgItem(hWnd, ID_EDIT)) { /* エディットウィンドウのID */
SetBkColor((HDC)lParam,RGB(0 , 0 , 0)); /* 背景を透過にする */
SetTextColor((HDC)wParam, RGB(0,0,255)); /* 文字の色を設定する */
}
return 0;
}
case WM_SIZE:
{
// MoveWindow(hEdit, 0, 0, LOWORD(lp), HIWORD(lp)-21, TRUE);
break;
}
case WM_PAINT:
{
hdc2 = BeginPaint(hWnd, &ps2);
hBrush = CreateSolidBrush( RGB(255,255,0) );
SelectObject(hdc2, hBrush);
Rectangle(hdc2,27,28,57,50);
hOldBrush = (HBRUSH)SelectObject(hdc2, hBrush);
EndPaint(hWnd, &ps2);
return 0;
}
case WM_LBUTTONDOWN:
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}