Click here to Skip to main content
11,637,176 members (59,691 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 MFC
The CDC (SetPixel) function cannot be accessible inside the member function of another class.

//OnPerformIBIT is a member function created by me
void CSplitterOne:: OnPerformIBIT()
{
    CDC *myDC = GetDlgItem(IDC_PICBOX)->GetDC();
 
    myDC->SetPixel(0, 0, RGB(0,0,0));
    myDC->SetPixel(1, 1, RGB(0,0,0));
    myDC->SetPixel(2, 2, RGB(0,0,0));
    myDC->SetPixel(3, 3, RGB(0,0,0));
    myDC->SetPixel(4, 4, RGB(0,0,0));
    myDC->SetPixel(5, 5, RGB(0,0,0));
    myDC->SetPixel(6, 6, RGB(0,0,0));
}

//In the above function is called from MainFrm.cpp. In the same function I cannot create the object for CDC. It give assertion. I am not get the Handle for Window (hWnd).
If I am do the same in thing in OnPaint() it works. Please Help me.

//CSplitterOne is FormView class.
Posted 8-Mar-13 23:26pm
Comments
Jochen Arndt at 9-Mar-13 7:38am
   
Is IDC_PICBOX a child window of CSplitterOn?
rajeshkumar.ramasamy at 20-Mar-13 8:02am
   
Yes, IDC_PICBOX is child window of CSplitterOne class.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It looks like you are calling GetDlgItem at a moment when the window has not been created yet. Then it's m_hWnd is still 0 and you run into an ASSERT.

You can easily verify this assumption by testing m_hWnd before calling GetDlgItem.
  Permalink  
Comments
rajeshkumar.ramasamy at 12-Mar-13 8:09am
   
I had Create same form using Splitter Window. I have to call the OnPerformIBIT() function from MainFrm.cpp. I am not got the handle when I am calling from MainFrm.cpp, If I put the same function from OnPaint & OnInitialUpdate, it works. How can i get the window handle if i'm call from Mainfrm.cpp?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 stibee 288
2 jyo.net 270
3 Sergey Alexandrovich Kryukov 214
4 himanshu agarwal 184
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,513
2 Mika Wendelius 6,922
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320


Advertise | Privacy | Mobile
Web04 | 2.8.150728.1 | Last Updated 14 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100