|
I tried creating a child dialog that shared the DC with it's parent: no luck. MFC just doesn't support this behaviour.
Best approach would be to derive your own CMDIChildWnd, which uses a CFormView instead of a CView. The MDI child window worries about the fact that the window can't leave the parent's zone, and the CFormView can be used to display standard dialog controls from a dialog template resource.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
One way would be to override the dialog's OnMoving() method, like:
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
GetWindowRect(m_rectOrig);
return TRUE;
}
void CMyDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
CRect rect;
((CFrameWnd *) AfxGetMainWnd())->GetActiveView()->GetWindowRect(rect);
GetParent()->GetWindowRect(rect);
pRect->left = max(rect.left, pRect->left);
pRect->left = min(pRect->left, rect.right - m_rectOrig.Width());
pRect->right = pRect->left + m_rectOrig.Width();
pRect->top = max(rect.top, pRect->top);
pRect->top = min(pRect->top, rect.bottom - m_rectOrig.Height());
pRect->bottom = pRect->top + m_rectOrig.Height();
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello,
I don't now what im doing wrong but it don't want to work for me is there anyone that can help me...
This is how i have done it.
HKEY hKey;
LONG lResult = ERROR_SUCCESS;
DWORD dwType;
int str=1;
lResult = RegCreateKey(HKEY_LOCAL_MACHINE,
USER_SETTINGS_KEY, &hKey);
dwType = REG_DWORD;
lResult = RegSetValueEx( hKey, "Test", NULL, dwType,(unsigned char*) str, NULL );
RegCloseKey( hKey );
When I run the app I get a wrong DWORD value!...
What can I do?
Please help me...
|
|
|
|
|
RegSetValueEx takes the address of the value data, not the data itself. Change it to:
lResult = RegSetValueEx( hKey, "Test", NULL, dwType,(unsigned char*) &str, NULL );
(note the & before the str ), and all should be well.
|
|
|
|
|
lResult = RegSetValueEx( hKey, "Test", NULL, dwType,(unsigned char*) &str, sizeof(DWORD));
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
Is it possible to setup a text output area at the bottom of a dialog.
I was looking at the ToolTip for information, but dont know whats its called.
What I am after is the line of text displayed at the botton of the Window, giving the user feedback on current activities.
Is it available for MFC based applications and how is it managed.
Or is it best to allocate a textbox (read only) and manage it yourself.
I was just wondering if a facility (more powerful than your own textbox) is already present.
|
|
|
|
|
look for a Status Bar ? have a look at CStatusBarCtrl
or simply put a "sunken" static text at the bottom of your dialog.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
Thanks, will try it over the weekend.
Sweep.
|
|
|
|
|
Can anyone explain to me how to use struct variables w/ STL? I generated a struct variable and need to use it in a vector template. Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
Shouldn't be a problem mate, unless you have hidden the default contructor or overloaded operator &.
<br />
<br />
struct thing<br />
{<br />
int i;<br />
};<br />
<br />
vector<thing> stuff;<br />
<br />
<br />
Ryan
|
|
|
|
|
Hi,
I've got wierd problem with my back buffer. For some reason 1 time out of every 20 I BitBlt a buffer into the forground it will show corruption - bits of the image are shown in the wrong place. I don't have a GDI leak, but the error is still occuring.
So I create the buffer by this function which is called early:
void CJackVisualCtrl::RebuildBackBuffer()
{
CRect clientrect;
GetClientRect(&clientrect);
CClientDC dc(this);
m_BackBitmap.CreateCompatibleBitmap(&dc, clientrect.Width(), clientrect.Height());
} I then use this in a paint routine:
void CMyClass::Paint(CDC *dc)
{
......
if(m_BackBitmap.m_hObject == 0)
RebuildBackBuffer();
CDC backdc;
backdc.CreateCompatibleDC(dc);
CBitmap *oldbitmap = backdc.SelectObject(&m_BackBitmap);
dc->BitBlt(0, 0, contentrect.Width(), contentrect.Height(), &backdc, 0, 0, SRCCOPY);
backdc.SelectObject(oldbitmap);
backdc.DeleteDC();
}
The image is quite large - 800x600 pixels, and it's rendered quite regularly - 10fps; but it surprises me that this is a problem for a modern PC. Can anyone see anything wrong with my technique?
Joel Holdsworth
|
|
|
|
|
While this does not directly answer your question, I wrote an tool a while back that I use when I get weird things happening with memory DC's and/or memory bitmaps. Simply place a ShowDC() call after every drawing operation that you do, and the problems show up in no time.
http://www.codeproject.com/tools/imageviewer.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I still think it's a nifty util btw.
Jeremy Falcon
|
|
|
|
|
thx
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I have a question to all you guys,
am working on a Mfc Dialog application.The aim is to display properties of 4 different objects.
Decided to use a Tab Control,so that each tab identifying the properties to display for a object(so 4 tabs for 4 Objects.)
So Now My questions are starting
In Each Tab as I said ,want to fill the properties of a partcular object in a control.
In the control,I need to have 2 header columns.
The First column contains always constant labels.
In the second column,Depending on the left label,need to add a combobox,checkbox,Ediable Text box etc...
[1]I decided to use the ListView Control.How Can I add controls to the listview control,for each item
[2] How to change the background colour of the caption label in a CDialog object.
[3] How to change the font & Tab background colour of a particular tab in a TabControl
Appreciate it if someone could tell which concrete member function to use,showing with a code snippet.
Thanks..
|
|
|
|
|
Maybe use Chris Maunders MFC Grid Control (available from CodeProject), one instance in each of your tabs.
It already does all this work for you.
Otherwise, look at what it does, as a starting point for the work you are about to duplicate.
|
|
|
|
|
Have already progressed with the ClistCtrl from Mfc & Now I need to add combo boxes ,test boxes etc to the second coulmn od the list control.
How can I achieve that..
Can I use the "SetItemData" Function or should I use any other variation...
|
|
|
|
|
What is typically done is a data set is tracked for each element in the list.
This data set can be a data structure, pointer to a class, whatever you want. It retains the user's item selection and generally what you would want to use in that cell, like some flag for combo box, list box, edit field, etc.
When the user 'selects' one of the cells, you create a window, on the fly, that covers the cell of interest. The focus is set to that window (the combo box, list box, or whatever) and the user makes a selection from it.
You then remove the small control window, then 'draw' in the selction into the item - if it is all text you want, that makes it easier, but some grids have bitmaps or other items, like progress bars and such - custom drawing stuff.
It is impractical to keep a separate window for every possible cell in a grid, so you only have a 'floating' child control for the cell currently being edited. Some people try to assign and create a seaprate control window for each cell int he grid, this limits how many rows and columns they can handle, as they lose ability to create even more windows.
Other than that, like I said, you are sort of duplicating the MFC grid control's efforts, so you might look to it for some examples.
|
|
|
|
|
Where can I find this Chris Maunders MFC Grid Control.
Could u provide a link.
In my Mfc control list,I can't see a Grid Control ...
What should I do...
|
|
|
|
|
It is available on this very same website.
http://www.codeproject.com/miscctrl/gridctrl.asp
|
|
|
|
|
|
How can I find out the extension of the file pointed to by a shortcut? IShellLink::Resolve can do that, but it has a lot of overhead.
Basically, I'm going through the contents of a directory and only showing files of certain types, but I also want to show shortcuts which point to files of those certain types.
|
|
|
|
|
Nevermind, figured it out: I use the normal COM code to find a shortcut's target, and just omit IShellLink::Resolve .
|
|
|
|
|