|
You get an error here, because you can not use '+' with an iterator.
If you want to assign the value of the next object to the current one, I would do:
{
RectList::reverse_iterator next = ri++;
*ri = *next;
}
If you want to access an iterator that is more than one step away, you can use std::advance() to step the iterator many steps.
If you intended to add a value to the value referenced by ri , you need to write:
*ri = *ri + value;
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Thanks for your reply.
Your code does the opposite of what I wanted. I would change it to:
{
RectList::reverse_iterator next = ri;
*ri = *(++next);
} Thanks anyway.
Hosam Aly Mahmoud
|
|
|
|
|
Hi,
how can I achieve this behaviour? I have an SDI-Application with CScrollView-derived View-class and I want to show the user a CStatic-derived control which shows a statistic. But this statistic should be permanent at the same place even if the user scrolls.
I prepared the control to be a Child from my CMainframe-class but then it gets overdrawn by the View. Then I wrote blah->Invalidate() in the OnDraw of the View to get the control to be drawn AFTER the View. But now I have the problem that there are "visual copies" (silly expression but I hope you understand what I mean...) of the control when I scroll...
has anybody an idea how to solve this problem?
(sorry for my English, I'm German...)
|
|
|
|
|
C will allow me to do this
char *names[]={"aaa","bbb","ccc"};
but what this doesnt work for ints
int *array[]={{1,2,3},{4,5,6}};
I need to get this clarified !
|
|
|
|
|
dear all,
this may seem as a weird problem but still i think its worth askin' in this forum of TOPGUN programmers. is there any way to create controls diagonally or at any given angle. Eg a button inclined at say 45 degrees wrt to the dialog.
i just wondered if this can be done in windows or any other programming environment.
regards,
rIsHaBh
|
|
|
|
|
I have never tried it, but may be using regions will solve your problem.
Hosam Aly Mahmoud
|
|
|
|
|
It is possible to output text at any angle. None of the existing win32 controls will allow you to edit text at an angle.
look thru MSDN for
Rotating Lines of Text
You can rotate TrueType fonts at any angle. This is useful for labeling charts and other illustrations. The following example rotates a string in 10-degree increments around the center of the client area by changing the value of the lfEscapement and lfOrientation members of the LOGFONT structure used to create the font.
On top of this you would need to draw a rotated control on a transparent window and deal with hit testing etc and passing mouse events to underlying controls 'shadowed' by the transparent window (which would still have normal horizontal and vertical orientation).
All in all not work the effort
|
|
|
|
|
it comes around to the same question....how do i create rotated control?
rIsHaBh
|
|
|
|
|
dear all,
i'm creating controls at runtime in my dlg based mfc application. the number of controls is unknown to me. the problem is i'm allocating memory to the controls in a function....so i've no idea when and where to free the memory coz the control variables are decalared and accessible within the function only. i've attached a snippet of my code :- plz. tell me how to make the code cleaner and get rid of memory leaks
<br />
void CRms::CreateControls()<br />
{<br />
int iCtr;<br />
CRect rcLabel, rcDtc; <br />
COleDateTime dt;<br />
dt.SetTime(0,0,0);<br />
for (iCtr = 0 ; iCtr < iMaxEmails; iCtr++)<br />
{<br />
CString sCtr, sLabel;<br />
CStatic *pText = new CStatic();<br />
CDateTimeCtrl *pTime = new CDateTimeCtrl();<br />
GetLabelRect(iCtr, rcLabel);<br />
GetDTCRect(iCtr, rcDtc);<br />
m_arrayStatic.Add(pText);<br />
m_arrayDTC.Add(pTime);<br />
sCtr.Format("%d", iCtr + 1);<br />
sLabel = LABEL_CAPTION + sCtr;<br />
pText->Create(sLabel, WS_VISIBLE, rcLabel, this, ID_LABEL + iCtr);<br />
<br />
pTime->Create(DTS_TIMEFORMAT |WS_VISIBLE , rcDtc, this, ID_DTC + iCtr);<br />
pTime->SetFormat("HH:mm");<br />
pTime->SetTime(dt);<br />
bControlsLoaded = true;<br />
}<br />
}<br />
thanx and regards
rIsHaBh
|
|
|
|
|
How about adding the "newed" Pointers to a list.. and in the PostNCDestroy - Handler (maybe OnDestroy would work too) you are deleting all the items in the list ? (or when you add new Controls and don't need the old ones lurking around)
in your header file:
#include<vector>
std::vector<CDateTimeCtrl*> controlList;
in your implementation file:
CreateControls:
after CDateTimeCtrl *pTime = new CDateTimeCtrl();
controlList.push_back (pTime);
PostNCDestroy (or OnDestroy)
for (std::vector<CDateTimeCtrl*>::iterator i = controlList.begin(); i != controlList.end(); ++i)
{
delete *i;
}
Not the most elegant solution, but it should work.
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
NOPES! didn't work
thnx anyways
rIsHaBh
|
|
|
|
|
Could you use an autopointer (like the shared_ptr from www.boost.org[^]?
An autopointer is a class that behaves like a pointer, but it calls delete on the object it points to when it goes out of scope.
With the boost autopointer, you can even use the STL vector or list , something you should never try with the std::autopointer that comes with the library!
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
well i want to free memory only when my dlg is about 2 be destroyed.....cpz as soon as i use delete....the controls are gone....so i don't think this wud work......but still i feel there must be some way to do this cleanly
rIsHaBh
|
|
|
|
|
You can very well change the scope of auto_ptr<> objects. So try that way...
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Create the maximum number of controls at design time. Show/hide them accordingly at run time. A much cleaner solution.
Otherwise, you'll need the following when the dialog is being destroyed:
CDateTimeCtrl *pTime;
CStatic *pText;
for (int x = 0; x < iMaxEmails; x++)
{
pText = m_arrayStatic.GetAt(x);
delete pText;
pTime = m_arrayDTC.GetAt(x);
delete pTime;
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
but these 2 variables are different (wrt scope) then the variables which i've already declared in CreateControls function...so those variables would still have memory allocated......but if i use ur logic...wud those predefined variables be deallocated?
rIsHaBh
|
|
|
|
|
Once memory is allocated, it matters not what variable is used to access it. For example:
int *a = new int;
array.Add(a);
int *y;
y = array.Get();
delete y;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
thanx a ton David
rIsHaBh
|
|
|
|
|
Hi,
To support both mpeg files and wmv files, I had just updated and embeded WMP Player 6 to 9 ActiveX control in my c++ application.
Everything went well with .mpg file, like frame step forward and backward. Also image kept moving while dragging a slider ctrl.
But that didn't work with .wmv file!
As described in WMPlayer SDK document, I couldn't find "m_MP.GetControls().step()" function in CWMPPlayer4 class.I find newly WM Player 9.0 has this funcion: Enhanced->Play speed control: there are 2 small button which can step forward and backward.
I dragged the slider ctrl but the image didn't refresh. After I dragged to a new position and excuted play() function, it moved again.
My code is like following:
void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
double dblPosi;
...
if (MPState == MP_PLAYING) g_pMediaPlayer->GetControls().pause();
m_nTimeSlider = m_TimeSlider.GetPos();
dblPosi = g_pMediaPlayer->GetControls().SetCurrentPosition((double)m_nTimeSlider);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CMyDlg::OnStep()
{
if (MPState == MP_PLAYING) g_pMediaPlayer->GetControls().pause();
// forward m_nOneFrame = 0.04 (PAL)
g_pMediaPlayer->GetControls().SetCurrentPosition((double)m_nOneFrame);
}
Anybody who know that plz give me some suggestion?
Thanks a lot.
No pains, no gains.
|
|
|
|
|
I had a small mistake in the above post.
void CMyDlg::OnStep()
{
if (MPState == MP_PLAYING) g_pMediaPlayer->GetControls().pause();
// forward m_nOneFrame = 0.04 (PAL)
g_pMediaPlayer->GetControls().SetCurrentPosition((double)m_nOneFrame);
}
should be:
void CMyDlg::OnStep()
{
...
if (MPState == MP_PLAYING) g_pMediaPlayer->GetControls().pause();
// forward m_nOneFrame = 0.04 (PAL)
g_pMediaPlayer->GetControls().SetCurrentPosition((double)(m_nCurrPos + m_nOneFrame));
}
No pains, no gains.
|
|
|
|
|
Hi,
Is there anything diferent in working with toolbars in dialogs? I am trying to put a toolbar in a dialog and it doesn't appear although I didn't get any error. The code is
if (!m_wndLowerButtons.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndLowerButtons.LoadToolBar(IDR_LOWER))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
See this URL:
http://www.codeguru.com/dialog/toolbars.shtml
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Thank you
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
hello all
please help me..
it s very urgent.
I have to develop a Windows Explorer like
application using dialog boxes only.
Is it possible to do that without Doc/view ?
If so how?
code samples will be great helpful at this
critical time.
if we have to develop in Doc/View ..how to do ?
But i fi get Dialog based code sample..
it is more helpful to me.
kumaru
"They can because they think they can" - Voltaire
|
|
|
|
|
kumaru_san wrote:
I have to develop a Windows Explorer like
application using dialog boxes only.
Is it possible to do that without Doc/view ?
If so how?
Yes, one of the first questions that AppWizard asks is whether you want a dialog-based application or not. After AppWizard creates the application, simply add the necessary controls to the dialog template.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|