|
I want to create a CScrollView in a dialogbased project.So i follow thsese steps :
1.createa a dialogbased project named MyDlg.
2.drag a CStatic control to this dialog,its ID is IDC_STATIC_VIEW
3.Create a new class named CMyView and its base class is CScrollView
4.Add a member function CreateView,include "MyView.h",Add a member variant
CMyView *pView;
we realize it like this:
VOID CViewInDlgDlg::CreateView()
{
CRect rect;
CWnd* pWnd=GetDlgItem(IDC_STATIC_VIEW);
pWnd->GetWindowRect(&rect);
ScreenToClient(&rect);
CCreateContext cx;
cx.m_pNewViewClass=RUNTIME_CLASS(CMyView);
cx.m_pCurrentDoc=new CDocument();
CFrameWnd* pfWnd=(CFrameWnd*)this;
CWnd* pView=pfWnd->CreateView(&cx);
pView->MoveWindow(&rect);
}
When I run this program, i found there was a ASSERT error at line 134 in viewsctrl.cpp.I correct it by overriding the function OnPrepareDC,I modified like this:
CView::OnPrepareDc(..)
Then no error ocurred.
I try to test if it can work,so i add a button in this dialog.Then I wrote this in its OnButton1 function,I wrote this:
void CMyDialog::OnButten1()
{
CDC *pDC=pView->GetDC();
pDC->TextOut(10,100,"hello");
}
Click this button it crashed.
The error happened in this line:
{ ASSERT(::IsWindow(m_hWnd)); return CDC::FromHandle(::GetDC(m_hWnd)); }
I have no idea now,someone can help me correct this error?
PS:If MyView Class is based on CView,then this error cannot be found.
As English is not my native language,i hope you can understand my meaning.
|
|
|
|
|
Hi, you can use the Doc/View Framework only in a SDI/MDI application. Sorry!
|
|
|
|
|
|
Hello, all!
Who can tell me the concept of "UNC path"? In which case should we use "UNC path" ?
I feel confused.
Best Regards,
|
|
|
|
|
|
hi
I have a clent/sever MFC application.I used MAPI(MAPI32.dll)in my client application to send a email from client program to an external email address.The problem is that it works on some systems but not on others. i.e on other systems we don't receive the emails.
i have configured outlook on all systems though....
what could be the problem?Is it with mail client or MAPI??
thanx in advance
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
-- modified at 4:16 Thursday 23rd March, 2006
|
|
|
|
|
Hello,
I have an MDI application in MFC, wherein I am opening several documents, my question is how to get all the child frame windows thru the document pointer?
I am using functions GetFirstDocTemplatePosition and GetNextDocTemplate. But thru those how can I get all the child frame windows. Please help.
Software Developer
Sanjay Khapre
|
|
|
|
|
One way could be to use the
FindWindow() function
I haven't tried it myself but if you get success doing the same please intimate me
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
Have you tried CWnd::GetNextWindow.
MSDN description of function says
"Searches for the next (or previous) window in the window manager’s list. The window manager’s list contains entries for all top-level windows, their associated child windows, and the child windows of any child windows.
If CWnd is a top-level window, the function searches for the next (or previous) top-level window; if CWnd is a child window, the function searches for the next (or previous) child window."
Use this function on main frame window .
In document class you can get main window by using function AfxGetMainWnd
|
|
|
|
|
could someone plz tell me how to control mouse movement using VC++
does any one have the code for it or even the logic would do.
Thank You
|
|
|
|
|
see SetCursorPos[^]
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
your query doesn't seem to be related to what you tried to ask
Why do you want to set the cursor position explicitly.
however if you still want to do it you can use the SetCursorPos() function
Bankey Khandelwal
Software Engineer
|
|
|
|
|
Hello All,
I've a MFC application from which I've to call a routine from a DLL.
EARLIER, This DLL was getting used by a JAVA application.
But now there is a MFC application instead.
We dont' have to change the DLL code for this in any case.
The export routines have following declaration:
JNIEXPORT void JNICALL Java_gui_config_setManufacturer(JNIEnv *env, jobject obj);
Please let me know how this routine can be called from MFC application.
Thanks in advance!
Regards!
-- modified at 22:51 Thursday 23rd March, 2006
|
|
|
|
|
In C++ how we can associate a function with a variable. means the function should be called automatically when the value of variable changes.
|
|
|
|
|
i don't really understand. this cannot be done automatically - say, when you assign the variable, the function is called automatically.
but if the variable changes, it is because you assigned it, so why no calling the function right after this assignation ?
moreover, i'm not sure, by i have the impression that we don't have the same vocabulary.
what you call by 'variable' is a control over a dialog or a frame, which is associated with a variable ; what you need so is knowing when the control's content is modified so that the framework calls its event handler ?
is so, see the events of your control (EN_CHANGE for a CEdit control).
if i'm wrong, please reformulate your question because it is really not clear enough.
|
|
|
|
|
There is no way to do that in C++, atleast that i know of.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Just a thought.
What if you create a class, encapsulating a variable of the desired type?
And then, using operator overloading, call a (class) function when the value changes?
Right out of my mind, I think it should work.
Thoughts, anyone?
|
|
|
|
|
yes, it's a good solution, as you ask my thought.
but i still have a doubt about what the guy was asking, and i suspect him not to express himself correctly and not to want this...
anyway, as he doesn't give feedback...
|
|
|
|
|
yes - and make the actual data private which force all access to happen through the methods.
|
|
|
|
|
There is no standard way to do this. In MSVC you can use __declspec(property) to do it but note this is not portable.
Steve
|
|
|
|
|
I compile a project(ATL dll based) in VS.NET 2005 under windows XP(sp2) and the build configuration is x64. The IDE will always perform a registration after project successfully compiled. This is the trouble, my machine is 32bit and target dll is 64bit, it always show an error:
Project: error PRJ0019: A tool returned an error code from "Performing
registration".
It is deservedly error for 64bit file can't register under 32bit windows.
how could i get the dll under 32bit windows? by config the project setting or something else??(Stop the perform registration action?)
|
|
|
|
|
|
Hi!
I have dynamically created a CButton. How can I remove it totally (i mean it should not be visible anymore).
|
|
|
|
|
Example
CButton *m_Button;
m_Button=new (CButton);
m_Button->Create("Butotn1",WS_CHILD|WS_VISIBLE|BS_NOTIFY,CRect(0,0,100,20),this,IDC_BUTTON1);
m_Button->DestroyWindow();
|
|
|
|
|
Not sure but try
pButton->DestroyWindow()
and then
delete pButton;
should work
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|