i want to remove DialogBox Button's border without OwnerDraw. Im using Win32 not MFC. Please guide how to do it.
Printable View
i want to remove DialogBox Button's border without OwnerDraw. Im using Win32 not MFC. Please guide how to do it.
You want to remove the border of the buttons on a dialog box? Or you want to remove the border of a dialog box? I'm a little bit confused here.
Without owner draw, you could try to use the BS_FLAT style, but it might still have a border.
I need to remove button border in dialogbox.
Any one??
why you guys are so confused.. its clearly written in the title that "Button border remove".. so what does this means... i want to remove button borders within dialog box
Code:CWnd::ModifyStyle (WS_BORDER, 0);
This is a MFC code. How to apply this in Win32 coding..
You can use GetWindowLong() and SetWindowLong().
I'm not sure this is going to work though. But on the other hand, I never tried it.Code:DWORD styles = ::GetWindowLong(hWnd, GWL_STYLE);
styles &= ~WS_BORDER;
::SetWindowLong(hWnd, GWL_STYLE, styles);
No.. no use
The code posted by Cilu did not serve my purpose. I need to remove Button border within a dialogbox without using owner draw..
Use Spy++ to find out this button styles. Then try to remove all styles that could cause any type of the border (use the code similar to what cilu posted)
Cilu's code has nothing to do with ownerdraw or not. It simply changes a windowstyle. Below you see the MFC implementation. It's allmost the same. And this code has also nothing to do with ownerdraw.
Code:AFX_STATIC BOOL AFXAPI _AfxModifyStyle(HWND hWnd, int nStyleOffset,
DWORD dwRemove, DWORD dwAdd, UINT nFlags)
{
ASSERT(hWnd != NULL);
DWORD dwStyle = ::GetWindowLong(hWnd, nStyleOffset);
DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
if (dwStyle == dwNewStyle)
return FALSE;
::SetWindowLong(hWnd, nStyleOffset, dwNewStyle);
if (nFlags != 0)
{
::SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
}
return TRUE;
}
Just checked in spy++.. there is no style dealing with button border..
Okay. I think there is no other options rather than creating a owner draw button to server my purpose. So can you guys post here a win32 code for creating a simple windows style owner draw button which looks exactly as BS_PUSHBUTTON style.
Removing the border from button may not serve your purpose on all Windows OSs. Like in Windows 98/2000, buttons have different form, in Windows XP, it was changed, and in Vista it is further revamped. You should not confuse the end user. Your UI should be consistent as per the user's OS and settings.
And what you want to achieve by removing the border? You don't want border, place a 'static' control (which doesn't have border). Handle the click events. Yes, that's absurd! Depends on your perspective, if more absurd than your idea!
Perhaps you'll explain us what and why you are trying to accomplish with such a button "without a boarder"?
PS: I've just read the Ajay Vijay's post... And I totally agree with him! :thumb:
Okay let me explain my story. I'm creating a win xp exe. also can execute on other os but its particularly for xp. and im using blue background picture instead of default white or gray color of dialog box. so after creating the buttons on that blue background the light borders comes to view around the buttons. so i wanna remove them. hope now u guys dont have any confusions why im trying to do this..
Then you must use owner drawing. Use DrawFrameControl in your owner-draw code, to draw required control' parts in standard format.
No one is confused here. No one is dying here to help you. Consider your language next time.Quote:
hope now u guys dont have anymore confusion why im trying to do this..
Okay. Can you post a sample win32 code for creating an owner draw button looking exactly like normal BS_PUSHBUTTON.
One of these articles may help:
http://www.codeguru.com/cpp/controls/buttonctrl
Thanks for the link brother.
In my case, I am trying to create a synthesizer keyboard, and was planning on an array of buttons. However, the borders are not visually appealing in the context of a music keyboard.
I am open to suggestions, but what exactly is a "static" control?
Are they accessible from the Properties window?
Thanks,
Mike
After playing around a bit (I am very new to Visual C++ and Windows in general), I see that setting the borders and padding to zero work just fine *IF* you set the Flat Style to Flat instead of the default, Standard.