Solved

CWnd is transparent

Posted on 2012-03-10
3
830 Views
Last Modified: 2012-03-10
Just trying to create an MFC CWnd window.  Do I need to derive from CWnd or can I just use a CWnd.  Anyway, window is failing to show although I know it is there because i can see it in its iconized state in the task bar and if i click it i get the outline although the inside is transparent.  I would have thought the client area would be white.  It doesn't matter if I register a class or not.  If I supply NULL for the window class the problem is the same.  Please help
      CWnd* pWnd = new CWnd;
      CString strMyClass = AfxRegisterWndClass(
      CS_VREDRAW | CS_HREDRAW,
      ::LoadCursor(NULL, IDC_ARROW),
      (HBRUSH) ::GetStockObject(WHITE_BRUSH),
      ::LoadIcon(NULL, IDI_APPLICATION));
      BOOL success= pWnd->Create(
       NULL,
         strMyClass,
       //strMyClass,
       WS_OVERLAPPED, // if the window doesn't need to be visible you don't need any styles
       CRect(0,0,300,300),
       CWnd::GetDesktopWindow(),
         //this,
       1234);
      if (success)
            pWnd->ShowWindow(SW_SHOW);
0
Comment
Question by:supportoranges
  • 3
3 Comments
 
LVL 1

Author Comment

by:supportoranges
ID: 37705273
I guess the window isn't transparent.  I have attached a screenshot of what i see if i Spy++ on the window.  I know I have the right one.  Why is it black?  It's like a black hole.  Please help this is driving me crazy.
forexperts.png
0
 
LVL 1

Accepted Solution

by:
supportoranges earned 0 total points
ID: 37706053
CString strMyClass = AfxRegisterWndClass(
      CS_VREDRAW | CS_HREDRAW,
      ::LoadCursor(NULL, IDC_ARROW),
      (HBRUSH) ::GetStockObject(WHITE_BRUSH),
      ::LoadIcon(NULL, IDI_APPLICATION));
      BOOL success= pWnd->Create(
       strMyClass,
         "Hello",
       WS_OVERLAPPEDWINDOW, // if the window doesn't need to be visible you don't need any styles
       CRect(0,0,300,300),
       CWnd::GetDesktopWindow(),
         //this,
       1234);
      if (success)
            pWnd->ShowWindow(SW_SHOWNORMAL);
0
 
LVL 1

Author Closing Comment

by:supportoranges
ID: 37706055
This worked
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

856 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