|
hi,
Can I use set_intersection function to find out the itersection of containers which contains user defined type objects or it works only with standard datatypes?
Thanks in advance,
Regards
Abhi Lahare
|
|
|
|
|
Abhi Lahare wrote:
Can I use set_intersection function to find out the itersection of containers which contains user defined type objects
Yes you can.
For that you have create your binary predicate function and use it as a last parameter of the set_intersection function.
for e.g
bool mod_lesser (int elem1, int elem2 )<br />
{<br />
if ( elem1 < 0 ) <br />
elem1 = - elem1;<br />
if ( elem2 < 0 ) <br />
elem2 = - elem2;<br />
return elem1 < elem2;<br />
}
you may change int to UDT.
Abhi Lahare wrote: it works only with standard datatypes?
Not neccessary,It should works for UDT also.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
In context to Laxman's reply
When you perform operations on User Defined Types(UDT) you should tell the "-" operator (in this case), how to work with UDT's. (Apply Overriding concepts)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: (Apply Overriding concepts)
Not Overriding Overloading
You may overload the logical operaters like <, > and Mathmatical operators like - for Binary predicate conditional checking. so that the program is generalised.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi all,
I have a CListCtrl, which has an attached ImageList.
I set the image for an item and the image is displayed correctly. Very Well.
Now I change my project settings to releasemode, compile my application and now something strange happens:
In my ListCtrl only the first image in my ImageList is displayed, no matter, what index I specify. It works perfectly in debug-mode, but does not work in release-mode. So I can not singlestep through my application to find the error.
Since it works in debug-mode, I think, my sourcecode is correct. I copied it from a MFC book.
Can anybody tell me, where to look for differences between debug and release as far as imagelists are concerned?
Juergen
|
|
|
|
|
Could you post code snipet so that we can trace the problem..??
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Ok, here is what my code looks like:
CImageList StatusImage is a member-variable in my class.
OnInitDialog()
{
StatusImage.Create(4,12,ILC_COLOR4,5,1);
AddBitmapToImageList(StatusImage,IDB_STATUS_PLAN);
AddBitmapToImageList(StatusImage,IDB_STATUS_GO);
AddBitmapToImageList(StatusImage,IDB_STATUS_CRITICAL);
AddBitmapToImageList(StatusImage,IDB_STATUS_FINISH);
AddBitmapToImageList(StatusImage,IDB_STATUS_STOP);
}
BOOL AddBitmapToImageList(CImageList &imageList, UINT nResourceID)
{
BOOL bReturn;
CBitmap bmp;
bReturn=bmp.LoadBitmap(nResourceID);
if(bReturn)
{
bReturn=imageList.Add(&bmp,RGB(255,255,255));
bmp.DeleteObject();
}
return bReturn;
}
When I access the ImageList in debug-mode, the correct image is selected. When I access the list in release-mode, only the first bitmap is displayed.
I even debugged the release-version, but I found no errors. Everything seems to work fine. But the wrong image is displayed.
Juergen
|
|
|
|
|
e-DJ wrote: So I can not singlestep through my application to find the error.
u can do debuging in a release version too
set the following option in project settings
take project->Setting
now take c++ tab
in the optimization combobox select Disabled
in the Debug info combo select "Program database for edit and continue"
now take the Link tab
Tick the check box "Generate debug info"
now rebuild the project
nave
|
|
|
|
|
Hi
I have a property sheet with tabbed property pages
When the property sheet is opened up, depending on some user settings some pages
are not displayed
When the property sheet is created, i add all the pages
the in OnInitDaig, i remove the pages i dont need with
RemovePage(&m_Page1);
this works fine, if i only open the sheet up once
If i try to open again, i get an expection error on RemovePage line, it seems the second time around
the page doesnt exist, how can i check so that the second time the sheet is opened up it doesnt try to removepage which has already been removed
anyone any ideas
thanks
si
|
|
|
|
|
si_69 wrote: RemovePage(&m_Page1);
if(m_Page1)<br />
{<br />
RemovePage(&m_Page1);<br />
m_Page1=0;<br />
}<br />
and check m_Page1==0 before RemovePage API
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
A_Laxmanm_Page1=0;
i think m_Page1 is an object of class derived from CPropertyPage
in that case how can we assign like this?
nave
|
|
|
|
|
Naveen R wrote: in that case how can we assign like this?
Yeh, you are right..we can't
I think we can solve the problem by maintaining the flags for pages.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
si_69 wrote: the in OnInitDaig
Where did u wrote the OnInitDialog()? .I mean in which dialog?
couldn't u keep some flags?
nave
|
|
|
|
|
si_69 wrote: When the property sheet is created, i add all the pages
the in OnInitDaig, i remove the pages i dont need with
RemovePage(&m_Page1);
I'm curious why you don't just call AddPage() for the pages you want added, rather than add them all and remove the unwanted ones.
si_69 wrote: this works fine, if i only open the sheet up once
If i try to open again,
Does the sheet get closed or hidden? How does it get re-opened?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Trying to compare a date to see if it is earlier of later.
My CompareFileTime function returns junk.. 0xffffff.
FILETIME Time;
SYSTEMTIME stime;
FILETIME ftime;
GetSystemTime(&stime);
BOOL bSys = SystemTimeToFileTime(&stime, &ftime);
LONG lfiletime;
FileTimeToLocalFileTime(&FindFileData.ftCreationTime,&Time);
//Time = &FindFileData.ftCreationTime;
lfiletime = CompareFileTime(&Time, &ftime);
|
|
|
|
|
0xFFFFFFFF is the same as -1 , and -1 is a valid return value from that function. Are you sure you are getting the wrong result?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Well, i check for -1, 1 or 1. In which case my algorithm totally misses the result. How would i catch it, would i have to check for 0Xffffff? Or does the computer know to equate that to -1?
|
|
|
|
|
0Xffffff is the hexadecimal representation of -1. So you can simply check for -1, this is exactly the same.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Post the rest of the code that evaluates the result, as well as a step-by-step of what you see in the debugger as those lines are executed.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Did you saw MSDN for CompareFileTime
In MSDN
"Return Values
–1 indicates that the first file time is less than the second file time. 0 indicates that the first file time is equal to the second file time. +1 indicates that the first file time is greater than the second file time.
"
whitesky
|
|
|
|
|
I am displayiing a Dialog over a Dialog using
MyDlg->DispDialog.DoModal();
only the second Dialog (DispDialog) is displayed. How i can display both the Dialog same time. The Size of second Dialog is more than first Dialog.
|
|
|
|
|
If you only need to have your first dialog visible (without having to inject inputs), then you can simply use MoveWindow for the second dialog.
If it needs to receive user inputs, then you need to use modeless dialogs. You can have a look at this tutorial[^]
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
anilksingh wrote: I am displayiing a Dialog over a Dialog using
MyDlg->DispDialog.DoModal();
only the second Dialog (DispDialog) is displayed. How i can display both the Dialog same time. The Size of second Dialog is more than first Dialog.
Create Modeless dialogs
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Are you doing this on the click of OK button?
What happens to the first dialog? Does the dialog close or something else?
If you want both dialogs to show and respond to user inputs create Modeless dialog as A_Laxman and Cedric suggests.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 8:19 Wednesday 14th June, 2006
|
|
|
|
|
try like this
if( MyDlg->DispDialog.m_hWnd == 0 )
MyDlg->DispDialog.Create( ... )
MyDlg->DispDialog.ShowWindow( SW_SHOW );
MyDlg->DispDialog.DoModal();
nave
|
|
|
|