How to make WS_THICKFRAME invisible, but still functional in MFC? - c++

So, I created a dialog that has a style: WS_THICKFRAME.
This WS_THICKFRAME gives the dialog box the functionality to resize the window, but my problems is that I don't won't a border around my window to be visible. How would I make the border invisible, but still have the re-size capability?
An example would be most helpful! Thanks!
Below, are the styles of the template for the dialog box I created:
IDD_GADGETTRANSLUCENTDIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_ABSALIGN | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_SYSMENU | WS_THICKFRAME

Remove WS_THICKFRAME
Handle WM_NCHITTEST roughly as follows:
UINT CMyClass::OnNcHitTest(CPoint point)
{
CRect rWindow;
GetWindowRect(rWindow);
CRect rInner(rWindow);
rInner.DeflateRect(GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
if (rWindow.PtInRect(point) && !rInner.PtInRect(point))
{
// figure out which of the following codes to return: //
// HTBOTTOM, HTTOP, HTLEFT, HTRIGHT //
// HTBOTTOMLEFT, HTBOTTOMRIGHT, HTTOPLEFT, HTTOPRIGHT //
}
else
{
return CMyBaseClass::OnNcHitTest(point);
}
}

Related

How to create a window that behaves like taskbar?

I want to ask how to create a window that behaves like taskbar (shell_traywnd)?
In a windows app called Enable Viacam (camera mouse for disabled people) I saw that the app creates a taskbar-like window on the top of the screen (see the image below) which pulls all other windows underneath it.
Enable_Viacam's window (top of screen)
I used Winspector software to examine this Enable Viacam's window to see its WS_/WS_EX_ properties so that I would try emulate it, but calling CreateWindowEx with those properties didn't give me the wanted result..
Here's my attempt (message loop & window procedure not shown here)
hwnd = CreateWindowEx(
WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_CONTROLPARENT,
"#32770","Window",
WS_OVERLAPPEDWINDOW | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_BORDER | DS_3DLOOK,
0, /* x */
0, /* y */
GetSystemMetrics(SM_CXSCREEN), /* width */
50, /* height */
NULL,NULL,hInstance,NULL);
Any ideas greatly appreciated,
thank you!
Apparently this window type is called an appbar
I created window with style WS_EX_TOOLWINDOW and WS_POPUP and followed that MSDN link
My code now is
APPBARDATA abd = {0};
abd.cbSize = sizeof(APPBARDATA);
abd.hWnd = hwnd;
abd.uCallbackMessage = 888;
SHAppBarMessage(ABM_NEW, &abd);
abd.uEdge = ABE_TOP;
abd.rc.left = 0;
abd.rc.right = GetSystemMetrics(SM_CXSCREEN);
abd.rc.top = 0;
abd.rc.bottom = height;
SHAppBarMessage(ABM_QUERYPOS, &abd);
abd.rc.bottom = abd.rc.top + height;
SHAppBarMessage(ABM_SETPOS, &abd);
Have fun coding guys

Need to Make CDockablePane Background Transparent in c++ MFC

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;
}

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 ?

How to Hide a Title Bar in a CDockablePane?

I want to hide a title bar in CDockablePane. I tried calling ModifyStyle(), but it doesn't work.
ModifyStyle(WS_SYSMENU, 0, SWP_FRAMECHANGED);
Don't use the style WS_CAPTION when you create the pane!
you need to call dockablepane's EnableGripper(FALSE) to hide the pane's caption in docking state. Remember to call it when creating tabbedpane as well.
The function CDockablePane::Create() has a parameter called BOOL bHasGripper which is usually set to TRUE while in your case you can set it to FALSE, like below.
class COutputWnd : public CDockablePane {};
COutputWnd m_wndOutput;
if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), FALSE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{
return FALSE; // failed to create
}

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...