I need Icon.FromHandle() method in Compact Framework but the FromHandle() method is not supported by the CF 1.0! So I searched a while and found an article at OpenNETCF.org[^] which did it: The code worked fine with PPC2002 and WM2003 but not works under WM2005... There seems to be a problem with the palette colors... The icon can be displayed but with wrong colors or transparency is a problem. 1. The SDF uses CreateDIBSection() with a BITMAPINFOHEADER parameter but MSDN and function prototype says that it is a BITMAPINFO. 2. P/invoked BITMAPINFOHEADER is missing biClrUsed and biClrImportant 3. Correcting issues 1+2 does not solve the problem. Very strange: If the application was launched using the debugger it works (icon displayed correctly). If launched without debugging (from within VS) the colors are not correct (black instead of transparency) The debugger seems to initialize something wich causes this behaviour but of course the app should be able to display the icons correctly without a debugger ;-) Thx for some help!
hfrmobile
Posts
-
How to Create icon Object from Stream ? -
about "delete"Because for one thing, your example is not exception-safe. If in the "..." code an exception is thrown, you'll end up with a memory leak. Since the topic has the subject "about delete" I only mention that there is no difference between delete and delete[]. You may assume that "..." stands for the following:
try { // do something meaningful } catch (...) { }
Of course you can usefinally
to free memory... :rose: Or you just use a wrapper class which ctor does this for you (so you can't forget)... Or use managed C++ :laugh: -
about "delete"I allways used
delete
regardless if usednew
ornew[]
...it worked fine (and I see no reason why it should not...)byte buffer[4] = new byte[4]; // 4 bytes DWORD dw4Bytes = new DWORD[1]; // 4 bytes ... delete buffer; // releases 4 bytes delete dw4Bytes; // releases 4 bytes
-
How to chage attributes for a directory?FYI: Conclusion - setting file attributes for directories I tried something and here are the results:
CeGetFileAttributes()
Worked for all devices.CeSetFileAttributes()
Not worked on a PPC2002 device (Pocket PC) Worked on a WM2003 device (Smartphone) So it seems that this is only supported for devices using WM2003 or higner... -
How to chage attributes for a directory?Very interesting... thx! This code (see comments) demonstrates what happens:
CeRapiInit(); // "\\CF-Card\\Temp" // "\\SD-MMCard\\Temp" // "\\Temp\\Test" CString strFileName = "\\SD-MMCard\\Temp"; wchar_t wcFileName[256]; mbstowcs(wcFileName, strFileName, strFileName.GetLength()+1); DWORD dwAttributes = CeGetFileAttributes(wcFileName); // works always HRESULT hr = CeGetLastError(); dwAttributes |= FILE_ATTRIBUTE_READONLY; // hr = 0x00000002 "The system cannot find the file specified." if dir is in RAM // hr = 0x00000005 "Access is denied." if dir is on storage card // this problems only occur using RAPI CeSetFileAttributes(wcFileName, dwAttributes); hr = CeGetLastError(); CeRapiUninit();
RAM: "The system cannot find the file specified." (ok, since MSDN says it is not supported Storage Cards: "Access is denied." (also not supported?:(( ) -
How to chage attributes for a directory?I assume you mean ROM, not RAM? Of course I do not try to alter attributes of a directory which is located in ROM. In this case I'll expect a "access denied" error... I'd like to change directory's attributes which are located in RAM or on a storage card. I can delete or rename the directories but I cannot change the "r" or "h" attribute...
-
How to chage attributes for a directory?Hi thanks for your reply! Sorry, I was a bit inaccurately... I am using RAPI version of SetFileAttributes() --> CeSetFileAttributes() because I need to do this on a remote device (on a Pocket PC running Windows CE) It seems that there is a difference between SetFileAttributes() and CeSetFileAttributes(). CeSetFileAttributes() works fine for files but not for directories. The only thing I have found about this issue is that the .NET Compact Framework does not support changing attributes on directories... (files are supported). Since the project is written in VC++ this should not matter... CeSetFileAttributes() always returns false and CeGetLastError() returns 0x2 (file not found...) Any idea why CeSetFileAttributes() does not work for directories? thx :doh:
-
How to chage attributes for a directory?Changing file attributes for a file is no problem (e.g. using the SetFileAttributes() function). Is there an equivalent for doing this for a directory? Thanks in advance, hfr :sigh: PS: if using SetFileAttributes() for a directory I get a HRESULT of 2 which means: file not found