MasterZiv |
---|
Картежник,
код покажи... |
примерно так
...
LRESULT CALLBACK ButProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ButProc1(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ButProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ButProc3(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
...
bool hov=false,hov1=false,hov2=false,hov3=false;
HWND hWndButton;
HWND hWndButton1;
HWND hWndButton2;
HWND hWndButton3;
WNDPROC lpfnOldWndProc,lpfnOldWndProc1,lpfnOldWndProc2,lpfnOldWndProc3;
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){
...
hWndButton=CreateWindowEx(NULL,
"BUTTON",
"X",
WS_TABSTOP|WS_CHILD|BS_DEFPUSHBUTTON|WS_VISIBLE|BS_OWNERDRAW,
wndwd-25,
5,
20,
20,
hWnd,
(HMENU)IDC_CLOSE_BUTTON,
GetModuleHandle(NULL),
NULL);
lpfnOldWndProc = (WNDPROC)SetWindowLong(hWndButton,
GWL_WNDPROC, (DWORD) ButProc);
hWndButton1=CreateWindowEx(NULL,
"BUTTON",
"Повторить",
WS_TABSTOP|WS_CHILD|BS_DEFPUSHBUTTON|BS_OWNERDRAW,
boxwd-120+(wndwd-boxwd)/2,
80,
120,
30,
hWnd,
(HMENU)IDC_REPEAT_BUTTON,
GetModuleHandle(NULL),
NULL);
lpfnOldWndProc1 = (WNDPROC)SetWindowLong(hWndButton1,
GWL_WNDPROC, (DWORD) ButProc1);
...
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CTLCOLORBTN:
if((HWND)lParam==hWndButton){
if(!hov){
hBitmap = (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_CLOSE),IMAGE_BITMAP,0,0,LR_COPYFROMRESOURCE);
}
else{
hBitmap = (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_CLOSE_HOVER),IMAGE_BITMAP,0,0,LR_COPYFROMRESOURCE);
}
hdcMem0=CreateCompatibleDC((HDC)wParam);
SelectBitmap(hdcMem0,hBitmap) ;
BitBlt ((HDC)wParam,0,0,20,20,hdcMem0, 0,0, SRCCOPY) ;
}
if((HWND)lParam==hWndButton1){
if(!hov1){
hBitmap = (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_DOWNLOAD),IMAGE_BITMAP,0,0,LR_COPYFROMRESOURCE);
}
else{
hBitmap = (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_DOWNLOAD_HOVER),IMAGE_BITMAP,0,0,LR_COPYFROMRESOURCE);
}
hdcMem0=CreateCompatibleDC((HDC)wParam);
SelectBitmap(hdcMem0,hBitmap) ;
BitBlt ((HDC)wParam,0,0,120,30,hdcMem0, 0,0, SRCCOPY) ;
}
...
}
}
LRESULT CALLBACK ButProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_MOUSEMOVE:
{
BOOL trackSuccess = TrackMouse( hWnd );
}break;
case WM_MOUSEHOVER:
hov=true;
InvalidateRect(hWnd,NULL,TRUE);
break;
case WM_MOUSELEAVE:
hov=false;
InvalidateRect(hWnd,NULL,TRUE);
break;
}
return CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam);
}
LRESULT CALLBACK ButProc1(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_MOUSEMOVE:
{
BOOL trackSuccess = TrackMouse( hWnd );
}break;
case WM_MOUSEHOVER:
hov1=true;
InvalidateRect(hWnd,NULL,TRUE);
break;
case WM_MOUSELEAVE:
hov1=false;
InvalidateRect(hWnd,NULL,TRUE);
break;
}
return CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam);
}
...