Originally posted by: Tilo Berger
Very thanks for your button class but there's a little problem.
If you are using the CUniButton class with it's specified region and an ownerdrawed background, you should overwrite the WM_ERASEBKGND message. Otherwhise you'll get the right button region but a rectangular background for the button!
BOOL CUniButton::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
That works fine!
ReplyOriginally posted by: ranjanie
please intimate me how to create such buttons in VB?
Originally posted by: Aniruddha S. Deshmukh
I really liked the UniButton control. It is fantastic. It really shows off the power of regions. I have one question (problem) in this regard. I have created a test application using the UniButton where I have put 9 such buttons on a modal dialog box. I wanted to make the buttons toggle buttons. So I wrote the ON_BN_CLICKED handlers for all these buttons and also created a member variable in the dialog to hold the id of the button currently in pressed state (I wanted at the most only one button in a pressed state at any time). Inside each handler I have a switch-case stmt and inside this I have written the code to press / unpress a button. I have used the CButton::SetState() function to press/unpress a button. It seems to work fine. Now the problem: Suppose a button is in a pressed (sunken) state. Now when I try to click the ok button, this pressed button loses its state. So I can't get the button that was pressed before closing the dialog box. Thus when I have clicked the mouse on the ok button (but before releasing the mouse) the pressed button loses its state and then the dialog closes. I am not able to figure out why this is happening. When I tried to debug I found that when I press ok, the handler of the button that was in a sunken state is called (I wonder why) and inside this handler (since I want toggle buttons), my code checks whether the button was previously in a pressd / sunken states and reverses the state, since it thinks that the user has again clicked mouse on the button. Can anyone please anwer why this is happening?
Originally posted by: dharry
I have a couple of questions.
First, Why did you subclass off of CButton and not CWnd and pass the window class of _T("BUTTON") to the CWnd::Create function like CButton does to implement itself? This fixes the click problems that I get from using the CUniButton class in vc4.2.
Finally, how do you draw a user specific button. I have looked at the code and have been trying to understand the logic flow behind it.
ReplyOriginally posted by: Chun-Ki, Park
I create a resizable window and create a unibutton by child window
When window size is changed, how can I move the button control to desired position ?
-Park
ReplyOriginally posted by: G�nther Stany
Hi there !
I�ve got heavy troubles by displaying buttons in my Win-API program.
When I try it with C++ Code it works well but in C it does not.
Do You have any ideas for solving this problem ???
greetings
G. Stany
Originally posted by: Peter Sieg
// Construction
*.cpp:
The two probelms were:
I am quiet new to VC++, C++ in general. I know only C, Java
So, if this fixes are stupid - let me know. Its never to late
With the exception of the textarea buttons, everything works
In order to get it working in VC++4.0, I had to make the
following changes:
// other_buttonDlg.h : header file
*.h:
====
//
#define MY_BTN1 1001
#define MY_BTN2 1002
#define MY_BTN3 1003
#define MY_BTN4 1004
#define MY_BTN5 1005
#define MY_BTN6 1006
#define MY_BTN7 1007
#define MY_BTN8 1008
#define MY_BTN9 1009
#define MY_BTN10 1010
#define MY_BTN11 1011
#define MY_BTN12 1012
#define MY_BTN13 1013
#define MY_BTN14 1014
#define MY_BTN15 1015
#define MY_BTN16 1016
#define MY_BTN17 1017
#define MY_BTN18 1018
public:
//enum {MY_BTN1 = 1001, MY_BTN2 = 1002, MY_BTN3 = 1003, MY_BTN4 = 1004, MY_BTN5 = 1005, MY_BTN6 =
1006, MY_BTN7 = 1007, MY_BTN8 = 1008};
//enum {MY_BTN9 = 1009, MY_BTN10 = 1010, MY_BTN11 = 1011, MY_BTN12 = 1012, MY_BTN13 = 1013, MY_BTN14
= 1014, MY_BTN15 = 10015, MY_BTN16=1016};
//enum {MY_BTN17 = 1017, MY_BTN18 = 1018};
======
// assign new region to a window
m_bNeedBitmaps = TRUE;
SetWindowRgn(GetSafeHwnd(),m_hRgn, TRUE);
// get region
HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
GetWindowRgn(GetSafeHwnd(),hRgn);
1. VC++ could cot understand the enum definition properly
2. The numer of parameters in Set/GetWindowRegn was wrong.
The handle of the window was missing?
and Delphi...
to do things better. This is just what I have done, to get it
working...
with this changes.
Originally posted by: Rich Rubel
I've been looking at converting CUniButton to use CBitmapButton
instead of CButton, and I've been able to get a sample bitmap
to be drawn (same picture on every button), but I'm drawing
a blank on being able to paint the loaded bitmaps instead of
just a solid color. Anyone have any suggestions, or done
this conversion already?
Thanks.
ReplyOriginally posted by: Hai Lin
When I used UniButton as a close button in a dialog, an error happened. I added a condition in OnLButtonUp to verify the existance of current CWnd handle:
if (::IsWindow(this->m_hWnd))
then it works well
void CUniButton::OnLButtonUp(UINT nFlags, CPoint point)
{
// record that mouse is released
CButton::OnLButtonUp(nFlags, point);
// prevent invalid hwnd when use the button as close
// button
if (::IsWindow(this->m_hWnd))
{
m_bMouseDown = false;
if (m_bCapture)
{
ReleaseCapture();
m_bCapture = false;
}
CheckHover(point);
}
}
Reply
Originally posted by: Levi
The job is done very well, it will be interesting to see the same effects in checkbox buttons wich toggle on
click two positions - normal and sunken with different colors .
Another development can be usage of bitmaps.
Levi