How to create a frame less Dialog box? - visual-c++

My goal is to create a frame-less dialog box using MFC, which are plain rectangle like shown in the image,i have basic knowledge of MFC applications.and dialog box,can you please provide some links for the same.

Copy this code
//Oninitdialog()
LONG lStyle = GetWindowLong(m_hWnd, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
SetWindowLong(m_hWnd, GWL_STYLE, lStyle);
Second way
Select you Dialog->properties->Border->None

Related

how can i copy text from the copy menu from a text control?

I get static text control on a dialog, and there is a copy menu when right-click.
when I copy the selected text, nothing can be pasted. Someone said static text control has no copy function, I replace static text control with a edit control, which has copy default, but still copy nothing to paste. What's the problem for that?
There is the edit control below.
IDD_WZD_ADD_EVENTS DIALOGEX 0, 0, 342, 189
STYLE DS_SETFONT | WS_CHILD | WS_BORDER
FONT 8, "MS Shell Dlg 2", 0, 0, 0x1
BEGIN
LTEXT "&Add events to the list in order of their appearance.",IDC_STATIC,21,1,165,8
LTEXT "How do I add events from Event Viewer?",IDC_EVENT_VIEWER_LINK_HELP,189,1,132,8
LTEXT "&Events: ",IDC_STATIC,21,12,163,8
CONTROL "List1",IDC_LST_EVENTS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,21,21,278,62
PUSHBUTTON "",IDC_BTN_UP_EVENT,304,21,17,16,BS_ICON
PUSHBUTTON "",IDC_BTN_DOWN_EVENT,304,41,17,16,BS_ICON
PUSHBUTTON "A&dd",IDC_BTN_ADD_EVENT,21,87,50,14
PUSHBUTTON "Re&move",IDC_BTN_REMOVE_EVENT,75,87,49,14
PUSHBUTTON "Edi&t...",IDC_BTN_EDIT_EVENT,128,87,50,14
CONTROL "Any &order",IDC_CHK_ANY_ORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,226,90,73,10
LTEXT "&Rule description:",IDC_STATIC,21,106,300,8
EDITTEXT IDC_STEP_DESCRIPTION,21,114,300,74,ES_AUTOHSCROLL
END

Adding Minimize box to MFC Property Sheet system menu

How could I Add Minimize and Maximize box to the system menu of CMFCPropertySheet.
I have tried modifying the style by
CMFCPropertySheet::ModifyStyle(NULL, WS_SYSMENU);
but nothing happened.
Assuming you have a class derived from CPropertySheet, let's call it MySheet:
// Capture the WM_NCREATE message
BEGIN_MESSAGE_MAP(CMySheet, CPropertySheet)
ON_WM_NCCREATE()
END_MESSAGE_MAP()
BOOL CMySheet::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!CPropertySheet::OnNcCreate(lpCreateStruct))
return FALSE;
// Modify the window style
LONG dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | WS_WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
return TRUE;
}
Note that you could do this in the OnInitDialog, but even though the Minimize/Maximize boxes will show, they won't do anything.
doing just this in the "OnInitDialog:" worked for me.
LONG dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | WS_WS_MINIMIZEBOX | WS_MAXIMIZEBOX);

CEdit in CDockablePane won't scroll

Im using W7, VS2010: create an MDI app with the visual studio look so it has a COutputWnd inherited from CDockablePane at the bottom. Copying the default I've made a new tab, but inherited from CEdit. The tabs inherited from CListBox work great with the following styles:
const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
But the CEdit with the following does not scroll vertically:
const DWORD dwStyle2 = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL;// | ES_READONLY;
I've tried all combinations of the above styles and read tons of websites, but nothing works :(
Oh - and I do have ShowWindow(SW_SHOW);
Thanks for any help you can offer.
Ta-da! Got it sorted. In COutputWnd::OnCreate I had used this as the parent window:
m_wndVehicle->Create(dwStyle2, rectDummy, this, 3);
It should have been &m_wndTabs:
m_wndVehicle->Create(dwStyle2, rectDummy, &m_wndTabs, 3);
Works a treat now!
Hope it saves someone else 2 hours!

uimenucontroller in uiwebview with custom menu items without MORE menu

In my iPad app, there is a UIWebview that displays text content. When I tap hold and select a text, a menu should popup with 2 custom menu.
say, | MENU1 | MENU2 |
But it seems the COPY menu will also accompany, which I couldn't disable. Is there any possibilities to disable it? I tried around the forum and no solutions worked out.
so itz okay to keep the COPY menu along with the other 2. which should now look like
| Copy | MENU1 | MENU2 |
But unfortunately, I 'm getting it displayed with a MORE menu as follows :
| Copy | More... |
Clicking the More... menu is showing the other 2 menu.
But I need all those 2 items to be displayed in the first attempt itself. either just the 2 menus alone, or atleast along with the copy menu.
| Copy | MENU1 | MENU2 |
OR
| MENU1 | MENU2 |
Get me some solution please.... Trying it out in many ways.. But nothing is working out...
Plz help me out...
Thanks,
Brian
It doesn't appear that there is a way to do this without replacing the UIMenuController. One option is to handle your own UILongPressGestureRecognizer (see How to remove th COPY UIMenuItem in UIMenuController). I've seen proposals where you override canPerformAction, but this does not work. Interestingly, the "copy:" action is never called, though it seems that everything else (cut:,select:,etc.) is.
- (BOOL) canPerformAction:(SEL)action withSender:(id)sender
{
if (action == #selector(defineSelection:))
{
return YES;
}
else if (action == #selector(translateSelection:))
{
return YES;
}
else if (action == #selector(copy:))
{
return NO;
}
return [super canPerformAction:action withSender:sender];
}
`

CSpinButtonCtrl drawing problem with small CEdit control

I'm trying to draw a CSpinButtonCtrl as a buddy of an edit box in Windows 7. When my CEdit window is 12 dialog units high, the spin buttons are scaled really badly and the top border is clipped off.
This looks pretty ugly. How can I get around this, or must I restrict my CEdit controls to be 14 dialog units high?
My controls are declared thusly:
EDITTEXT IDC_LOWER_EDIT,51,20,63,12,ES_MULTILINE | ES_WANTRETURN,WS_EX_RIGHT
CONTROL "",IDC_LOWER_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,104,17,11,12
I've tried resizing using MoveWindow, but that doesn't help. Any ideas?
I found the code for changing the width
CWnd* pWnd = GetDlgItem( IDC_SPIN1 );
CRect rect;
pWnd->GetWindowRect( &rect );
ScreenToClient( &rect );
rect.right += 5 ; // make 5 pixels wider
pWnd->MoveWindow(&rect) ;
Put it in the OnInitDialog().
I think I would go for #2 - are you that pressed for screen space?
Another option is: leave it unattached (remove UDS_ALIGNRIGHT) and place it right next to the edit control.

Resources