Need to Make CDockablePane Background Transparent in c++ MFC - c++

I'm developing an application in MFC C++ and I have derived a CDockablePane object that I can view on the main window. I need the dockable pane's background to be transparent so you can see the main window through the dockable pane.
How would I accomplish this? Thanks.
this how i create the CDockable Pane object:
if (!FeaturePane.Create("Features", this, CSize (400,500), TRUE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Program window\n");
//return false; // failed to create
return FALSE;
}
i Know you can clear the background of a CDroDialog using the following code:
BOOL CDroDialog::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd,GWL_EXSTYLE) ^ WS_EX_LAYERED);
SetLayeredWindowAttributes(RGB(255,0,255),0, LWA_COLORKEY);
}
BOOL CDroDialog::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CRect clientRect ;
GetClientRect(&clientRect) ;
pDC->FillSolidRect(clientRect, RGB(255,0,255)) ; // paint background in magenta
//return CDialog::OnEraseBkgnd(pDC);
return FALSE;
}

Related

how to create or dock dockable pane on full client screen MFC?

i want to create a dockable pane full size on client screen i want it load full size on client screen by default when application load at start point.i have tried with many ways like override setwindowpos() method and setminsize() method but it didn't work window not called this method on cdockable pane here is my code on oncreate() method in parent window
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
BOOL bNameValid;
// Create output window
CString strOutputWnd;
bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND);
ASSERT(bNameValid);
if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 0, 0), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Output window\n");
return FALSE; // failed to create
}
m_wndOutput.EnableDocking(CBRS_ALIGN_ANY );
int screen_height=GetSystemMetrics(SM_CYSCREEN);
int screen_width =GetSystemMetrics(SM_CXSCREEN);
m_wndOutput.SetMinSize(CSize(screen_height,screen_width)
m_wndOutput.CalcFixedLayout(FALSE,TRUE);
DockPane(&m_wndOutput);
}

Creating a child CWnd inside a CView paint corruption

