iCarousel item disappearing when scrolling out of its height? - icarousel

I have written a program to scroll vertically in iCarousel, item appearing fine but I am facing problem while scrolling like items disappearing when I scroll out of iCarousel allocated width.

Make sure you're telling iCarousel to use enough views with the option iCarouselOptionVisibleItems:
- (CGFloat)carousel:(iCarousel *)_carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
//customize carousel display
switch (option)
{
case iCarouselOptionVisibleItems:
{
return 11;
}
default:
{
return value;
}
}
}

Related

Win32 Listview Tilemode Interactable Item Space Question

When custom painting a listview item in tileview, returning CDRF_SKIPDEFAULT during CDDS_ITEMPREPAINT enlarges the interactable rect of the item to the size of the actual item (i.e. the size received from ListView_GetItemRect(LVIR_BOUNDS)) instead of only the size of icon+label. How and why does this happen exactly? I couldn't find a clear answer in the docs or on the web. I mean, shouldn't handling custom paint only affect the painting of the item and not the way you interact with it?
Codesample:
::NMLVCUSTOMDRAW* pNMCustomDraw = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
switch (pNMCustomDraw->nmcd.dwDrawStage)
{
// Before the painting cycle begins.
case CDDS_PREPAINT:
{
return CDRF_NOTIFYITEMDRAW;
}
// Before an item is drawn.
case CDDS_ITEMPREPAINT:
{
return CDRF_SKIPDEFAULT;
}
}
Visual representation of the question:
The line case CDDS_ITEM | CDDS_PREPAINT is checking the result value of "or'ing" CDDS_ITEM | CDDS_PREPAINT. plus, you already checked CDDS_PREPAINT above. Shouldn't it be CDDS_ITEMPREPAINT ?
It should be like this, probably:
switch (pNMCustomDraw->nmcd.dwDrawStage)
{
// Before the painting cycle begins.
case CDDS_PREPAINT:
{
return CDRF_NOTIFYITEMDRAW;
}
// Before an item is drawn.
case CDDS_ITEM: // fall through
case CDDS_ITEMPREPAINT:
{
return CDRF_SKIPDEFAULT;
}
}
Plus, MSDN states that:
CDRF_SKIPDEFAULT The application drew the item manually. The control
will not draw the item. This occurs when dwDrawStage equals
CDDS_ITEMPREPAINT.
in https://learn.microsoft.com/en-us/windows/win32/controls/nm-customdraw-list-view
check here as well (MSDN):
https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmcustomdraw
Try that :). And don't forget to add breaks if needed after cases. Greetings

Text Selection with CRichEditCtrl in MFC

I have CRichEditCtrl object which is read only(Text is for read and not allowed to modified). I want to provide functionality of Text Selection with Mouse for text displayed with CRichEditCtrl object.
Following Code is working to capture event for Left Mouse Button - DOWN & UP
BOOL CReportFormView::PreTranslateMessage(MSG* pMsg)
{
if (m_EditNs->GetFocus()!=NULL)
{
switch (pMsg->message)
{
case WM_LBUTTONDOWN:
return TRUE;
case WM_LBUTTONUP:
return TRUE;
}
}
}
Now looking for some code to write in case block which will highlight selected text. I want to know if there is any API available for CRichEditCtrl object which help to track at which location user pressed Left Mouse Button and released
You could use member function CString strText = m_myRichEditCtrl.GetSelText(); or some other member function. Like GetSel() just a suggestion.
I think you will need to use the EM_CHARFROMPOS message. ex. some form of this:
POINTL pt { x,y }; // ... screen coordinates to test relative to edit
DWORD info = m_EditNS->SendMessage(EM_CHARFROMPOS, 0, pt);
int charIndex = LOWORD(info);
int line = HIWORD(info);
After that, set the selection with normal selection methods.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb761566(v=vs.85).aspx

GetCheck() working for check buttons but not radio buttons?

I'm just learning about making dialog boxes with MFC in Visual Studio 2010.
From what I can see on msdn's website, the GetCheck() function should work the same for both check boxes and radio buttons.
Basically I have two radio buttons next to two sliders. If one radio button is on, that slider is disabled, and if the other radio button is on, then the other slider is disabled.
When I had the radio buttons switched out for check boxes, this was the code i used:
void Cstring_copyierDlg::OnBnClickedSld1chk()
{
UINT nCheck = m_slide1check.GetCheck();
if(nCheck == BST_CHECKED){
m_slider.EnableWindow(FALSE);
}
else{
m_slider.EnableWindow(TRUE);
}
}
void Cstring_copyierDlg::OnBnClickedSld2chk()
{
UINT nCheck = m_slide2check.GetCheck();
if(nCheck == BST_CHECKED){
m_slider2.EnableWindow(FALSE);
}
else{
m_slider2.EnableWindow(TRUE);
}
}
This code worked fine. But when I switched out the check boxes for radio buttons, this is the code i used:
void Cstring_copyierDlg::OnBnClickedRad1()
{
UINT nCheck = m_radio1.GetCheck();
if(nCheck == BST_CHECKED){
m_slider.EnableWindow(FALSE);
}
else{
m_slider.EnableWindow(TRUE);
}
}
void Cstring_copyierDlg::OnBnClickedRad2()
{
UINT nCheck = m_radio2.GetCheck();
if(nCheck == BST_CHECKED){
m_slider2.EnableWindow(FALSE);
}
else{
m_slider2.EnableWindow(TRUE);
}
}
However the second piece of code returns the following error upon compilation:
error C2228: left of '.GetCheck' must have class/struct/union
What gives?
You are choosing the wrong variable type for the DDX in the add variable wizard. You should choose the control type there.
To change the variable type manually, replace the type of the m_radio1 to CButton and replace DDX_Radio with DDX_Control in DoDataExchange.

Clearing Scene And Flushing Variables in OpenGL

I have made a game in OpenGL, and also have added a menu item. when I right click on the OpenGL Screen, the menu item is displayed and I have added an option "Reset Game" in it. How Can I clear all the variables involved in the game by clicking on this (Any clear or flush function?).
Here is my code
glutCreateMenu(menu);
glutAddMenuEntry("Reset Game", 1);
void menu(int item)
{
switch (item)
{
case 1:
{
//Adding a function here to clear all the variables
}
break;
}
}
You just need to code up the routine to reset all your variables to their default values.
void Reset()
{
score = 0;
lives = 3;
// etc.
}
OpenGL doesn't know what these are so you have to do it yourself.

Android menuItem act strange?

I belive my question is kinda simple for most experienced Android developers but not for me!
I am trying to set the name in a menuItem and make the text WHITE colored. First of all the text gets displayed only if I klick on the menuItem, or rather when I click on the menuItem the text turns white and is readable. What I dont know is if the text gets displayed only when I click on the menuItem or if it for some reason changes color to WHITE when clicked so I am able to see it? Any useful help how I can make the text white and visible all the time in the menuItem?
item.setTitle(this.task.getName()); is supposed to be White and visible all the time in the menuItem!. Thx alot!
#Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate( R.menu.show_task_feedback_menu, menu );
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch ( item.getItemId() )
{
case R.id.show_task_feedback_menu_add_feedback: item.setTitle(this.task.getName()); <------------- Here is the problem!!!!!!!!!!
this.startTaskFeedback();
return true;
default: return true;
}
}