CWnd::Create()

I have two basic questions -

CWnd::Create(....) function takes in a parameter nID, The ID of child window.
Can i give any value that comes to my mind to this nID input ? or it is required to be within certain range.
for example I see the CControlBar::Create(..) requires the value to be between AFX_IDW_CONTROLBAR_FIRST and AFX_IDW_CONTROLBAR_LAST (?)
Similarly AFX_IDW_PANE_FIRST and AFX_IDW_PANE_LAST are seen when we create a default SDI without Doc-view support.

m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)

1 - What is the significance of nID in CWnd::Create(..), i.e. whats  AFX_IDW_CONTROLBAR_FIRST / LAST / AFX_IDW_CONTROLBAR_FIRST /AFX_IDW_CONTROLBAR_LAST etc

If i make AFX_IDW_CONTROLBAR_FIRST to AFX_IDW_CONTROLBAR_LAST it stops repainting the view  when i resize the main frame.
2 - why

you know i am novice.

LVL 1
bhiveAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

igor_skCommented:
When you create controls in your window (ex. in your dialog box) you assign unique ID to each one of controls. You can assign it yourself or with DevStudio (when you create dialog boxes).

Then, you can access different controls in your dialog by control ID. You can use CWnd::GetDlgItem(int nID) method for this purpose. It returns a pointer to the given control or child window.
0
bhiveAuthor Commented:
thx, that helps taking me closer to understand the nID. I don;t know however why are the nIDs like AFX_IDW_CONTROLBAR_FIRST / LAST , AFX_IDW_PANE_FIRST/LAST etc
 are hardcoded.
and any clue for question - (2) ...
0
SteHCommented:
_FIRST / _LAST are just ends of a range. This allows to use _FIRST / _LAST in a check whether the values are in that range but having the ability to change the actual values of used names.
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

bhiveAuthor Commented:
igor, steh you guys answered the first part thx.
Any idea why the making _FIRST to _LAST stops the view from being painted ?
0
SteHCommented:
Hello bhive,

since you're asking in the MFC forum I suggest to use
CControlBar::CControlBar () to create a control bar. The underlying CWnd::Create () is then called from the framework and the ID assigned there. This assures a proper value of the nID. Unless you really know what to do you should create the control objects and not CWnd's which you have to somehow convert to be of a control class.

The value of AFX_IDW_CONTROLBAR_FIRST is by the time you are calling definitly in use. The next control bar should have a value of LAST + 1 and change the value of LAST. But this should be handled by the framework.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bhiveAuthor Commented:
thx SteH, i am deriving CMyClass from CControlBar.
I am going to give you the points ...
here is the story that i want to report, and your comments are welcome.
Now i have a
CMyClass::Create(Cwnd *pParent, nID){ CControlBar::Create(.., nID,...), where pParent is my CFrameWnd main frame.
It took long to figure out that CMyClass has to have (?) a CalcFixedLayout() that returns CSize. without which i could not make it see on the screen. correct me if i am doing it unnecessarily.
So now i have my CMyClass visible in the frame wnd as a sibling of the main view.
then the problem was that if i resize the CMyClass control bar, then the view doesnot refresh. So i add a call to pParent->RecalcLayout() in the OnSize event handler of CMyClass.

however i am facing one lil problem when i resize the main frame wnd, MyClass window touches the menu bar and lower edge of the frame wnd and displaces the default toolbar and status bar to the right.

More importantly, i would like to know if i am doing the whole thing right or not. your comments or any sample would be greatly appreciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.