Ignore:
Timestamp:
Oct 8, 1999, 2:10:27 PM (26 years ago)
Author:
cbratschi
Message:

resource and other fixes

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 sandervl Exp $ */
     1/* $Id: button.cpp,v 1.4 1999-10-08 12:10:26 cbratschi Exp $ */
    22/* File: button.cpp -- Button type widgets
    33 *
     
    129129  {
    130130    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);
    133137    if (GetObjectA(hbitmapCheckBoxes,sizeof(bmp),&bmp))
    134138    {
     
    393397  GetClientRect(hwnd,&rect);
    394398  point = MAKELPARAM(rect.right/2,rect.bottom/2);
    395   SendMessageA(hwnd,WM_LBUTTONDOWN,0,point);
     399  SendMessageA(hwnd,WM_LBUTTONDOWN,MK_LBUTTON,point);
    396400  Sleep(100);
    397401  SendMessageA(hwnd,WM_LBUTTONUP,0,point);
     
    503507 *           ButtonWndProc
    504508 */
     509static
    505510LRESULT WINAPI ButtonWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
    506511{
     
    612617     */
    613618    BUTTON_DrawPushButton(hwnd,
    614                           hDC,
    615                           action,
    616                           bHighLighted);
     619                          hDC,
     620                          action,
     621                          bHighLighted);
    617622}
    618623
     
    649654    {
    650655        Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
    651         InflateRect( &rc, -1, -1 );
     656        InflateRect( &rc, -1, -1 );
    652657    }
    653658
     
    693698            /* don't write gray text on gray background */
    694699            PaintGrayOnGray( hDC,infoPtr->hFont,&rc,text,
    695                                DT_CENTER | DT_VCENTER );
     700                               DT_CENTER | DT_VCENTER );
    696701        else
    697702        {
     
    702707                         DT_SINGLELINE | DT_CENTER | DT_VCENTER );
    703708            /* do we have the focus?
    704              * Win9x draws focus last with a size prop. to the button
    705              */
     709             * Win9x draws focus last with a size prop. to the button
     710             */
    706711        }
    707712        free(text);
    708713    }
    709714    if ( ((dwStyle & BS_ICON) || (dwStyle & BS_BITMAP) ) &&
    710         (infoPtr->hImage != NULL) )
    711     {
    712         int yOffset, xOffset;
    713         int imageWidth, imageHeight;
    714 
    715         /*
    716         * We extract the size of the image from the handle.
    717         */
    718         if (dwStyle & BS_ICON)
    719         {
    720             ICONINFO iconInfo;
    721             BITMAP   bm;
    722 
    723             GetIconInfo((HICON)infoPtr->hImage, &iconInfo);
    724             GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm);
    725        
    726             imageWidth  = bm.bmWidth;
    727             imageHeight = bm.bmHeight;
     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;
    728733
    729734            DeleteObject(iconInfo.hbmColor);
    730735            DeleteObject(iconInfo.hbmMask);
    731736
    732         }
    733         else
    734         {
    735             BITMAP   bm;
    736 
    737             GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm);
    738        
    739             imageWidth  = bm.bmWidth;
    740             imageHeight = bm.bmHeight;
    741         }
    742 
    743         /* Center the bitmap */
    744         xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - imageWidth ) / 2;
    745         yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - imageHeight) / 2;
    746 
    747         /* If the image is too big for the button then create a region*/
     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*/
    748753        if(xOffset < 0 || yOffset < 0)
    749         {
     754        {
    750755            HRGN hBitmapRgn = NULL;
    751756            hBitmapRgn = CreateRectRgn(
     
    754759            SelectClipRgn(hDC, hBitmapRgn);
    755760            DeleteObject(hBitmapRgn);
    756         }
    757 
    758         /* Let minimum 1 space from border */
    759         xOffset++, yOffset++;
    760 
    761         /*
    762         * Draw the image now.
    763         */
    764         if (dwStyle & BS_ICON)
    765         {
    766             DrawIcon(hDC,
     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,
    767772                rc.left + xOffset, rc.top + yOffset,
    768                      (HICON)infoPtr->hImage);
    769         }
    770         else
     773                     (HICON)infoPtr->hImage);
     774        }
     775        else
    771776        {
    772             HDC hdcMem;
    773 
    774             hdcMem = CreateCompatibleDC (hDC);
    775             SelectObject (hdcMem, (HBITMAP)infoPtr->hImage);
    776             BitBlt(hDC,
    777                    rc.left + xOffset,
    778                    rc.top + yOffset,
    779                    imageWidth, imageHeight,
    780                    hdcMem, 0, 0, SRCCOPY);
    781        
    782             DeleteDC (hdcMem);
    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        }
    784789
    785790        if(xOffset < 0 || yOffset < 0)
     
    875880    {
    876881        BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) ||
    877                              (infoPtr->state & BUTTON_CHECKED));
     882                             (infoPtr->state & BUTTON_CHECKED));
    878883
    879884        BUTTON_DrawPushButton(hwnd,
    880                               hDC,
    881                               action,
    882                               bHighLighted);
    883         return;
     885                              hDC,
     886                              action,
     887                              bHighLighted);
     888        return;
    884889    }
    885890
Note: See TracChangeset for help on using the changeset viewer.