Solved

CWnd::Create()

Posted on 2003-11-24
6
1,795 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 56
mixString challenge 36 137
if loop in java 3 174
EvenOdd challenge 10 160
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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