|
You are right buddy.
I only get the Caption but not the actual text.
Just FYI, my view is a complex (e.g. CFormView-based views). Any pointers, I mean, How can I read data that is being displayed in the same?
A code snippet will be helpful.
Thanks.PanB
|
|
|
|
|
Just an add-on, when I tried to write some text on this window by getting its handle, its actually setting its caption...
|
|
|
|
|
Here's some non MFC code that will grab the window text from a window's children.
http://www.savefile.com/files/1782897[^]
It can look at it's own children or you can enter the (full) title-bar text of
a program and it will look at that app's child windows.
Hope it's more useful and less horrific than my last 'effort'
|
|
|
|
|
Hi there.
Even that article does not fulfilled my requirement.
But anyway buddy, Thanks a TON for your effort and time.
Regards
PanB
|
|
|
|
|
If you can easily determine the type of a given view object, or if your app only has one view-based class, you can get a pointer to the active view and cast it to the actual type of the CFormView -based class.
Your class can expose either the text of its children or their HWND s, either one can be used to get the text of the controls. You can even have it present a struct -type that contains all of the HWND s, allowing you easy access to all of the controls.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks for your reply James.
Just an add-on info. I am trying to hook an existing application with this new piece of code. So, I do not know what type of view is it, but I am sure its not something that's being derived from CEdit.
As I said before, if I try to set any text in the control, its Caption gets filled with that text.
In case you need any further info., please let me know.
Thanks
PanB
|
|
|
|
|
I created a Smart Device MFC SDI application in VS2005. I've got some files with names like this: MyApp.cpp, MyAppDoc.cpp, MyAppView.cpp, MainFrm.cpp. There are classes in these files. In MyApp.cpp there is a class called CMyAppApp. In MyAppView.cpp there is a class called CMyAppView. In MainFrm.cpp there is a class called CMainFrame. How do I call public methods in CMyAppView and CMainFrame from CMyAppApp? How do I get hold of instances of the classes so I can access the methods? I don't want to use "new" on CMainFrame. This would create a new form. I want to get hold of the handle to the existing form and view (CMainFrame and CMyAppView). I can't find any good pointers in afxwin.h.
|
|
|
|
|
lagu2653 wrote: How do I get hold of instances of the classes so I can access the methods?
There are no instances of classes (objects) until you create them.
You can't access non-static methods of a class without an object.
lagu2653 wrote: I don't want to use "new" on CMainFrame. This would create a new form. I want to get hold of the handle to the existing form and view (CMainFrame and CMyAppView).
Where do these existing windows come from if you don't create them?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oops, I misread your post
lagu2653 wrote: How do I get hold of instances of the classes so I can access the methods? I don't want to use "new" on CMainFrame. This would create a new form. I want to get hold of the handle
MFC has functions to to get at those instances like, AfxGetMainWnd() or something
Then the CFrameWnd[^] class has functions to get Views like GetActiveView()
led mike
|
|
|
|
|
OOOPS, bits are flowing more slowly from Italy...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
led mike wrote: Oops, I misread your post
me too apparently!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If I understand you correctly then you've already wizard-generated code creating such windows. You may to call AfxGetMainWnd to get a pointer to the frame window (possibly you need to cast it) and the call its GetActiveView (and, again, cast it).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Recently I reinstalled visual c++ 2008 Express edition and ever since then, when I open a project, all the source files within the project no longer automatically restore themselves to their previous state. This question isn't very clear so lets pretend I had the files main.cpp, d3d.cpp, and d3d.h open when I last closed my project. When I open this project again, none of the source files will open with it. I have to manually open all the source files (which can be quite tedious for large projects). Previous to reinstalling, the files main.cpp, d3d.cpp, and d3d.h would all automatically restore themselves in this particular example.
I've searched through the options menu but couldn't find a setting for it
|
|
|
|
|
Nobody knows?
|
|
|
|
|
Now I need to write a dll witch COM interface, so that the asp application can use it.
The COM object will have a window. Can asp application show the window created by the COM object?
The problem is:
My COM knowledge is only from the book <Inside COM>, almost no practical experience.
However I can write regular dll (common interface, not COM).
Is there any quick guide for implementing such a COM object?
Thanks very much.
system
|
|
|
|
|
Try this oldie good book about COM Developer's Workshop to COM and Atl 3.0, there are also many good articles here in CodeProject, but this book is a good introductory tutorial.
JO
|
|
|
|
|
Thanks, but I don't not have enough time for a book now.
Because of the need in my job, time is limited,
so I need a quick way to implement a simple com object.
system
|
|
|
|
|
Why don't you try creating a simple COM component and see if can it be called in ASP.
read this link COM[^]
The essence of COM is a language-neutral way of implementing objects that can be used in environments different from the one they were created in, even across machine boundaries
Check this section of CP for examples and niformation
COM[^]
Regards,
Sandip.
|
|
|
|
|
Thanks.
I found that ActiveX is just for this.
system
|
|
|
|
|
Hi,
I want to know how Visual C++ experts implement these complicated logical relations between visual components of a form.
For example when user switch between different radio buttons and you need to en/disable other components or some other tasks.
Actually I need some APIs (like EnumChildWindows) or some approaches(which I don't know any!) to make it more covnvenient to do such boring tasks!
|
|
|
|
|
Hello everybody,
in my program I dynamically add up to four CRichEditCtrl elements to a dialog. So far no problem. For some functions (e.g. search function) I need to know which control holds the focus.
How can I determine the active RichEdit control?
Greetings
|
|
|
|
|
Member 3554668 wrote: I dynamically add up to four CRichEditCtrl elements to a dialog.
That means you have handle to all of them.
You can use Getfocus() and check handle returned by it against the handles you have.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
I tried this already, I compared GetFocus() with GetDlgItem('ID'), but it didn't work. They returned two different handles...
For 'ID' I inserted the number I used to create the CRichEditCtrl. Perhaps this is the problem?!
CRichEditCtrl *pRichEdit = new CRichEditCtrl;
pRichEdit->Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL|
ES_MULTILINE | ES_READONLY, rectRichEdit, this, 2000+i);
m_oaAllRichEditCtrl.Add(pRichEdit);
Greetings
|
|
|
|
|
Member 3554668 wrote: For 'ID' I inserted the number I used to create the CRichEditCtrl. Perhaps this is the problem?!
I dont think it can be a problem
But you can verify using GetDlgCtrlID() that id you passed is getting set correctly..
Instead of comparing handles you can also use
GetDlgCtrlID and compare the ID's..
Regards,
Sandip.
modified on Thursday, September 11, 2008 8:52 AM
|
|
|
|