|
-
February 20th, 2011, 12:27 AM
#1
"Fixing down" a CButton or CEdit control.
Hello again,
I was wondering how I could "fix down" a CButton or CEdit control in a scrollable main window. The problem is that when such a window is scrolled, the CButton or CEdit control floats over to the next scrolled region. How can I stop this from happening?
-
February 20th, 2011, 02:12 AM
#2
Re: "Fixing down" a CButton or CEdit control.
Place the controls (buttons, edits, and so on) in a control bar (preferable a dialog bar).
See CDialogBar and CControlBar MFC classes.
-
February 21st, 2011, 07:54 AM
#3
Re: "Fixing down" a CButton or CEdit control.
 Originally Posted by ovidiucucu
Place the controls (buttons, edits, and so on) in a control bar (preferable a dialog bar).
See CDialogBar and CControlBar MFC classes.
Thank you so much for replying! I'm working on it and I will get back to you about it. I've sub-classed CControlBar and i'm transferring all the control related functions.
Thanks again.
-
February 23rd, 2011, 07:59 AM
#4
Re: "Fixing down" a CButton or CEdit control.
I tried making a CControlBar derived class, but it signals this error:
Code:
1> 'void CControlBar::OnUpdateCmdUI(CFrameWnd *,BOOL)' : is abstract
1> c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\afxext.h(167) : see declaration of 'CControlBar::OnUpdateCmdUI'
What is an abstract class? Why is this happening?
-
February 23rd, 2011, 09:43 AM
#5
Re: "Fixing down" a CButton or CEdit control.
Am abstract class is a class which contains just abstract/general stuff and has no sense to be instantiated.
In C++, a class is abstract if has at least one pure virtual function.
Imagine a class Shape:
Code:
class Shape
{
protected:
int pen_color;
public:
void Draw();
};
Can we implement Shape::Draw? What to draw? A rectangle, an ellipse, something else? I think, in Shape class we have no idea.
So, let's make Shape abstract:
Code:
class Shape // abstract class
{
protected:
int pen_color;
public:
virtual void Draw() = 0; // pure virtual function
};
To make a derived class "concrete" we have to override all the base pure virtual functions, in our case the function Shape::Draw.
Code:
class Rectangle : public Shape
{
// ....
public:
virtual void Draw()
{
// draw a rectangle here.
}
};
CControlBar is like Shape: an abstract class. It has no sense to create an object of CControlBar type, then the compiler doesn't let you to do silly things. ;).
Use one of its derived concrete classes CDialogBar, CToolBar and so on.
As I already said, for your purpose, CDialogBar is preferable.
Last edited by ovidiucucu; February 23rd, 2011 at 09:55 AM.
Reason: typos
-
February 24th, 2011, 06:43 AM
#6
Re: "Fixing down" a CButton or CEdit control.
Thanks very much for the explanation. I've now tried using the CDialogBar instead.
1.) Since I've chosen to use CDialogBar, do i still subclass it and create the controls as private?
2.) Further, how could I reposition the CDialopBar? It's create function does not accept any CRect parameter.
3.) The CDialogBar will be created dynamically in the program. The CEdit controls may be created anywhere in a table in the program. Is this possible?
-
February 24th, 2011, 07:13 AM
#7
Re: "Fixing down" a CButton or CEdit control.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|