|
Sorry, I'm new in MFC...
I know that I can access CMyAppDoc within CMyAppView using GetDocument() function in a SDI Application. How can I do the inverse? that's access CMyAppView within CMyAppDoc?
Thank you masters!
|
|
|
|
|
I think the idea is that you don't need to. For instance if you are viewing a split document e.g. page 1 and page 7, when you ask for the view which one do you want?
You are meant to update the data your document contains e.g. a text or drawing then from the document call UpdateAllViews to have the view (or views) redraw/paint your document so you see the changes.
Also if the View knows about the document and the document the view it can get complicated with circular references.
|
|
|
|
|
You can use CDocument::GetFirstViewPosition and CDocument::GetNextView to iterate through all the views that are attached to a document.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
See CView Access From Anywhere[^] and questions on the bottom of page.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I would also point you at UpdateAllViews member function of the CDocument class.
As has been said, the whole point is that CDocument has no clue whatsoever about the views. This lets you replace / add different views, and only change one area of your code.
This is a GoodThing(tm).
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I have upgraded a project written in VC++ 7.1 version using the .net 2005 wizard. After fixing few code related issues, I have got the following errors while building
error LNK2001: unresolved external symbol DllCanUnloadNow
error LNK2001: unresolved external symbol DllGetClassObject
I have declared this in the .def file as
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
I would really appreciate for showing me the right way to resolve this please. Thanks in advance.
SoftwareDeveloper(.NET)
|
|
|
|
|
did you switch a dll from being a com DLL to a managed DLL?
a programmer traped in a thugs body
|
|
|
|
|
Few libraries actually was written in vc 6 and using those with that..but it has been upgraded to vc 7 ..
Thanks
SoftwareDeveloper(.NET)
|
|
|
|
|
Finaly I could resolve the issue. I have done the following steps to resolve the issue.
1) Have set "Multi-Threaded Debug(/MTD" in all the projects under workspace. this thing was correct already but mentioning here for future reference.
2) In the Resources-->Preprocessor Definitions , I have set "_DEBUG,_MT,DLL". I believe this part , corrected the issue. previously it was having only "_DEBUG".
Thanks,..
SoftwareDeveloper(.NET)
|
|
|
|
|
Hello,
I am using dialog boxes and I need to capture window message when the window/dialog was displayed
I tried WM_SHOWWINDOW but the help says:
WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown.
I can not fint the proper message.Can you give me a hind?
Thank you very much.
|
|
|
|
|
daavena wrote: displayed
What do you mean by 'displayed' - created, shown, redrawn?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
when I click on the button I need:
show window/dialog with message "Loading profile it can take several minutes" inside
and than when the window is shown(is visible) I need to run the function - but only once.
|
|
|
|
|
There's no window message that you only get when the window is shown the first time.
Instead, catch WM_SHOWWINDOW. Maintain a flag that tells you if your message has been shown. You can use this flag to tell you whether you should show your message or not - something like:
void CMyWindow::OnShowWindow(BOOL bShow, UINT nStatus)
{
if (bShow && !m_bShownMyMessage)
{
m_bShownMyMessage = TRUE;
}
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thaks for reply,
WM_SHOWWINDOW
WPARAM wParam
LPARAM lParam;
Parameters
wParam
Specifies whether a window is being shown. If wParam is TRUE, the window is being shown. If wParam is FALSE, the window is being hidden.
lParam is still 0
when I capture WM_SHOWWINDOW so wParam is always 1 -the window is being shown.
My function always runs first. Then I see the window.
This function takes a time - 10sec, that is reason why I need to see the window first.
WM_SHOWWINDOW message is called only once. I think it is not possible to do that.
|
|
|
|
|
WM_WINDOWPOSCHANGING?
Or you could even could WM_PAINT - that was when the window was actually shown to people!
So it depends on what you mean...
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Thanks for reply.
I need message when window/dialog has been shown - I need to see the window first and then run my function(only once).
|
|
|
|
|
Please consider the following code fragment written using C++ and MFC.
void<br />
GraphWindow::OnPaint()<br />
{<br />
CPaintDC dc(this);<br />
dc.TextOut( 50, 50, TEXT("A Parabola"), 11 );<br />
<br />
dc.SetWindowOrg( -cx/2, -cy/2 );<br />
<br />
CPen pen(PS_SOLID, 2, RGB(255, 0, 0) );<br />
CPen *pOldPen = dc.SelectObject( &pen );<br />
<br />
dc.MoveTo( -10, 100 );<br />
for( int i = -10; i<=10; i++ )<br />
dc.LineTo( i, (i*i) );<br />
<br />
dc.SelectObject( pOldPen );<br />
}<br />
This routine is suppose to graph the curve y = x^2. However, it graphs the function y = -x^2 because the windows orientation is that an increasing y value, moves down in the window. If I change the call to LineTo to the following, it works:
dc.LineTo( i, -(i*i) );
I believe that there is a call that will change the window orientation such that an increasing y value moves up rather than down. However, I have been unable to find the call. I am hoping that somebody can tell me what it is.
Thanks
Bob
|
|
|
|
|
|
Iain,
Thanks for the response. Based the article you sited, I tried the following piece of code:
<br />
void<br />
GraphWindow::OnPaint()<br />
{<br />
CPaintDC dc(this);<br />
<br />
dc.TextOut( 50, 50, TEXT("A Parabola"), 10 );<br />
<br />
dc.SetMapMode( MM_HIENGLISH );<br />
<br />
CPen pen(PS_SOLID, 2, RGB(0, 255, 0) );<br />
CPen *pOldPen = dc.SelectObject( &pen );<br />
<br />
dc.MoveTo( 100, 100 );<br />
dc.LineTo( 800, 800 );<br />
<br />
dc.SelectObject( pOldPen );<br />
I called the method SetMapMode to orient the window such that positive x values are to the right and positive y values are up. With the call to SetMapMode in there, the line does not appear. Without the call to SetMapMode, the line does appear. I do understand and I am hoping that somebody can explain it to me.
Thanks
Bob
|
|
|
|
|
You need to play with the article more...
But at a first guess - you've changed the map mode, and I think to a "Y is up" mode. But you've not changed the origin. So you're not drawing 50,50 above and to the right of the top left of the window - so nothing to see.
But the article has all sorts of things to vary, so you can experiment with this there.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
hi,
I want to trap a events whenever user selects cell in excel sheet 2007. Can I do it by subclassing it. If yes how to do it.
Thanks
SNI
|
|
|
|
|
You need a different mechanism than to subclass to catch Windows messages.
Instead, you need to tell the relevant worksheet that you want to connect to its SelectionChange[^] event.
This CodeProject article[^] has information on COM connection points (that's what you need to use to catch the event).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
Thanks for your reply. But will it be same for Exccel 2007.
Thanks
SNI
|
|
|
|
|
Yes[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for your reply. I was able to capture events like WorkbookOpen,WorkbookActivate,SheetSelectionChange but my requirement is something different. Let assume that one excel file is open (Test.xlsx) and I have selected a cell and press F2 so that my cursor is inside a cell. Now I have opened this xlsx file so I know the name of it. but if I change the focus from this xlsx file to test.doc and again come back to Test.xlsx, I am not able to get the name of this file since the cursor is blinking inside the cell.
Here I want to capture this event either Active cell, which is not working nor all of the above mentioned events. How to capture this curosr blinking event inside the cell (EditDirectlyInCell).
Does Subclassing of Excel will help?
Thanks
SNI
|
|
|
|