|
Hi
I m using CUsefulsplitterWnd Class for replacing views in my project.
My Problem is that the OnInitialUpdate Function is not been called in my project.
I m using Listcontrol in Rpelort Views.
I m tryin to set columns names in OnInitialUpdate Function...But the fn is not been invoked while executin
Can U help me out?
|
|
|
|
|
What version of MFC are you using? This sample code is 810 years old and I no longer use MFC that much and I suspect the framework has moved on a bit.
You may need to look at the source code and see how OnInitialUpdate is triggered normally and then see how to adapt the sample to work with the latest framework - it may be as simple as calling the method yourself after doing the replace view.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerryBizSquawk
|
|
|
|
|
Hi all,
i m using a worker therad its all working fine but when the statement for ReplaceView execute its crash and point out on
CSplitterWnd::GetPane(int row=0, int col=1) Line 346
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Since you haven't posted anything about the exception and I don't do MFC anymore I am going to have to suspect that it is probably because you can't talk from a worker thread to a UI thread directly.
In order to get you UI to update in reponse to events in the Worker Thread you will need to use PostMessage.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerryBizSquawk
|
|
|
|
|
UINT Test_Thread(LPVOID param);
UINT Test_Thread(LPVOID param)
{
CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();
for(int i=0;i<1000;i++)
{
}
pMainFrame->m_wndSplitter.ReplaceView(0,1,RUNTIME_CLASS(CTest),CSize(100,100));
Test.exe!CSplitterWnd::GetPane(int row=0, int col=1) Line 346 C++
return 0;
}
please now tell me wat can i do,its all working fine without thread.
please help me for this.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
It looks like you will have to use postmessage, as WorkerThreads should NOT interact with GUI objects, to do the final switch see http://www.flounder.com/workerthreads.htm[^] for more information (it is an old article but windows hasn't changed that much when it comes to the basics.)
What you should do is use PostMessage to send a message to your UI thread which will then do the ReplaceView call that you wish.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerryBizSquawk
|
|
|
|
|
i m using this code in my application for replace view,check this
http://www.codeproject.com/KB/splitter/usefulsplitter.aspx[^]
it is using for replace views.but after using of this code ,in replaced view the OnInitialUpdate function is not working.
i m also check this in this code same problem is there so please anyone can tell me how can remove this problem.
thanks in advance.
|
|
|
|
|
I am also facing the same problem , If anybody knows the answer can you post?
|
|
|
|
|
What version of MFC are you using? This sample code is 8 years old and I no longer use MFC that much and I suspect the framework has moved on a bit.
You may need to look at the source code and see how OnInitialUpdate is triggered normally and then see how to adapt the sample to work with the latest framework - it may be as simple as calling the method yourself after doing the replace view.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerrywww.many-monkeys.com
|
|
|
|
|
I am using CUsefulSplitterWnd with form views. My form view contains the CReportCtrl custom control here: http://www.codeproject.com/KB/list/ReportControl.aspx[^].
The trick for me was to overwrite the WM_CREATE message of the form view class
int CForm3::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFormView::OnCreate(lpCreateStruct) == -1)
return -1;
m_List.Create (this, 0, NULL, 0);
return 0;
}
and force the OnInitialUpdate call in the replaceable view class
void CSplittstView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
CString szText=GetListCtrl().GetItemText(pNMListView->iItem,pNMListView->iSubItem);
if (pNMListView->uNewState == 3)
{
CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();
if (szText==_T("Form3"))
{
pMainFrame->m_wndSplitter.ReplaceView(0,1,RUNTIME_CLASS(CForm3),CSize(0,0));
CForm3* pForm3 = dynamic_cast < CForm3* > (pMainFrame->m_wndSplitter.GetPane(0,1));
if (pForm3)
pForm3->OnInitialUpdate();
}
}
*pResult = 0;
}
Programming can be frustrating!
|
|
|
|
|
At UsefulSplitterWnd.cpp(line 103),
Add
#define WM_INITIALUPDATE 0x0364 // (params unused) - sent to children
pNewView->SendMessage(WM_INITIALUPDATE,0,0);
Before
if (bSetActive==TRUE)
GetParentFrame()->SetActiveView(pNewView);
[Chintse Wu]
|
|
|
|
|
WM_INITIALUPDATE - is that not already defined in a header file?
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerryBizSquawk
|
|
|
|
|
Sure, WM_INITIALUPDATE defined in AFXPRIV.H
I copy the symbol define for quickly...
[Chinte Wu]
|
|
|
|
|
Thanks, great solution.
Víctor Rodríguez Doncel
|
|
|
|
|
Can u tell me if i want to split windows in more part how can i do that
I want to split right hand side window into 3 parts
-- modified at 2:25 Friday 17th November, 2006
|
|
|
|
|
You will need to add 3 splitters.
splitter 1 will split the form into left and right views.
split the right view into a top and bottom view.
split the bottom view into left and right.
There is an MFC sample[^] that can be used as a basis
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerrywww.many-monkeys.com
|
|
|
|
|
Hi,
I am trying to replace the view in the EXE with a view that I obtain from a DLL. I am able to get the View from the DLL and cast it to CRunTimeClass and use it with ReplaceView. But, I am not able to see the View that I loaded from the DLL. I see only the Form 1. What could be the reason? Please help!
AJ
|
|
|
|
|
What sort of DLL was it? Did you put the Form in a proper MFC extension DLL?
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerrywww.many-monkeys.com
|
|
|
|
|
Hi all,
This is my first email to this site. I have developed an SDI application with Wizard type propertypages and it builds and runs without any errors. Now I want to store the data obtained from the Wizard pages into some database object and display it in a list control on the formview. So I want to introduce 3 vertical panes into my main view class provided by the framework, which I know how to do and I am aware of the procedure of assigning various views to the different panes. What I want to know is how to dynamically change the views in the middle view say 1,2,3 using a treectrl(Left pane which is fixed) or mainmenu command? The RHS view is CRichEditView and that too is fixed. So if I want to use DAO database where shall I declare the objects and variables then? Obviously I can post that question to the database forums, but since it is related I am asking it here. I just need the appropriate space where I should declare and define them. I also understand that using a split view, it is better to use CMainFrame class to handle the messages or menu commands. Also, are there any changes to be made to the relevant view classes after adding the split window? That is all I need right now......
Thank you all in advance.....
Regards
Bhushan.
|
|
|
|
|
Hi Bhushan
You post is more relevent to the MFC forums, however.
Bhushan1980 wrote: What I want to know is how to dynamically change the views in the middle view say 1,2,3 using a treectrl(Left pane which is fixed) or mainmenu command?
If you are using this class for you splitter window then you could use the ReplaceView method.
Bhushan1980 wrote: So if I want to use DAO database where shall I declare the objects and variables then?
The document class is usually the place for this sort of the stuff or mainframe (disclaimer: though it has now been 4 years since I did any MFC and so things may have changed with the latest frameworks.)
Bhushan1980 wrote: Also, are there any changes to be made to the relevant view classes after adding the split window?
I've never had to in the past.
I hope this helps - sorry can't be more help but as I said I don't get chance to do MFC anymore.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerrywww.many-monkeys.com
|
|
|
|
|
I want to create a view in the CUsefulsplistWnd.But now the Class FormView_in_dll is in a dll.
I've tried to get a CRuntimeClass from the Dll,then use it to call CUsefulsplistWnd::ReplaceView(),
but it can't work.
My purpose is to build a Splitted Programe,which can run the plugins in the Dll.In this programe,the leftview is used to display the plugins icon,and the Rightview is the FormView area.
And I can't use the function SetPaneView() you given. Because of where could I get a *pView to make it as the parameter?
Help me Pls...
Thanx!!!
HFHero@163.com
|
|
|
|
|
Hi
you can cast you CFormView derived class to a CView since CView is a base class of CFormView
CFormView->CScrollView->CView->CWnd
CView *pView = (CView*)pMyFormView;
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerrywww.many-monkeys.com
|
|
|
|
|
OMG....
I mean I can't generate a FormView object alone.
Now I can just use UsefulSplitterWnd::CreatView() with a CRunTimeclass as parameter to create a CView object.
And could I get an CRunTimeClass* from a Dll,then use the pointer to create a CView?
So I can't get an pointer to my FormView object.
Pls read my question throughly, Thanx, I'm hurried...
-- modified at 11:56 Monday 29th May, 2006
|
|
|
|
|
Ah I don't think I understand your problem domain enough to help.
From your original post I think you are trying to do the following and I'll answer based on these assumptions.
#1) You have an application that loads forms into a frame dynamically.
#2) You are loading these forms from a DLL dynamically - i.e. these classes are not known about at compile time.
I think you need to understand more about CRuntimeClass and what it is and how it is implemented.
CRuntimeClass is not a class but a structure (or was when I last made an MFC program - a long long time ago) and is implemented by MACROS and hence every class you wish to load needs to be known about at compile/linker time.
You could get round this by having a common base class (CFormView may suffice)that you use to load and manipulate the class fom a DLL and you could use a DLL function (same name in every library that can be loaded and run using LoadLibrary/GetProcAddress[^]) that you could use to create the form (you could pass in a CDocument* should that be required) and then pass that as pointer to your code.
There is however an easier way to do all this - ActiveX (COM). Each of your forms is atomic, I guess, requiring no information for the main document and will therefore easily wrap into an ActiveX object. Now all you need to do is load and destroy ActiveX objects into the right view container when your icons are selected in the left view. If data is required to come from the document then you could create you own interface to pass this data to/from the ActiveX control. The added advantage of this is that you can host any control in that window that you wish and they don't all have to be written in C++ (e.g. VB, delphi, .NET, ...). MFC can act as a container foor COM objects very simply - CHtmlView or use this OleView sample[^] as a starter.
I hope this helps - if not then you'll either have to explain the problem more thoroughly and maybe even send code that shows what you are trying to do.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerrywww.many-monkeys.com
|
|
|
|
|
Well, let me try your suggestion now.
Anyhow,thank you for your help.Your words make me confident!;P
I'll tell you the result after I've tried it.
|
|
|
|