In my MFC program I am using a splitter to create two panes. I now want to split one of these panes in half again and put in another view, can someone talk me through how to do it or point me in the direction of some code?
I would prefer to code it myself so I am not interested in custom derived classes unless they are extremely basic.
Thanks!
In CMainFrame::OnCreateClient
// Create splitter with 2 rows and 1 col
m_wndSplitter.CreateStatic(this, 2, 1);
// Create a view in the top row
m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CView1), CSize(100, 100), pContext);
// Create a 2 column splitter that will go in the bottom row of the first
m_wndSplitter2.CreateStatic(&m_wndSplitter, 1, 2, WS_CHILD|WS_VISIBLE, m_wndSplitter.IdFromRowCol(1, 0));
// Create views for the bottom splitter
m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CView2), CSize(100, 100), pContext);
m_wndSplitter2.CreateView(0, 1, RUNTIME_CLASS(CView3), CSize(100, 100), pContext);
...
I am not an expert in MFC, but can't you just put a splitter in one of the panes you made with the first splitter ? that how we do in winform....
Related
I'm trying to align some controls in my wxPython app to bottom of a panel. Here's sample of my code:
def __DoLayout(self):
vsizer = wx.BoxSizer(wx.VERTICAL)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
hsizer.Add(self.prog, 0, wx.ALL|wx.EXPAND, 5)
hsizer2.Add(self.text, 0, wx.ALL|wx.EXPAND, 5)
#hsizer.Add(self.timer, 0, wx.EXPAND|wx.ALIGN_RIGHT)
vsizer.Add(hsizer2, 0, wx.EXPAND)
vsizer.Add(hsizer, 0, wx.ALIGN_BOTTOM|wx.EXPAND)
self.SetSizer(vsizer)
I would like the bottom horizontal sizer (hsizer) to stretch to bottom, or the top one to stretch placing bottom sizer on the bottom (that would actually be better).
[EDIT: Proposed sulution description]
The proportion parameter defines the ratio of how will the widgets change in the defined orientation. Let's assume we have three buttons with the proportions 0, 1, and 2. They are added into a horizontal wx.BoxSizer. Button with proportion 0 will not change at all. Button with proportion 2 will change twice more than the one with proportion 1 in the horizontal dimension.
From zetcode
Solution proposed by Renae Lider
With reluctance, but as #renae-lider who answered the question has not posted an answer.
Change the 0 to 1 in this line :
vsizer.Add(hsizer2, 1, wx.EXPAND)
This is the proportion parameter.
The proportion parameter defines the ratio of how will the widgets change in the defined orientation.
Let's assume we have three buttons with the proportions 0, 1, and 2. They are added into a horizontal wx.BoxSizer. Button with proportion 0 will not change at all. Button with proportion 2 will change twice more than the one with proportion 1 in the horizontal dimension.
I have three widgets under my main window . I design my program that each widget will be controlled by a class .
Last 2 hours I waste my time to fit 3 GUI elements to one of this widgets.
I want to have a label and a line item and a button. I put them in to a grid layout(in real case I have 3 row for simplicity I put 1 row in the example below). And set the grid layout's parent to my class.
What I expect is this GUI items to resize themselves and fit to one row in this widget, no matter what I tried I couldn't succeed .
In short I expect this items to shrink to fit to the widget by themselves. But couldn't figure out how to do it. Any advice ?
void
enviromentSetup::createDialogs()
{
numberOfPoints = new QLabel (QApplication::translate("leftPanel","numberOfPoints"));
inputNumberOfPoints = new
QLineEdit(QString::number(st_environmentParamaters.number_of_points_in_line));
maxElementsButton = new QPushButton("Max Elems");
gridLayout = new QGridLayout(this);
gridLayout->addWidget(numberOfPoints, 0, 0);
gridLayout->addWidget(inputNumberOfPoints, 0, 1);
gridLayout->addWidget(maxElementsButton, 0, 2);
this->show();
}
It is insufficient to merely make the parent of the layout the main widget. You also have to explicitly set the layout of the widget.
Add the following line just before you show the widget:
this->setLayout(gridLayout);
I am trying to make a Menu that contains 13 MenuItemImages in two columns (the last one is in the middle).
The frame width/ design resolution width is 480 pixels. MenuItemImage width is 180 pixels.
here is my code :
CCMenu* testMenu = CCMenu::createWithArray(testMenuItems);
testMenu->alignItemsInColumns(2,2,2,2,2,2,1);
CCSize size1 = CCDirector::sharedDirector()->getWinSize();
testMenu->setPosition(ccp(size1.width / 2, size1.height/2));
but the two columns are slightly overlapping. (the right one is above the left one)
here is the result of my code:
I would like it to be properly spaced with some padding between the two columns.
Please help me out I am new to Cocos2d-x.
the alignItemsInColumns will align menu itens based on itens center, against menu width.
In your case, you have 2 options:
1) Increase your menu width (by default, their size will be based on screen size. Change the menu.contentSize.width)
2) Change the anchor point of left itens to ccp(.7,.5) and right itens to ccp(.3,.5) for example
I'm trying to create a dialog in MFC that contains a CListCtrl to display a list of items with associated images. However, the images are being displayed as blank white squares. They are there, or at least, there is a space where they should be.
I am trying to load the bitmap from a file (although I have also tried loading from a resource ID which has the same effect) and I am storing it in a CImageList. This image list is then given to the CListCtrl. I'm fairly certain that the bitmap is being correctly loaded as I have managed to load the same bitmap successfully elsewhere in my project using the same code.
I'm not sure whether this is important, but this is part of a context menu shell extension and the dialog is raised when the user clicks on one of the items in the explorer context menu. Also, I'm relatively new to MFC so apologies if I've just missed something really obvious.
The following is my code for initialising the CListCtrl in report view with two columns and one item which should have the image in the first column and some text in the second:
// Get reference to list control
CListCtrl m_list_control = (CListCtrl*)GetDlgItem(IDC_LISTCONTROL);
// Create image list
CImageList image_list;
image_list.Create(32, 32, ILC_COLOR4, 0, 3);
HANDLE hBitMap = ::LoadImage(0, L"E:\pathtomybitmap\bitmap1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
CBitmap bitmap;
bitmap.Attach((HBITMAP)hBitMap);
image_list.Add(&bitmap, RGB(255, 0, 255));
// Add the image list to the list control
// (LVSIL_NORMAL didn't seem to show anything at all)
m_list_control->SetImageList(&image_list, LVSIL_SMALL);
// Add columns
LVCOLUMN column;
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_IMAGE;
column.fmt = LVCFMT_LEFT | LVCFMT_IMAGE;
column.cx = 100;
column.pszText = (LPWSTR)&L"Image";
column.iImage = 0;
m_list_control->InsertColumn(0, &column);
m_list_control->InsertColumn(1, _T("Text"), LVCFMT_LEFT, 100);
int index = m_list_control->InsertItem(0, _T(""), 0);
m_list_control->SetItemText(0, 1, _T("My text"));
Any idea what I'm doing wrong?
Try changing create statement so that the size you put is smaller than the image size
image_list.Create(31, 31, ILC_COLOR4, 0, 3);
Try setting the mask argument of insert item to:
InsertItem(LVIF_TEXT | LVIF_IMAGE,...
I have a fixed size panel (derived from wxPanel) on which i blit images / draw geometric shapes. This is present in a frame (derived from wxFrame).
Now i want the panel (appinterface) to be centered inside the frame whenever the frame is maximized/resized. Also the empty space in all four directions should have a tiled background (seamless).
I can center using sizers, horizontal & vertical boxsizers, but how do i fill empty space.
This is my code which only centers the panel horizontally currently.
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
appInterface = new Interface((wxFrame *)this, kFrameWidth - 20, kFrameHeight - 110);
sizer->Add(1, 1, 1, wxEXPAND);
sizer->Add(appInterface, 1, wxEXPAND | wxALIGN_CENTER);
sizer->Add(1, 1, 1, wxEXPAND);
SetSizer(sizer);
SetAutoLayout(true);
I guess i can't add background to frame and i can't add a panel inside panel, because if it were possible, then it would be easy to solve my problem.
NOTE:Things inside appinterface are drawn using absolute coordinates, so it wouldn't be easy to simply draw in center.