Changeset 1184 for trunk/src/user32/button.cpp
- Timestamp:
- Oct 8, 1999, 2:10:27 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/button.cpp
r992 r1184 1 /* $Id: button.cpp,v 1. 3 1999-09-20 19:17:57 sandervlExp $ */1 /* $Id: button.cpp,v 1.4 1999-10-08 12:10:26 cbratschi Exp $ */ 2 2 /* File: button.cpp -- Button type widgets 3 3 * … … 129 129 { 130 130 BITMAP bmp; 131 132 hbitmapCheckBoxes = NativeLoadBitmap(0,MAKEINTRESOURCEA(OBM_CHECKBOXES)); 131 HINSTANCE hinst; 132 133 //CB: Open32 hack to load our own bitmap 134 hinst = LoadLibraryA("USER32.DLL"); 135 hbitmapCheckBoxes = NativeLoadBitmap(hinst,MAKEINTRESOURCEA(OBM_CHECKBOXES)); 136 FreeLibrary(hinst); 133 137 if (GetObjectA(hbitmapCheckBoxes,sizeof(bmp),&bmp)) 134 138 { … … 393 397 GetClientRect(hwnd,&rect); 394 398 point = MAKELPARAM(rect.right/2,rect.bottom/2); 395 SendMessageA(hwnd,WM_LBUTTONDOWN, 0,point);399 SendMessageA(hwnd,WM_LBUTTONDOWN,MK_LBUTTON,point); 396 400 Sleep(100); 397 401 SendMessageA(hwnd,WM_LBUTTONUP,0,point); … … 503 507 * ButtonWndProc 504 508 */ 509 static 505 510 LRESULT WINAPI ButtonWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 506 511 { … … 612 617 */ 613 618 BUTTON_DrawPushButton(hwnd, 614 615 616 619 hDC, 620 action, 621 bHighLighted); 617 622 } 618 623 … … 649 654 { 650 655 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); 651 656 InflateRect( &rc, -1, -1 ); 652 657 } 653 658 … … 693 698 /* don't write gray text on gray background */ 694 699 PaintGrayOnGray( hDC,infoPtr->hFont,&rc,text, 695 700 DT_CENTER | DT_VCENTER ); 696 701 else 697 702 { … … 702 707 DT_SINGLELINE | DT_CENTER | DT_VCENTER ); 703 708 /* do we have the focus? 704 705 709 * Win9x draws focus last with a size prop. to the button 710 */ 706 711 } 707 712 free(text); 708 713 } 709 714 if ( ((dwStyle & BS_ICON) || (dwStyle & BS_BITMAP) ) && 710 711 { 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 715 (infoPtr->hImage != NULL) ) 716 { 717 int yOffset, xOffset; 718 int imageWidth, imageHeight; 719 720 /* 721 * We extract the size of the image from the handle. 722 */ 723 if (dwStyle & BS_ICON) 724 { 725 ICONINFO iconInfo; 726 BITMAP bm; 727 728 GetIconInfo((HICON)infoPtr->hImage, &iconInfo); 729 GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm); 730 731 imageWidth = bm.bmWidth; 732 imageHeight = bm.bmHeight; 728 733 729 734 DeleteObject(iconInfo.hbmColor); 730 735 DeleteObject(iconInfo.hbmMask); 731 736 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 737 } 738 else 739 { 740 BITMAP bm; 741 742 GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm); 743 744 imageWidth = bm.bmWidth; 745 imageHeight = bm.bmHeight; 746 } 747 748 /* Center the bitmap */ 749 xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - imageWidth ) / 2; 750 yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - imageHeight) / 2; 751 752 /* If the image is too big for the button then create a region*/ 748 753 if(xOffset < 0 || yOffset < 0) 749 754 { 750 755 HRGN hBitmapRgn = NULL; 751 756 hBitmapRgn = CreateRectRgn( … … 754 759 SelectClipRgn(hDC, hBitmapRgn); 755 760 DeleteObject(hBitmapRgn); 756 757 758 759 760 761 762 763 764 765 766 761 } 762 763 /* Let minimum 1 space from border */ 764 xOffset++, yOffset++; 765 766 /* 767 * Draw the image now. 768 */ 769 if (dwStyle & BS_ICON) 770 { 771 DrawIcon(hDC, 767 772 rc.left + xOffset, rc.top + yOffset, 768 769 770 773 (HICON)infoPtr->hImage); 774 } 775 else 771 776 { 772 773 774 775 776 777 778 779 780 781 782 783 777 HDC hdcMem; 778 779 hdcMem = CreateCompatibleDC (hDC); 780 SelectObject (hdcMem, (HBITMAP)infoPtr->hImage); 781 BitBlt(hDC, 782 rc.left + xOffset, 783 rc.top + yOffset, 784 imageWidth, imageHeight, 785 hdcMem, 0, 0, SRCCOPY); 786 787 DeleteDC (hdcMem); 788 } 784 789 785 790 if(xOffset < 0 || yOffset < 0) … … 875 880 { 876 881 BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) || 877 882 (infoPtr->state & BUTTON_CHECKED)); 878 883 879 884 BUTTON_DrawPushButton(hwnd, 880 881 882 883 885 hDC, 886 action, 887 bHighLighted); 888 return; 884 889 } 885 890
Note:
See TracChangeset
for help on using the changeset viewer.