Solved

CWnd::Create()

Posted on 2003-11-24
6
1,743 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now