|
It seems to me that it looks way better to use the greyscale bitmap created for the "BTNST_AUTO_GRAY" out button for disabled buttons than to use the default "disabled" state, which looks horrible. Or perhaps I'm missing something. You can see the effect if you enable the BTNST_AUTO_GRAY option and set the m_bShowDisabledBitmap to FALSE. Then it will default to using the greyscale image for disabled buttons. I've generalised this by creating a third array element and always creating a greyscale bitmap for the disabled state.
- Pfft. Coddled kids. In my day, we used to telnet to port 80, then render the page with pencil and paper-- and that's the way we liked it!
- Pshaw! Youngster. Your UID barely fits inside 16 bits. In _my_ day we had to whistle the 1's and 0's through an acoustic coupler!
Tools that support "all of UTF-8 as long as it starts with ASCII" and tools that cannot handle these three [BOM] bytes at all are not really supporting UTF-8.
- Michael Kaplan
|
|
|
|
|
Hello to everyone and thank you for using CButtonST for so many years !
If interested in x32/x64 Visual Studio 2017 CButtonST version please check my homepage here:
www.SoftechSoftware.it
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|
|
|
When adding an icon to this button on a very high DPI, the icon (if it's 16 pixels) and the button are not usable because they are too small.
Has anyone found an easy way to make this great control cope with that?
Any tip welcome!
|
|
|
|
|
Hi
I can't compile this now in x64 in VS2015. It is giving warnings about casting from int to HICON and/or HBITMAP.
Please help!
Andrew
|
|
|
|
|
Check here:
www.SoftechSoftware.it
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|
|
Hi,
I have to analyze the content of the button in another process. So I have to use the Windows API to acquire the title. It seems to correspond to the original text rather than the current. Did I miss something?
|
|
|
|
|
First of all,thanks you very much!But I have a few questions, for example, are the numbers of the Buttons limited?
|
|
|
|
|
Hi!
No, they aren't limited.
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|
|
|
Hi,
Thank you very much for this !
I however had to change some code :
void CButtonST::OnEnable(BOOL bEnable)
{
CButton::OnEnable(bEnable);
if (bEnable == FALSE)
{
CancelHover();
} }
I commented the SetFocus part because it bring some abnormal button behavior. I believe setting the focus to the next tab item might be done only if the disabled button is the current control with focus.
thx.
|
|
|
|
|
|
Hello folks,
I had a problem with this class that grayscale icons were not correctly created because the CreateGrayScaleIcon() method sometimes created black pixels.
Here's the solution (copied from here):
In BtnST.h:
To protected section, add:
HICON CreateGrayscaleIcon(HICON hIcon, COLORREF* pPalette);
In BtnST.cpp replace the whole CButtonST::CreateGrayscaleIcon() method with:
HICON CButtonST::CreateGrayscaleIcon(HICON hIcon, COLORREF* pPalette)
{
if (hIcon == NULL)
{
return NULL;
}
HDC hdc = ::GetDC(NULL);
HICON hGrayIcon = NULL;
ICONINFO icInfo = { 0 };
ICONINFO icGrayInfo = { 0 };
LPDWORD lpBits = NULL;
LPBYTE lpBitsPtr = NULL;
SIZE sz;
DWORD c1 = 0;
BITMAPINFO bmpInfo = { 0 };
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
if (::GetIconInfo(hIcon, &icInfo))
{
if (::GetDIBits(hdc, icInfo.hbmColor, 0, 0, NULL, &bmpInfo, DIB_RGB_COLORS) != 0)
{
bmpInfo.bmiHeader.biCompression = BI_RGB;
sz.cx = bmpInfo.bmiHeader.biWidth;
sz.cy = bmpInfo.bmiHeader.biHeight;
c1 = sz.cx * sz.cy;
lpBits = (LPDWORD)::GlobalAlloc(GMEM_FIXED, (c1) * 4);
if (lpBits && ::GetDIBits(hdc, icInfo.hbmColor, 0, sz.cy, lpBits, &bmpInfo, DIB_RGB_COLORS) != 0)
{
lpBitsPtr = (LPBYTE)lpBits;
UINT off = 0;
for (UINT i = 0; i < c1; i++)
{
off = (UINT)( 255 - (( lpBitsPtr[0] + lpBitsPtr[1] + lpBitsPtr[2] ) / 3) );
if (lpBitsPtr[3] != 0 || off != 255)
{
if (off == 0)
{
off = 1;
}
lpBits[i] = pPalette[off] | ( lpBitsPtr[3] << 24 );
}
lpBitsPtr += 4;
}
icGrayInfo.hbmColor = ::CreateCompatibleBitmap(hdc, sz.cx, sz.cy);
if (icGrayInfo.hbmColor != NULL)
{
::SetDIBits(hdc, icGrayInfo.hbmColor, 0, sz.cy, lpBits, &bmpInfo, DIB_RGB_COLORS);
icGrayInfo.hbmMask = icInfo.hbmMask;
icGrayInfo.fIcon = TRUE;
hGrayIcon = ::CreateIconIndirect(&icGrayInfo);
::DeleteObject(icGrayInfo.hbmColor);
}
::GlobalFree(lpBits);
lpBits = NULL;
}
}
::DeleteObject(icInfo.hbmColor);
::DeleteObject(icInfo.hbmMask);
}
::ReleaseDC(NULL,hdc);
return hGrayIcon;
}
HICON CButtonST::CreateGrayscaleIcon( HICON hIcon )
{
static COLORREF defaultGrayPalette[256];
static BOOL bGrayPaletteSet = FALSE;
if (hIcon == NULL)
{
return NULL;
}
if (!bGrayPaletteSet)
{
for(int i = 0; i < 256; i++)
{
defaultGrayPalette[i] = RGB(255-i, 255-i, 255-i);
}
bGrayPaletteSet = TRUE;
}
return CreateGrayscaleIcon(hIcon, defaultGrayPalette);
}
|
|
|
|
|
I replied to an earlier thread on this subject, but with the organization of this discussion board I think no one would notice a reply to an 8-year old message, so to repeat myself...
When building this code, one gets a compiler warning:
BtnST.cpp(19) : warning C4005: 'BS_TYPEMASK' : macro redefinition c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(8749) : see previous definition of 'BS_TYPEMASK'
To which Nirav replied:
I have also encountered the same warning.
Is it because of the MS-Platform SDK that we have installed, as the warning is because the constant is already defined in the WinUser.h in the Platform SDK.
Is this inevitable, or there's something wrong that we're doing?
To which I reply and ask:
The problem isn't just that it is being defined again, but that it is being defined again with a different value. In BtnST.cpp BS_TYPEMASK is defined as SS_TYPEMASK , on my current development system SS_TYPEMASK is defined as 0x0000001FL ; however before this line BS_TYPEMASK was 0x0000000FL . So the general questions are:
- Should it be
0x1F or 0x0F ? - Should it use the SDK's value if defined, but
0x1F if not? - Why
SS_TYPEMASK (a Static Control Style value) for BS_TYPEMASK (a Button Style value)?
|
|
|
|
|
This code use in my application and its works fine.
|
|
|
|
|
How to get the color of the clicked button.... i am new to mfc could u please explain the use of GetColor(BYTE byColorIndex, COLORREF* crpColor) with an example.
Thank You
modified 10-Feb-12 1:06am.
|
|
|
|
|
ON_BN_CLICKED(ID_CHECK_GROUP7, OnCheckRec7),in OnCheckRec7,can not get the CheckBox state!
|
|
|
|
|
hello thanks alot
I think if you add this function to (BtnST.cpp) ,when paint
(image button) has been problem , may be solve with this code .
for example if before create (image button) top of it have been a window , after create (button) and move window to other side for see (button) , (button) colored with window color and this problem stay until lifetime.
excuse me for bad english
hessamini@gmail.com
LRESULT CButtonST::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_NCPAINT:
{
m_bmpBk.DeleteObject();
m_dcBk.DeleteDC();
m_dcBk.m_hDC=NULL;
}
}
return CButton::WindowProc(message, wParam, lParam);
}
void CButtonST::OnLButtonDown(UINT nFlags, CPoint point)
{
GetParent()->Invalidate();
CButton::OnLButtonDown(nFlags, point);
}
salam
modified on Saturday, August 20, 2011 5:00 AM
|
|
|
|
|
|
Hi,
There is just a little limitation in the Get24BitPixels() function (Vander Nunes function).
It is written :
wBmpWidth -= (wBmpWidth%4);
It should be :
dwBmpWidth = (dwBmpWidth+3) & ~3;
example:
The width of my image is 279 pixels
In the formula you have a width result equals to 276, it should be 280.
The formula only works fine when the width is a multiply of 4.
Bye,
Jean-Philippe
|
|
|
|
|
|
This control is useful for me in decorating my program, and it is also powerful.
|
|
|
|
|
how to set font?thank you
|
|
|
|
|
sorry it is so easy to set font,now ,the problem is ,how is gif?
3q very much ![Laugh | :laugh:](https://cdn.statically.io/img/www.codeproject.com/script/Forums/Images/smiley_laugh.gif)
|
|
|
|
|
很好很强大,我做课程设计要用!
提个建议,能不能设定按钮的形状,比如随意设置形状为圆形或方形??
Thank you!
|
|
|
|
|