Solved

CWnd::Create()

Posted on 2003-11-24
6
1,767 Views
Last Modified: 2013-11-20
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.

0
Comment
Question by:bhive
  • 3
  • 2
6 Comments
 
LVL 1

Assisted Solution

by:igor_sk
igor_sk earned 25 total points
ID: 9815682
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
 
LVL 1

Author Comment

by:bhive
ID: 9816129
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
 
LVL 13

Expert Comment

by:SteH
ID: 9816711
_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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 1

Author Comment

by:bhive
ID: 9821577
igor, steh you guys answered the first part thx.
Any idea why the making _FIRST to _LAST stops the view from being painted ?
0
 
LVL 13

Accepted Solution

by:
SteH earned 100 total points
ID: 9823117
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
 
LVL 1

Author Comment

by:bhive
ID: 9871689
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

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 92
Prevent this page from creating additional dialogs. 3 532
Smart Camera scanning and reading information 3 106
fizzArray2 challenge 1 79
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question