scroll content of a dialog Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
schmallaria
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Aug 19, 2005 9:54 am

scroll content of a dialog

Post by schmallaria »

hello,

i have to scroll the content of a modal dialog.

how can i do this?

can i use wxScolledWindow? it's needfull to create the dialog modal because the program have to wait until the user ends the dialog.
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Re: scroll content of a dialog

Post by upCASE »

schmallaria wrote: can i use wxScolledWindow?
Yes.
schmallaria wrote: it's needfull to create the dialog modal because the program have to wait until the user ends the dialog.
If you allready have it in a frame, try MakeModal() to create a modal frame.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
schmallaria
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Aug 19, 2005 9:54 am

Post by schmallaria »

thank you for your reply...i would try to test it.
schmallaria
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Aug 19, 2005 9:54 am

Post by schmallaria »

i dosn't work :( ...

let me explain what i want to do:

my main application (developed with mfc) calls a function from a dll (developed with wxwidgets).
when the function is called a modal dialog will be created (this is because the main application have to stop until the user ends the dialog).
on the dialog are a lot of controls wich are not all displayed, because of that i must scroll the content of the dialog.

i can't use a wxFrame, because after the construction of the frame the program returned to the main application but i want to stop the main thread until the user click the ok or cancel button.
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

So, what was the problem with the dialog/frame. Didn't you see the controls or it is not scrolling or what?
For making a wxFrame modal, you can use MakeModal(true) function.
schmallaria
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Aug 19, 2005 9:54 am

Post by schmallaria »

the problem was:

i dont't know how to scroll the dialog.

when i use a frame and the function MakeModal, the frame is created but i didn't see it and after the construction of the frame the the dll funtion returned to the main application.
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Atleast the frame should be visible, did you call m_pFrame->Show(true); after the creation. And for the second problem, i think wxDialog is more better choice, use ShowModal(); to stop the main program execution loop.
schmallaria
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Aug 19, 2005 9:54 am

Post by schmallaria »

exactly this is my problem.

when i use a wxDialog everything is fine. the main application stop, the user can click a button and the the dll function returned to the main application.

but how to scroll the content of the dialog?
there are a lot of controls and to see all i have to scroll down with a little scrollbar. the wxDialog doesn't scroll in standard.
how can i do this?
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Create a object of wxScrolledWindow, whose parent is the dialog, and add controls to the wxScrolledWindow, the controls parent will be the wxScrolledWindow object.
schmallaria
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Aug 19, 2005 9:54 am

Post by schmallaria »

thank you for your answer

...now i see the modal dialog with the scrollwindow and my controls, but i don't see the scrollbar and it doesn't scroll.

here is the code i use for (i use evc++ and the wince port of wxwidgets):

Code: Select all

MyDialog::MyDialog(const wxString& title)
: wxDialog(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDIALOG_NO_PARENT)
{
	//create the main sizer
	wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);

	//create the scrollwindow
	wxScrolledWindow* wnd = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, wxT("scroll"));

	//create the second sizer
	wxBoxSizer* innersizer = new wxBoxSizer(wxVERTICAL);

	//create a lot of controls to see how it scrolls
	wxTextCtrl* m_textCtrl;

	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);
	m_textCtrl = new wxTextCtrl(wnd, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
	innersizer->Add(m_textCtrl, 1, wxEXPAND |wxALL, 5);

	//set the second sizer to the scolledwindow
	wnd->SetSizer(innersizer);
	wnd->SetAutoLayout(true);
	wnd->Layout();

	//add the scrolledwindow to the main sizer
	main_sizer->Add(wnd, 1, wxEXPAND | wxALL, 5);
	
	SetSizer(main_sizer);
	SetAutoLayout(true);
	Layout();

}
schmallaria
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Aug 19, 2005 9:54 am

Post by schmallaria »

i have forgotten a line of code:

simply add

Code: Select all

wnd->SetScrollbars(20,20,50,50); 
and it works :D

thank you guys
Post Reply