|
Try to use a dynamic_cast . If the returned value is NULL , then the pointer is not of that class.
|
|
|
|
|
How do i use dynamic_cast?...sorry,i've heard of it but i've never tried anything like that..
|
|
|
|
|
Do this:
pView = dynamic_cast<CMy3027View*>(pMF->GetActiveView());
if(pView)
m_numOfValues= pView->m_imageIndex;
You might have to turn on the RTTI option in VC.
|
|
|
|
|
It ran into exception handling error while executing
pView = dynamic_cast<cmy3027view*>(pMF->GetActiveView());
Anyway...is there a better way to obtain member variables of a CView class then?
|
|
|
|
|
good grief
the code you posted is horribly wrong considering it was provided to you correctly
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
;Poops...i mean i did run the right statement(that below) when i got an exception error.
pView = dynamic_cast<cmy3027view*>(pMF->GetActiveView());
|
|
|
|
|
oh, u missed the "display this message as-is (no HTML)" check box. sorry
did you turn on the RTTI build option?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
i c i c
yes i did enable it, under project->settings->c++ language...
|
|
|
|
|
I want to Make an Application ( MDI one )
the APPlication support one type of document ( texte document ) for that i need to the classe of wiew must be as EditView Class , and that's not a problem !
I let to the user put his texte in the first window and when he finish , if he click for a menu item ( for emple " Draw") a new Window ( Child Window ) must be apear (created)
and this window contain some Draw ( Squars lines ... etc )
|
|
|
|
|
First of all you need to make a new class inherited from CView , then register a new document template. The document template registration is done in the CWinApp of the program, you will find a code like this in the InitInstance() of the CWinApp ;
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_MultiDocMDITYPE,
RUNTIME_CLASS(CMultiDocMDIDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CMultiDocMDIView));
AddDocTemplate(pDocTemplate);
This creates a document tempalte formed of document class CMultiDocMDIDoc and child frame class CChildFrame and view class CMultiDocMDIView . The IDR_MultiDocMDITYPE is a resource id given for a string table entry and an icon and a menu to be attached to that document template.
Anyw, let's assume you made a CView class named CDrawView , you should add similar lines to register a new document template for it, like these
m_pMyDocTemplate = new CMultiDocTemplate(IDR_SECONDTYPE,
RUNTIME_CLASS(CMultiDocMDIDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CDrawView));
AddDocTemplate(pDocTemplate);
where m_pMyDocTemplate is a public member data you should declare in the App class of type CMultiDocTemplate* .
Just add these after the preivous document template registration. If you run your project now you will be asked to choose which document template to use. The names given to them are the name you have entered in the string table entry under the given ID (for our e.g. it is IDR_SECONDTYPE , just take a look on the default type entry and see how to make this string).
Well! you are going to choose the edit view document template and write whatever you want, then we come on the part needed to start the view window. This code should do it and it should be run from the CMainFrame class:
CMDIChildWnd * pMDIActive = MDIGetActive();
ASSERT(pMDIActive!=NULL);
CDocument * pDoc = pMDIActive->GetActiveDocument();
ASSERT(pDoc != NULL);
CMDIChildWnd * pNewFrame =
(CMDIChildWnd *)theApp.m_pMyDocTemplate->CreateNewFrame(pDoc, NULL);
if(pNewFrame == NULL)
return 0;
theApp.m_pMyDocTemplate->InitialUpdateFrame(pNewFrame, pDoc);
I know it's a little complicated but it should work. Remeber to include the header of the document class in the new CDrawView class to be able to access its member data.
You may get some problems or you may get nothing, but if there is any problems I may try to send you a sample project for the whole thing.
|
|
|
|
|
Hi all
i'm about to begin developing an application that requires me to draw an image on a either a form or a dialog box (if possible?). Basically the image will consist of a series of lines and basic shapes interconnected. What i would then like to be able to do is with the mouse click on individual lines and in doing so automatically change their properties e.g. say i clicked on a line it would change from green to red. Is this sort of functionality achievable. The issue i'd have from a conceptual point of view is how do you determine which line you have clicked on, if any, in the mouse button event handler???
If possible i'd like to be able to implement this in VC++ as i have very little VB experience. so to go back to my earlier question is it possible to draw lines shapes etc. on a dialog box? i've never tried anything like that before and unfortunately for this particular project the SDI or MDI app look would not be suitable!
Any advice is appreciated!!
Regards,
Griff
|
|
|
|
|
Paul Griffin wrote:
is it possible to draw lines shapes etc. on a dialog box?
of course. do it in the OnPaint function.
Paul Griffin wrote:
do you determine which line you have clicked on, if any, in the mouse button event handler???
in your OnLButtonDown handler, you'll need to run through your list of line/shape objects and determine which, if any, of these objects contain the point-of-click. if there are multiple objects, you'll have to figure out a scheme for picking just one (Z-order).
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
Hey Chris
thanks for the quick reply ... sorry if that question about drawing on dialog boxes seemed stupid ... but i have very little MFC experience and even less with drawing with MFCs
I think i get what your saying though take the co-ordinates returned from the OnLButtonDown handler and match them against co-ordinates in the list of shapes .. seems blatantly obvious when someone points it out to you.
thanks again!!
Griff
|
|
|
|
|
Take a look at DrawCli MFC Sample.
|
|
|
|
|
I want the cdialog to come up square in the middle of my app. So I did the foll, but its really not at the center at all!!!!
CRect cRect;
GetClientRect(&cRect);
int width = 150;
int height = 50;
CPoint cPoint;
cPoint.x = cRect.Width()/2 - width/2;
cPoint.y = cRect.Height()/2 - height/2;
ClientToScreen(&cPoint);
msgText.Format("Number of files found %d",m_nToDisplay);
CMsg* pMsg = new CMsg;
if (pMsg == NULL) return;
pMsg->m_msgText = msgText;
BOOL ret = pMsg->Create(IDD_DIALOGMSG, this);
if(!ret) return;
pMsg->ShowWindow(SW_SHOW);
pMsg->MoveWindow(cPoint.x, cPoint.y, width, height);
Appreciate your help,
ns
|
|
|
|
|
MoveWindow works relatively in the client area of a parent window. You shouldn't use the ScreenToClient call.
Pavel
Sonork 100.15206
|
|
|
|
|
tried that, and it positioned it at the corner top of my screen when for testing purposes I told it move 0,0...no screentoclient etc...not at the corner of my app..
Appreciate your help,
ns
|
|
|
|
|
Have you tried just doing CDialog::CenterWindow() ? You can pass the parent with which you wish to work to determine the center.
|
|
|
|
|
I did CenterWindow(0) and its at the center of the screen, not my app. I tried passing in (this) in my parent view, so then it does stay along with the client but it doesnt center it ...ths might be a problem related to the fact that I fitted my view to be the size of the frame using CPs CenterWindow article by Brian HArt. SO maybe its centering it to what would have been had I not meddled with the sizing...
Another thing: the dlg style is popup, not child, but I dont know if thats relevant. I need it to be popup. For the moment popping it up at the center of the screen is fine....
Thanks! I guess the (0) means the desktop....
Appreciate your help,
ns
|
|
|
|
|
All I want to do is to write a script that will modify they rights of the everyone group. Which you can do on any object by going to it's security page. all I am tyying to do is automate this process which I know is possible because when edit an objects security page all you are doing is executing a series of API functions and any API function is accessible from C++ I know I cannot delete the everyone group but I also know I can assign rights to the everyone group and this is what I want to do. I need to know how to target your harddrives DACL and remove an particular ACEplease help
|
|
|
|
|
:(Hi,
I am having a Property page with an Editable ComboBox, wherein if i press the delete key from keyboard, would delete the item selected in List of Combo Box.(Combo Box List is in Dropped down State)
Requirement:
1. Delete Option will be enabled only when the List of Combo Box is in dropped down state and an item is selected in List of Combo Box(Found Solution)
2. If i type some text in the Combo box window & the list is dropped down and an item is selected using mouse, then delete key is pressed. The item selected would be deleted & the text in window should not be deleted and the focus in text would be maintained. (I am not able to retain the focus of the Text in ComboBox Window)
3. Once the Item selected in Listbox is deleted the List will reduce based on the number of items deleted.
The above point is similar in implementing the Login screen functionality of web Brosers using CCombobox.
I need a solution for this very urgently.
I am enclosing a sample workspace with the above problems indiacted
Regards,
R.S.Velan
Senior Software Engg.
L&T Infotech Ltd...,
Chennai
India
|
|
|
|
|
hi,
i want to know how i can let my network card send raw data(without TCP/IP and that stuff). and of course how to receive it.(OSI layer 3)
and of course... is it possible(because windows already uses the network card)
|
|
|
|
|
Hi all,
Anybody knows how to get the highlighted string from window application? For example, getting the highlighted string from IE or MS Word. I do not have any idea of implement it.
Cheers,
Tony
Enjoy Coding.
|
|
|
|
|
What kind of window? In a generic window you are limited to GetWindowText only.
|
|
|
|
|
:-OThank you for your answer. I am going to do the following works:
1) Highlighted a string in an MS Word document/ MS IE.
2) Press a Hotkey from keyborad to activate my application, and use the highlighted string in step#1 as the input parameter.
Does it possible to be done by VC++?
Cheers,
Tony
|
|
|
|