Sign in to follow this  

MFC stressing me out, heres example

This topic is 4765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

whats wrong w the following code :
	CSliderCtrl *csc = 0;
	csc = new CSliderCtrl;
	csc->SetRange(0, 100, TRUE);
	csc->SetTicFreq(2);
	CWnd *pWndHandle = 0;
	pWndHandle = new CWnd;
	
	csc->Create(WS_CHILD | WS_VISIBLE | SS_CENTER, CRect(50,80,150,150), pWndHandle->GetParent() , 7);

All Im trying to do is make a slider control, but understand it in code. I think the problem is that I dont know how to get the hWnd of a parent window, or retrieve the hWnd of a child window.

Share this post


Link to post
Share on other sites
1) You can't call methods on the slider until you have called Create to make the window for it. Usually you create the slider as a child of a dialog (in OnInitDialog) or as a child of a view (in OnInitialUpdate).
2) You construct a CWnd with new which it looks like you want to be the parent of the slider, but you don't call Create on that either. Normally you would parent it with the CDialog derived class or the CView derived class in the functions mentioned above, using just the "this" pointer as the parent HWND.

Share this post


Link to post
Share on other sites

This topic is 4765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this