I want to create a CWnd derived class inside a CView derived class. I am using also a window splitter to create a tree control menu to the left side and a view area in the right side like the draft below.
------------------------
| tree | View |
| menu | |
| | |
------------------------
The problem is that when CWnd::OnEraseBkgnd is called for the 1st time it erases the background from the Window's most top left corner instead of the view's client area causing a temporary corrupted area. I tried to use the SetWindowPos but didn't solve the problem.
I create the CWnd derived class like this
CRect rect;
m_MediaWindow->GetClientRect(&rect); //Get CSplitterView client area size
if (!m_videoChildWnd.Create(NULL, NULL, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE , rect, m_MediaWindow, ID_DSHOW_RENDER_WND)) {
// failed to create child
return TRUE;
}
::SetWindowPos(m_videoChildWnd,NULL, rect.left, rect.top, rect.Width(), rect.Height(),
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
m_videoChildWnd.ShowWindow(SW_SHOW);
Now inside m_videoChildWnd exist the OnEraseBkgnd function
BOOL CWndVideoChild::OnEraseBkgnd(CDC* pDC) {
// TODO: Add your message handler code here and/or call default
CBrush brush;
CRect rect;
GetClientRect(&rect);
brush.CreateStockObject(BLACK_BRUSH);
pDC->FillRect(rect,&brush);
return TRUE;
}
after almost 3 calls from the framework the repaint system restore the corrupted area and everything works just fine.
Any ideas how to solve this ?

MFC Project Combination: How to add a SDI application without document class to a MDI application?should I use child window?[MFC]

I'am now working with a MDI MFC app and want to add a console/command-line function to the app. The only function I want to take from QuickWin(see below) is to use its text area and the process function which captures input. If I can add it to a popup dialog or a dock bar, it will be great!
And I got the src-code of a SDI Applization without Document Class like this(link:http://www.codeproject.com/.../QuickWin-...):
My Question is: can I add the app into my MDI app, and how to deal with source or head files like:
MainFrm.cpp/MainFrm.h and class like: CQuickWinApp/CQuickView?(If I can pop up a child window to implement the function, better:))
In QuickWin's mainframe, it has something to do with client area, which is difficule to deal with:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// create splitter without views
m_wndSplitter.CreateStatic(this, 2, 1);
CCreateContext Context;
Context.m_pNewViewClass = RUNTIME_CLASS(CQuickView);
Context.m_pCurrentDoc = NULL;
Context.m_pNewDocTemplate = NULL;
Context.m_pLastView = NULL;
Context.m_pCurrentFrame = this;
// Create the Stdio QuickView
m_pStdioView = (CQuickView*)CreateView(&Context, AFX_IDW_PANE_FIRST);
if (m_pStdioView == NULL)
{
TRACE("Failed to create QuickWin Stdio View\n");
return FALSE; // fail to create
}
// Create the Stderr QuickView
m_pStderrView = (CQuickView*)CreateView(&Context, AFX_IDW_PANE_FIRST);
if (m_pStderrView == NULL)
{
TRACE("Failed to create QuickWin Stderr View\n");
return FALSE; // fail to create
}
m_pStderrView->SetReadOnly(TRUE);
ShowSplitter(theApp.m_bShowSplitter);
return TRUE;
}
in My MDI app:
The MDI app has 3 doctemplates:
//BCGPVisualStudioGUIDemo.cpp
m_pDocTemplateCpp = new CMultiDocTemplate(
IDR_BCGDEVTYPE_CPP,
RUNTIME_CLASS(CBCGPVisualStudioGUIDemoDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CBCGPVisualStudioGUIDemoView));
AddDocTemplate (m_pDocTemplateCpp);
m_pDocTemplateWeb = new CMultiDocTemplate(
IDR_BCGDEVTYPE_WEB,
RUNTIME_CLASS(CBCGPVisualStudioGUIDemoDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CBCGPVisualStudioGUIDemoView));
AddDocTemplate (m_pDocTemplateWeb);
m_pStartDocTemplate = new CMultiDocTemplate(
IDR_BCGDEVTYPE0,
RUNTIME_CLASS(CNetworkMapEditorDemoDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CNetworkMapEditorDemoView));
AddDocTemplate(m_pStartDocTemplate);
The app also has some dock bars:
//MainFrm.cpp
//------------------
// Create config bar:
//------------------
if (!m_wndClassView.Create (_T("config"), this, CRect (0, 0, 200, 200),
TRUE,
ID_VIEW_CLASS,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Class View bar\n");
return FALSE; // fail to create
}
//------------------
// Create output bar:
//------------------
if (!m_wndOutputView.Create (_T("output"), this, CRect (0, 0, 200, 100),
TRUE,
ID_VIEW_OUTPUT,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create output bar\n");
return FALSE; // fail to create
}
//------------------
// Create help bar:
//------------------
if (!m_wndDynamicHelpView.Create (_T("help"), this, CRect (0, 0, 200, 200),
TRUE,
ID_VIEW_DYNAMICHELP,
WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Dynamic Help Bar\n");
return FALSE; // fail to create
}
//------------------
// Create watch bar:
//------------------
if (!m_wndWatchBar.Create (_T("watch"), this, CRect (0, 0, 300, 100),
TRUE,
ID_VIEW_WATCH,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create watch bar\n");
return FALSE; // fail to create
}
//------------------
// Create property bar:
//------------------
if (!m_wndPropertiesBar.Create (_T("property"), this, CRect (0, 0, 300, 200),
TRUE,
ID_VIEW_PROPERTIES,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Properties Bar\n");
return FALSE; // fail to create
}
Can I add the QuickWin app's text function into my app's dock bar or into a doctemplate or just a popup window?
All you need to integrate the functionality of QuickWin into your application are 3 textboxes (one for stdin, stdout and stderr) and the following classes from the Quickwin project:
CRedirect
CRedir
CParamDlg (only optical fluff, not essential)
The CRedirect-class manages the creation of the new process as well as the redirection of stdin/stdout/stderr (in combination with CRedir).
You have to modify CRedir::OnChildWrite and -Started and -Terminate to fit your needs. These methods actually write the content to the view/textbox/whatever. It is helpful to look at CMainFrame::OnCopyData and CQuickView::Append on how this can be done.

MFC CEdit object in a CDialogEx object

I'd be very grateful if anyone could help me with this? I'm trying to create a dialog box with a text box in it for receiving error messages. I've added ON_WM_CREATE to the message map, and written this function which the debug goes through, but the object doesn't display.
int CImportDatatoAPMDlg::OnCreate(LPCREATESTRUCT LpCreateStruct)
{
if(CWnd::OnCreate(LpCreateStruct) == -1)
{
return -1;
}
CEdit *MessageBox = new CEdit;
MessageBox->Create(WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL,CRect(100, 200, 450, 150), this, 0x1552);
return 0;
}
Do I have to make a dummy box when I'm designing the dialog box. I've already done this for the rest of the controls? I'm also wondering where I give this object a number ID combination?
Thanks,
James
You normally should use VisualStudio resource editor to add controls to your dialog. If you want to do it manually then create and add controls in your overriden OnInitDialog method:
BOOL CImportDatatoAPMDlg::OnInitDialog() {
BOOL bRes = CDialog::OnInitDialog();
CEdit *MessageBox; // !!! put it into class definition
MessageBox = new CEdit
MessageBox->Create(WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL,CRect(100, 200, 450, 150), this, 0x1552);
return bRes;
}

MFC docking windows and where they dock

I have created (generated) a MDI project with tabbed documents with
VS2008 Pro.
Visual Studio generates an application with the File/Class view
window, properties window, output window and the first MDI document/
view.
I want to control the sides on which the windows dock. I thought this
was done in BOOL CMainFrame::CreateDockingWindows() , i changed the
CBRS_TOP to CBRS_BOTTOM and CBRS_RIGHT to CBRS_LEFT , but the windows
still come out the same in the client area. It makes no difference
what is use for a window style attribute of CBRS_xxxx. Where and how
can i control where in the client area these windows dock ?
I changed then in :
BOOL CMainFrame::CreateDockingWindows()
{
BOOL bNameValid;
// Create class view
CString strClassView;
bNameValid = strClassView.LoadString(IDS_CLASS_VIEW);
ASSERT(bNameValid);
if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE,ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Class View window\n");
return FALSE; // failed to create
}
// Create file view
CString strFileView;
bNameValid = strFileView.LoadString(IDS_FILE_VIEW);
ASSERT(bNameValid);
if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200),TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create File View window\n");
return FALSE; // failed to create
}
// Create output window
CString strOutputWnd;
bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND);
ASSERT(bNameValid);
if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100),
TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Output window\n");
return FALSE; // failed to create
}
// Create properties window
CString strPropertiesWnd;
bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND);
ASSERT(bNameValid);
if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |CBRS_RIGHT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Properties window\n");
return FALSE; // failed to create
}
SetDockingWindowIcons(theApp.m_bHiColorIcons);
return TRUE;
}
Could someone please help explain to me how to control the sides where
these windows dock?
Thanks.
IIRC, CBRS_TOP etc. are for where they can dock, not for where they are docked when you start the application. That is saved in the registry, basically it will show up where it was when the application was shut down the last time.
In the past (this was not with the Feature Pack docking framework) if you wanted to dock on startup to a specific side you had to set the side where you wanted the toolbar to be docked as the only one allowed (e.g. on the right), create the toolbar, dock it (there was a SetDocked() or something like that) and then modify the allowed dock sides to the directions you wanted to allow. I'm not sure if that behavior persists in the current version but I think it does, as that was something build on low level docking toolbar functionality which the feature pack stuff just builds on.
Not a real answer but hopefully it'll set you on your way...