|
Aha I've found the answer in GetTextMetrics . Taken from mny old "Inside Visual C++" for MFC2 - published in 1993
Joel Holdsworth
|
|
|
|
|
::DrawText(..., ...|DT_CALCRECT)
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Can any one clarify this:
What is the advantage of overwriting a copy constructor when C++, by default, providing one.
Thanks,
Prudhvi.
|
|
|
|
|
Copy Constructor is used to solve the problem of Shallow copy when using dynamic data( as in pointers ). as the default copy constructor does a member wise copy of data members , this operation is undesirable while using pointers as both the pointer members point to the same area in memory . This can have undesired effects . By implementing a copy constructor , one can allocate new memory and make sure that space allocated is different .
In the case where memory management isnt required the default COPY cONSTRUCTOR will suffice .
Engineering is the effort !
|
|
|
|
|
also, remember to always implement a destructor that frees the new memory so that any class that is copied won't cause memory leaks.
[insert witty comment here]
bdiamond
|
|
|
|
|
|
Hi, Can any one help
How to identify a DLL whether it is a normal DLL or its a COM DLL, if no documentation is provided.
Thanks,
Prudhvi
|
|
|
|
|
Open the DLL inside the Dependency Walker utility (this utility ships with Visual C++ 6.0. If you don't have the utility it can be downloaded from http://www.dependencywalker.com/[^]). If the DLL in question is a COM server, the DLL will export the following functions:
DllCanUnloadNow
DllGetClassObject
DllRegisterServer
DllUnregisterServer
If these exported functions are not listed, then chances are it's not a COM server.
Hope this helps
-John
|
|
|
|
|
I m working on an MFC based MDI application . My view is of type CFormView and I currently have a CTreeCtrl as a component on the Form .
What I want to know is that when the app is executed a default document is opened , but is not sized proportional to the size of the mainframe . Same is the case for all new Documents opened . What is the right way of resizing the view ? Does the view do it based on the parent CFrameWnd or does the mainFrame handle this ?
Right now Im doing this in the View class to resize the view based on the MainWindow
void CMyView::OnSize(UINT nType, int cx, int cy) <br />
{<br />
if(init){ <br />
CRect r;<br />
this->GetParentFrame()->GetParent()->GetClientRect(&r);<br />
this->GetParentFrame()->MoveWindow(r);<br />
this->GetParentFrame()->GetClientRect(&r);<br />
m_tree.SetWindowPos(0,r.left+5,r.top+5,r.Width()/3-10,r.Height()-10,0);<br />
return ;<br />
} <br />
CFormView::OnSize(nType, cx, cy);<br />
}
void CMyView::OnInitialUpdate()<br />
{<br />
CFormView::OnInitialUpdate();<br />
<br />
init = true ; <br />
<br />
<br />
<br />
ResizeParentToFit();<br />
<br />
<br />
}
and this in the MainFrame :
void CMainFrame::OnSize(UINT nType, int cx, int cy) <br />
{<br />
CMDIFrameWnd::OnSize(nType, cx, cy);<br />
<br />
CRect r;<br />
this->GetClientRect(&r);<br />
CFrameWnd *wnd;<br />
wnd =this->GetActiveFrame();<br />
if(wnd){<br />
wnd->MoveWindow(r);<br />
}<br />
<br />
}
so that the view is resized when the mainFrame is moved .
I get a feeling there might be a better way to do this .
|
|
|
|
|
You're along the right lines, although I think all you need to do is go:
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CRect clientrect;
GetClientRect(&clientrect);
m_Tree.MoveWindow(clientrect);
}
CFormView::OnSize(nType, cx, cy);
} You might want to overide OnEraseBkgrn and OnPain to reduce flicker.
However, I think you may be able to have an altogether better method by embedding the tree control directly as a control view using a CCtrlView , or even better: by using a CTreeView that way all the work is done for you!
Joel Holdsworth
|
|
|
|
|
I'm on my way out the door right now, so I didn't have a lot of chance to look at your code, but my CMainFrame wasn't getting sized correctly, so I send FALSE in ResizeParentToFit() to make sure the frame always accomodates my formview. Otherwise this call really doesn't do anything for formviews. Sending FALSE makes sure that the frame will always accommodate the form view's size.
[insert witty comment here]
bdiamond
|
|
|
|
|
We are in the proscess of designing a new multi platform game and require programers if you are interested please email Staff@kingszone.com
|
|
|
|
|
|
Does anyone know of any macros or other technics which would make it easier to debug BSTR and SAFEARRAY. Both are combersome structures to deal with and "dumping" their contents either dynamically via a debug macro of somekind or statically so that you could view them in debugger watch window.
|
|
|
|
|
The question states.
Write the following code and discuss what exactly results.
enum logical { no, maybe, yes };
I get the enum part, no = 0, maybe = 1 and yes = 2. But what is the 'logical' part? A logical |, or perhaps a logical &
Thanks for a push in the right direction.
|
|
|
|
|
McGahanFL wrote:
But what is the 'logical' part?
It's the name of the set (i.e., type).
As an added bonus, how would your answer change, if at all, if I were to change the statement to:
enum logical { no, maybe = 3, yes };
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Are you saying I can replace the word 'logical' with types like int or CString? I don't think that is what you mean.
bonus question no = 0, maybe =3, yes = 4
-------------------------
logical operator &&(logical a, logical b);
thansk
|
|
|
|
|
McGahanFL wrote:
Are you saying I can replace the word 'logical' with types like int or CString?
No, not at all. The word following the enum keyword is the name of your new type, like animal, position, or vehicle.
McGahanFL wrote:
bonus question no = 0, maybe =3, yes = 4
Very good. You have a firm grasp on the subject.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
OK, thanks. Let me work with that for a while.
|
|
|
|
|
my situation :
In my application i have to start another exe. In that other application the user has to make a choice and has to press the button ok or cancel. Now what i want is to receive the choice of the user in my calling app.
Application 1 --> starts up Application 2
In App2 the user choses ok or cancel
Is there a way to return the value from the choice to my App1 ??
|
|
|
|
|
Timothy1982 wrote:
Is there a way to return the value from the choice to my App1 ??
Have a look at GetExitCodeProcess() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
thx for the help ;)
|
|
|
|
|
if it's a dialog app, shouldn't it be:
if(dlg.DoModal == IDOK)<br />
else<br />
[insert witty comment here]
bdiamond
|
|
|
|
|
When I make a main window fullscreened, the taskbar sometimes won't hide itself under my window. It does that arbitrarily it seems.
I'm doing this right now:
ModifyStyle(WS_OVERLAPPEDWINDOW, 0);
ShowWindow(SW_MAXIMIZE); Is there a better way to make a window fullscreened?
--
Arigato gozaimashita!
|
|
|
|
|
I have seen similar problems with XP. Try Start->Run->Accessabilty Wizard. Just hit next on all questions. Restart you program. Is the problem still there?
|
|
|
|