|
|
You can delete it even if it doesn't exist. Don't worry about DeleteFile, it won't crash your program if the file doesn't exist...well maybe on 98
Chris Richardson
|
|
|
|
|
Sounds like what you really want to do is use CreateFile with CREATE_ALWAYS.
|
|
|
|
|
Whilst looking at my MFC CWnd window, I often just fiddle with the mouse wheel out of boredom.. however my window has a slider control class on it, and if I've just moved the slider then fiddling with the wheel will make it move.
I would like to put in some kind of handler for the main CWnd so that if the user clicks anywhere in the window that isn't a control, the focus is given to the window and not the control.
Which handler do I use? CWnd::OnMouseActivate() doesn't quite seem to work in the way I want...
Thanks,
____________
Smidge
|
|
|
|
|
Hmmm, by wanting to have *no* child window have focus when the user clicks in an "empty" part of the window, you'll likely confuse your users by overriding Window's standard behavior (i.e. remembering which child window has focus).
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I'm aware of what the window behaviour would be like, but this would not cause major problems..
Do you know which message I should handle? Thanks,
|
|
|
|
|
I think you'd need to handle WM_SETFOCUS and WM_LBUTTONDOWN in PreTranslateMessage() . Good luck! I'd be curious to know how it works out.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
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.
|
|
|
|