|
-
August 20th, 1999, 12:02 PM
#1
CWnd::FromHandle - Really want CView::FromHandle
I have an SDI application that acts as a console taking in lots of commands from user... one of these causes a bitmap to be read into memory and lots of associated info. - currently this is being done by acquiring a handle for the window and using the SDK CreateWindow() with the handle as one of the parameters - huge sections of code currently rely on the handle etc. - Now this display needs more functionality - I could create a CWnd using CWnd::FromHandle but really I'd like the functionality of CScrollView & Doc - Being inexperienced I've only ever created these classes as part of a new SDI application - can I attach them to this new window? If so what's the best way to use the development enviroment, initialise the Doc. etc. without creating a new SDI?
Many thanks,
Rachel
-
August 20th, 1999, 12:12 PM
#2
Re: CWnd::FromHandle - Really want CView::FromHandle
Yes, you can use these without the AppWizard Framework. What you need to do is use a Document Template. I have some example code for you; it is for a MDI application, but you should be able to figure it out for SDI.
//first I create the Template hint: multiTemplate is, I believe, of type CMultiDocTemplate
multiTemplate = new CMultiDocTemplate(
IDR_SINGENTYPE,
RUNTIME_CLASS(CSingenDoc), //name of the Document class
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CSingenView)); //name of the View class
AddDocTemplate(multiTemplate);
//now to get a new document/view pair up and running we do this
CSingenDoc* doc=(CSingenDoc*)multiTemplate->OpenDocumentFile(NULL,true);
//hint: you don't really need the stuff left of (CSingenDoc... unless you need a pointer to your document (which I did)
and Whoalla - we now have newly functioning doc/view pair. Of course you still need to create yourself a C*Doc and C*View pair of classes, but you should be able to figure this out from looking at an old MFC App.
Hope this helps you out,
Brian Budge
-
August 23rd, 1999, 07:00 AM
#3
Re: CWnd::FromHandle - Really want CView::FromHandle
If you want the functionality of CScrollView and you know that it is a CScrollView, you can do this...
CScrollView* l_pScrollView = (CScrollView*)CWnd::FromHandle(l_hWnd);
Hope this helps,
Brad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|