|
I dont want to have duplicate entries, but I dont want any sorting either. I was using a set but it wont work for me since it sorts. A vector doesnt sort, but allows duplicates. Is there a container that will neither allow duplicates, nor sort?
Appreciate your help,
ns
|
|
|
|
|
You could use a set and specify your own sorting function, one that does nothing.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
specify your own sorting function, one that does nothing.
Did you actually tried this one yourself?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
No, and after thinking about it on the bus, I decided it would not work.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
hash_set
|
|
|
|
|
You could implement a two-step insertion with find() and insert() on a vector. In other words, you search for an item before inserting a new item.
Kuphryn
|
|
|
|
|
many thanks for the suggestions - I now have so many options!
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
Is there a container that will neither allow duplicates, nor sort?
Isn't that map ?
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I've used map just for sorting, so not map.
Appreciate your help,
ns
|
|
|
|
|
hash_set is what you want. Unfortunately, this container is not standard. I think STLPort has it, though.
Check here[^] for info about hash_set s.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
VC7 has it though.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Oh, didn't know about it... After having a look at the docs, seems like this hash_set does not serve the needs of ns, since it requires that the elements be ordered --SGI's hash_set , on the other hand, only demands an equality predicate (with the disadvantage or poorer performance, I guess).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi!
I want to change the caption of my property page (CPropertyPage ) with setting the pszTitle member of the PROPSHEETPAGE struct.
It works fine when I am init the pszTitle member with something like _T("Hi!") , but when I am init the member with a CString object, in the tab control of my property sheet (CPropertySheet ) some stupid characters are displayed.
This code works fine:
m_psp.dwFlags |= PSP_USETITLE;
m_psp.pszTitle = _T("Hi!");
But this code will display some stupid characters:
CString strTitle(_T("Hi!"));
m_psp.dwFlags |= PSP_USETITLE;
m_psp.pszTitle = strTitle;
I think the problem is that the system is working with UNICODE and this member (pszTitle ) exspects a LPCSTR and no LPCTSTR .
But why does the first code sequenz woking and the second not?
And how can I fix that?
(Working with embedded Visual C++ 3.0 + MFC)
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
It's nothing to do with Unicode. Your CString object will get deleted at the end of the current method, but the title is not displayed until later on, at which point it has a bad pointer. If you want to use a CString, make it a member variable of the property page.
Dave
|
|
|
|
|
It's not the problem of UNICODE, but your confusion on character string and character pointer. Look at your code:
CString strTitle(_T("Hi!"));<br />
m_psp.pszTitle = strTitle;
Above code is wrong, wrong and, WRONG!
I cannot remember how many times it's been emphasized that you do NOT copy string like that, instead, you should do it the correct way:
free((void*)m_psp.pszTitle);<br />
m_psp.pszTitle = _tcsdup(_T("Hi!"));
Then your problem should be gone.
|
|
|
|
|
Hi Bin! Thanks for your answer!
But I have a second question.
When I do it you told me, I have to free the pszTitle at the end, or???
...
free((void*)m_psp.pszTitle);
m_psp.pszTitle = _tcsdup(_T("Hi!"));
...
...
...
free((void*)m_psp.pszTitle);
Or does the CPropertyPage class that automatic in the destructor???
Thanks!
Daniel
|
|
|
|
|
CPropertyPage will handle that in its destructor.
|
|
|
|
|
The MSDN says:
"Calling CreateDIBitmap with fdwInit as CBM_INIT is equivalent to calling the CreateCompatibleBitmap function to create a DDB in the format of the device and then calling the SetDIBits function to translate the DIB bits to the DDB."
So, should I interpret this to mean that CreateDIBitmap actually calls SetDIBits, or just that the results are the same? I ask, because I'm trying to find out if a DC can support CreateDIBitmap or not. Because of the quoted sentence, I assumed that I should check GetDeviceCaps for RC_DI_BITMAP. But, there's a situation where GetDevCaps says RC_DI_BITMAP isn't supported, but CreateDIBitmap still works.
Anyone know anything about this? I hate programming.
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Hi all, it's me again. After some searching I found a function that does what I need, converts a ddb to a dib. Problem is it doesn't work and I don't know why. I'll post my trouble code and hopefully someone can send me in the right direction. Thanks in advance.
Mike.
<br />
<br />
HPALETTE hPal;<br />
CDC* pDC;<br />
<br />
ASSERT( bitmap.GetSafeHandle() );<br />
<br />
if( dwCompression == BI_BITFIELDS )<br />
return NULL;<br />
<br />
hPal = (HPALETTE) pPal->GetSafeHandle();<br />
if (hPal==NULL)<br />
hPal = (HPALETTE) GetStockObject(DEFAULT_PALETTE);<br />
<br />
<br />
int f = ::GetLastError();<br />
<br />
<br />
bitmap.GetObject(sizeof(bm),(LPSTR)&bm);<br />
<br />
bi.biSize = sizeof(BITMAPINFOHEADER);<br />
bi.biWidth = bm.bmWidth;<br />
bi.biHeight = bm.bmHeight;<br />
bi.biPlanes = 1;<br />
bi.biBitCount = bm.bmPlanes * bm.bmBitsPixel;<br />
bi.biCompression = dwCompression;<br />
bi.biSizeImage = 0;<br />
bi.biXPelsPerMeter = 0;<br />
bi.biYPelsPerMeter = 0;<br />
bi.biClrUsed = 0;<br />
bi.biClrImportant = 0;<br />
<br />
int nColors = (1 << bi.biBitCount);<br />
if( nColors > 256 ) <br />
nColors = 0;<br />
dwLen = bi.biSize + nColors * sizeof(RGBQUAD);<br />
<br />
<br />
hDC = (HDC)GetDC();<br />
<br />
<br />
DWORD wx = ::GetDeviceCaps(hDC, RASTERCAPS);<br />
<br />
<br />
TRACE("Raster capabilities : %08X\n",wx);<br />
<br />
<br />
hPal = SelectPalette(hDC,hPal,FALSE);<br />
<br />
<br />
f = ::GetLastError();<br />
<br />
<br />
RealizePalette(hDC);<br />
|
|
|
|
|
Mike Savoie wrote:
// We need a device context to get the DIB from
hDC = (HDC)GetDC();
so, you're calling this from a window of some kind?
have you tried ::GetDC(NULL) instead?
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Hi, thanks for the quick response. No, it's not called from a window. That's why I'm having such a hard time. All the examples I've found display to windows. The way this program works is that once you click the OK button. A pre-generated Large bmp file is created. Then this app is called to crop part of the original file, and save to a new file. All the bitmap manipulation happens unseen in the background, and the file is then passed to a different function for printing. That's why I'm so confused. Like I said every example uses windows, or resource files. Neither of which I have. I hope this makes sense, hehe I've been hacking at this for a couple weeks now and it's turning me into a babbling buffoon! Again thanks for the quick help.
PS- CWnd::GetDC(); //error C2660: 'GetDC' : function does not take 1 parameters
|
|
|
|
|
Mike Savoie wrote:
PS- CWnd::GetDC(); //error C2660: 'GetDC' : function does not take 1 parameters
are you trying ::GetDC(NULL) ? (ie. don't try CWnd::GetDC(NULL) )
-c
Alcohol is the anesthesia by which we endure the operation of life.
-- George Bernard Shaw
|
|
|
|
|
Dude, if I knew where you were I'd kiss ya!! (umm, well maybe buy ya a beer) haha yeah ::GetDC(NULL); worked. A few more bugs and it'll be finished. Thanks again.
|
|
|
|
|
Hi!
I want to read some information stored in a file.
I mean such as Comment, Title, Author or Keywords.
Are there some APIs that do that ... or must I access the file directly?
Maybe somebody have some code example for me?
Furthermore I want to write (change) this information...
Thanks
Martin
|
|
|
|
|