Eric Fritzinger

I'm pretty new to MFC, and having problems with the group box object.

Using the resource editor, I created a form with a group box and a button. The group box is used in the DoDataExchange (DDX_Control(pDX, IDC_MYPANEL, myPanel)) of the dialog in order to use it with a custom class I created, which contains a reference to the button placed within the group box.

Ex.
//The custom class
class MyPanel : public CButton
{
public:
MyPanel();
private:
CButton* myButton;
}

MyPanel::MyPanel()
{
myButton = this->GetParent()->GetDlgItem(IDC_MYBUTTON);
myButton->SetParent(this);
myButton->SetWindowPos(&CWnd::wndTop, 10, 125, 0, 0, SWP_NOSIZE);
}


Now, if the button remains the child of the dialog, then it appears normally. However, if I SetParent() to the group box on the button, then there is a thick black border around the edge of the button, which looks ugly. Also, in the SetWindowPos() call, if I specify either wndTopMost or wndNoTopMost, then the button just doesn't appear.

Does anybody know why these things are happening

Thanks! =)
~Eric


Re: Visual C++ General Small style problem with a button

Simple Samples

I don't know what you are trying to do but I think you need to ask how to do what you need to do instead of asking for help with the solution you are attempting. You say "in order to use it with a custom class I created". I think you need to explain that better to get a better way to do what you need to do. I don't understand the need for a group box and it is probably not needed. You don't need to know MFC to describe the requirements; describe the requirements from the point of view of a non-programmer.






Re: Visual C++ General Small style problem with a button

Eric Fritzinger

Requirements:

-I need a group box, which is going to contain some information (edit fields, labels, and a drop-down box) and a button.
-There are going to be several of these group boxes.

In order to keep the code of the main dialog box's class from exploding to a ridiculous size, I separated out the group boxes into their own classes so that the events for the items within the group boxes could be handled by the group box object (my custom class).

What is happening is when I set the button's parent to be the group box, I'm getting a thick, black border around the button whereas if I don't set the group box to be the parent, then the button looks fine.

I'm wondering if there is a way to fix the visual effect so that there is no border whatsoever. Currently, I do not specify a border around the button, and all attempts to modify the style of the button have failed to yield the proper results.

Thanks for the help! =)
~Eric





Re: Visual C++ General Small style problem with a button

Simple Samples

Note that this does not say anything new and relevant.




Re: Visual C++ General Small style problem with a button

Eric Fritzinger

Sheesh. Ok, I figured that my explanation in my previous post would have been adequate, but apparently not.

So, what I'm trying to do is this:
I need a single dialog box.
It needs to have several labeled areas that will contain various controls.

All I'm trying to figure out is WHY there's a border around the button that I when I make it a child of a groupbox. However, if you have a better suggestion for how I can do what I need to do, then please tell me.

Thanks! =)
~Eric




Re: Visual C++ General Small style problem with a button

Bite Qiu - MSFT

Hi Eric,

Group box should not be used as the way you are using, binding a static control to a CButton derived class object makes no sense at all. I also tried to reproduce a thick black border button, but it all failed with the information you provided. It seems you tend to make group box a control container, if so, CFormView is the best choice:

MSDN wrote:
A form view is essentially a view that contains controls. These controls are laid out based on a dialog-template resource.

More information can be found:

http://msdn2.microsoft.com/en-us/library/353dcby6(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/1d7781f1(VS.80).aspx

hope it helps

rico






Re: Visual C++ General Small style problem with a button

Eric Fritzinger

Thanks for the response =).

Like I had mentioned, I am pretty new to MFC, and did not know that what I was doing was incorrect. I could find no documentation on the subject prior to your links, so I was pretty frustrated.

This helps a lot, thank you again =).

~Eric





Re: Visual C++ General Small style problem with a button

Simple Samples

There is a lot to learn. It is not possible to quickly learn everything about MFC and everything about Windows programming; it is even difficult to learn both at the same time. As much as MFC relieves us of the details of Windows programming, MFC does not free us from the necessity to learn Windows programming also. You probably know all that already but I am saying this to emphasize the importance of learning Windows programming also.

Your requirements seem complex enough that you likely need to learn about Windows programming in general. I would be more specific but I am not familiar with your requirements enough to be more specific.






Re: Visual C++ General Small style problem with a button

Simple Samples

Bite Qiu - MSFT wrote:
MSDN wrote:
A form view is essentially a view that contains controls. These controls are laid out based on a dialog-template resource.

I think one good way to explain a form view is that it combines the advantages of a non-dialog window and a dialog.