How to scroll automaticly in CView

I have a problem again :)
I use dynamicly created CView class as my dialog..and when I dynamicly add any control which is out of client dialog area ,the dialog doesnt scroll automaticly..I mean no scrollbar is being created so I cant scroll down to tha created control..How can I fix it?
Thanks for any suggestions...
[325 byte] By [don_tom] at [2007-11-20 0:38:13]
# 1 Re: How to scroll automaticly in CView
What was the reason "to dynamically create CView class as the dialog" rather then use CFormView derived class?
VictorN at 2007-11-10 23:20:54 >
# 2 Re: How to scroll automaticly in CView
I also tried CScrollView but It didnt help..but I can try it..
thanks
don_tom at 2007-11-10 23:21:57 >
# 3 Re: How to scroll automaticly in CView
In case of CScrollView derived class you could try using CScrollView::SetScrollSizes method
VictorN at 2007-11-10 23:23:01 >
# 4 Re: How to scroll automaticly in CView
I did but it didnt work..I used this function in CView::OnInitialUpdate()
SetScrollSizes(CSize(100,100)) for example.
don_tom at 2007-11-10 23:23:56 >
# 5 Re: How to scroll automaticly in CView
1. Please, define "didnt work". It is not clear what you did, what you expected to see, what you saw instead, what does 100x100 size meand (why 100, not 117 or 87 for instance?)!
2. used this function in CView::OnInitialUpdate()You probably, meant in OnInitialUpdate() method of your CSrollView derived class?
3. You haven't answer my first question - What was the reason "to dynamically create CView class as the dialog" rather then use CFormView derived class?
VictorN at 2007-11-10 23:24:55 >
# 6 Re: How to scroll automaticly in CView
Sorry for unclear reply.
1.
Ive meant it didnt work that it didnt do what I want-automaticlly show sroll bar when its created control out of showing area and so I can use that scroll bar to scroll there..I thought to use function SetScrollSizes to fix this problem.
2.
Yes Ive meant CScrollView::OnInitialUpdate().

3.
I use CView because I also create controls automatically,and if I used CFormView it should be attached to some existing dialog created by dialog designer and I want to create everything just with MFC functions

Ive tried to use CScrollView and function SetScaleToFitSize or SetScrollSizes
with CSize(100,100) just as an example.
I actually dont know what it mean CSize(100,100)..
don_tom at 2007-11-10 23:25:58 >
# 7 Re: How to scroll automaticly in CView
Sorry for unclear reply.
2.
Yes Ive meant CScrollView::OnInitialUpdate().

3.
I use CView because I also create controls automatically,and if I used CFormView it should be attached to some existing dialog created by dialog designer and I want to create everything just with MFC functionsSorry, what class is your view derived from: CView or CScrollView? It is now absolutely unclear! :confused:

Ive tried to use CScrollView and function SetScaleToFitSize or SetScrollSizes
with CSize(100,100) just as an example.
I actually dont know what it mean CSize(100,100)..Well, Trial and Error method may be in many cases very helpful... but I am afraud - not in your case!
Your should firstly understand what you need, what and why you are trying to do, what CSize means and why you need the size 100x100, not 123456x222222 or some other, ...
Also code snippet posted to Forum could sometimes help to understand the problem.
VictorN at 2007-11-10 23:26:57 >
# 8 Re: How to scroll automaticly in CView
I use CScrollView now,but my program also works on CView
It doesnt matter in that way but when I want scrolling I should use CScrollView..
I dont know If it would help you some code but:
I got document/view application so in InitInstance funtion is:
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CPocketNemDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CMyView));
and my view is CScrollView class..
don_tom at 2007-11-10 23:28:07 >
# 9 Re: How to scroll automaticly in CView
in MyView in OnUpdateFunction I use for example
CEdit *edit
edit->Create(WS_VISIBLE,VS_CHILD,CRect(0,0,20,20),this)
and so..
I create for example 20 edits like that
and last few edits disappear form showing area and I want to scroll to them
but it doesnt show scroll bar
don_tom at 2007-11-10 23:29:00 >
# 10 Re: How to scroll automaticly in CView
The code you've posted (two lines with CEdit creation) is NOT correct!
Please, either post a real code you are using or feel free to solve your problems yourself. :cool:
VictorN at 2007-11-10 23:30:01 >
# 11 Re: How to scroll automaticly in CView
Im sorry I was going to have a dinner a so i wrote it fast and uncorrectly..
//----------fragment 1
CMyView:CScrollView
//----------fragment 2
CEdit *edit;
//----------fragment 3
CMyView::OnUpdate(){
if(edit==NULL){
CreateInterface();
edit =new CEdit;
}
edit->Create(WS_CHILD|WS_VISIBLE|WS_BORDER,CRect(x,y,x+width,y+height),this,ID);
}
//------end
int x,y,width,height,ID are my variables initialized in my intitialization function called CreateInterface() and are changing as program creates controls
Its not the same code that Im using but identical..
Thats finally the way of creating controls like edit combobox,button in my program
don_tom at 2007-11-10 23:31:10 >
# 12 Re: How to scroll automaticly in CView
...
Its not the same code that Im using but identical..
Thats finally the way of creating controls like edit combobox,button in my programSo, I wish you to "identically" solve your problem...
Good luck!
VictorN at 2007-11-10 23:32:07 >
# 13 Re: How to scroll automaticly in CView
OK
Thank you anyway
don_tom at 2007-11-10 23:33:03 >
# 14 Re: How to scroll automaticly in CView
Ive finally solved it by calling function SetScrollSizes always when new control is being created with new computed CSize..
don_tom at 2007-11-10 23:34:05 >