Home » U++ Library support » U++ Widgets - General questions or Mixed problems » List of custom controls, how?
Re: List of custom controls, how? [message #37745 is a reply to message #37717] |
Thu, 08 November 2012 09:29   |
crydev
Messages: 151 Registered: October 2012 Location: Netherlands
|
Experienced Member |
|
|
Thanks a lot Honza! Your example made sense to me. I implemented it in my application the following way:
// Initialization of the scrollbar frame.
mScrollBar.Vert().AutoHide();
mScrollBar.WhenScroll = THISBACK(ScrollImdbResults);
mImdbSearchResults.AddFrame(mScrollBar);
Code populating the ParentCtrl with controls.
mImdbCtrls.Clear();
ImdbManager im;
im.ImdbSearch(SEARCHMODE_KEYWORD, mMovieList.Get(row, 0));
auto tmpRes = im.GetValues();
for (int i = 0; i < /*tmpRes.GetCount()*/20; i++)
{
ImdbSearchResult *m = new ImdbSearchResult(); // This is weird! I had it a struct with a default constructor but that
// kept giving me an error about not having a 'copy constructor'. I still
// don't know why this notation is not resulting in a memory leak.
m->SetValues(CtrlImg::save(), tmpRes[i].cTitle, tmpRes[i].cUrl);
mImdbCtrls.Add(m); // Array<ImdbSearchResult> mImdbCtrls;
mImdbSearchResults.Add(mImdbCtrls[i].HSizePos().TopPos(IMDBCTRLHEIGHT * i, IMDBCTRLHEIGHT)); // ParentCtrl mImdbSearchResults;
}
mScrollBar.SetTotal(mImdbCtrls.GetCount() * IMDBCTRLHEIGHT); // const int IMDBCTRLHEIGHT = 60;
The scroll event function
void MovieManager::ScrollImdbResults()
{
int pos = mScrollBar.Get();
for (int i = 0; i < mImdbCtrls.GetCount(); i++)
{
mImdbCtrls[i].TopPos(IMDBCTRLHEIGHT * i - pos, IMDBCTRLHEIGHT);
}
}
The Key function
bool MovieManager::Key(dword key, int)
{
return mScrollBar.VertKey(key);
}
The Layout function
void MovieManager::Layout()
{
mScrollBar.SetPage(GetSize().cy);
}
There still is one thing that doesn't work that I would like to work. Using the mouse scrollwheel to scroll though the objects is not working. My guess is that this should be implemented in the Key(dword key, int) function. Is there maybe a builtin property or function to handle this? And which keys are being handled by the Key(dword key, int) function?
Thank you!
[Updated on: Thu, 08 November 2012 09:30] Report message to a moderator
|
|
|
 |
|
List of custom controls, how?
By: crydev on Mon, 05 November 2012 12:35
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: mirek on Mon, 05 November 2012 19:50
|
 |
|
Re: List of custom controls, how?
By: crydev on Mon, 05 November 2012 21:48
|
 |
|
Re: List of custom controls, how?
By: crydev on Wed, 07 November 2012 10:02
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: crydev on Thu, 08 November 2012 09:29
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: crydev on Tue, 27 November 2012 17:33
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: crydev on Wed, 28 November 2012 08:20
|
Goto Forum:
Current Time: Sat Jun 07 01:20:58 CEST 2025
Total time taken to generate the page: 0.05436 seconds
|