diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-19 18:48:35 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-19 18:48:35 +0000 |
commit | 3b3bdf6af13a209838d2a99efdc23bfd35f02f3d (patch) | |
tree | d538b7816d8a968ace9ec7a6920b46215e74a7a5 /src/modules/button/button.cpp | |
parent | eb8ccdb0ad9e2c508f425b2b25a6eb1e25644461 (diff) |
tabSRMM button sync
git-svn-id: http://svn.miranda-ng.org/main/trunk@486 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/button/button.cpp')
-rw-r--r-- | src/modules/button/button.cpp | 86 |
1 files changed, 46 insertions, 40 deletions
diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index 752e4da1bb..bf5b2b6893 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -316,9 +316,9 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L }
break; // DONT! fall thru
- case WM_NCDESTROY:
+ case WM_NCDESTROY:
mir_free(bct);
- break;
+ break;
case WM_SETTEXT:
bct->cHot = 0;
@@ -383,33 +383,35 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_NCPAINT:
case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdcPaint = BeginPaint(hwndDlg, &ps);
- if (hdcPaint) {
- PaintWorker(bct, hdcPaint);
- EndPaint(hwndDlg, &ps);
+ {
+ PAINTSTRUCT ps;
+ HDC hdcPaint = BeginPaint(hwndDlg, &ps);
+ if (hdcPaint) {
+ PaintWorker(bct, hdcPaint);
+ EndPaint(hwndDlg, &ps);
+ }
}
break;
- }
+
case BM_SETIMAGE:
- {
- HGDIOBJ hnd = NULL;
- if (bct->hIcon) hnd = bct->hIcon;
- else if (bct->hBitmap) hnd = bct->hBitmap;
-
- if (wParam == IMAGE_ICON) {
- bct->hIcon = (HICON)lParam;
- bct->hBitmap = NULL;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- }
- else if (wParam == IMAGE_BITMAP) {
- bct->hBitmap = (HBITMAP)lParam;
- bct->hIcon = NULL;
- InvalidateRect(bct->hwnd, NULL, TRUE);
+ {
+ HGDIOBJ hnd = NULL;
+ if (bct->hIcon) hnd = bct->hIcon;
+ else if (bct->hBitmap) hnd = bct->hBitmap;
+
+ if (wParam == IMAGE_ICON) {
+ bct->hIcon = (HICON)lParam;
+ bct->hBitmap = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ else if (wParam == IMAGE_BITMAP) {
+ bct->hBitmap = (HBITMAP)lParam;
+ bct->hIcon = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
}
return (LRESULT)hnd;
- }
+
case BM_GETIMAGE:
if (bct->hIcon) return (LRESULT)bct->hIcon;
else if (bct->hBitmap) return (LRESULT)bct->hBitmap;
@@ -513,6 +515,7 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L mir_free(ti.lpszText);
}
break;
+
case WM_SETFOCUS: // set keybord focus and redraw
bct->focus = 1;
InvalidateRect(bct->hwnd, NULL, TRUE);
@@ -547,23 +550,24 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L break;
case WM_LBUTTONUP:
- {
- int showClick = 0;
- if (bct->bIsPushBtn) {
- if (bct->bIsPushed) bct->bIsPushed = 0;
- else bct->bIsPushed = 1;
- }
- if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
- if (bct->stateId == PBS_PRESSED)
- showClick = 1;
- if (msg == WM_LBUTTONUP) bct->stateId = PBS_HOT;
- else bct->stateId = PBS_NORMAL;
- InvalidateRect(bct->hwnd, NULL, TRUE);
+ {
+ int showClick = 0;
+ if (bct->bIsPushBtn) {
+ if (bct->bIsPushed) bct->bIsPushed = 0;
+ else bct->bIsPushed = 1;
+ }
+ if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
+ if (bct->stateId == PBS_PRESSED)
+ showClick = 1;
+ if (msg == WM_LBUTTONUP) bct->stateId = PBS_HOT;
+ else bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ if (showClick) // Tell your daddy you got clicked.
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
}
- if (showClick) // Tell your daddy you got clicked.
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
break;
- }
+
case WM_MOUSEMOVE:
if (bct->stateId == PBS_NORMAL) {
bct->stateId = PBS_HOT;
@@ -572,11 +576,13 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L // Call timer, used to start cheesy TrackMouseEvent faker
SetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL);
break;
+
case WM_TIMER: // use a timer to check if they have did a mouseout
if (wParam == BUTTON_POLLID) {
RECT rc;
- POINT pt;
GetWindowRect(hwndDlg, &rc);
+
+ POINT pt;
GetCursorPos(&pt);
if ( !PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave
PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L);
|