M-A's

technology blog
Showing posts with label rant. Show all posts
Showing posts with label rant. Show all posts

Friday, 10 April 2009

EMF buffer idiocracy

On Windows XP, when creating an HDC from an EMF buffer with CreateEnhMetaFile():
  • SetDCBrushColor() and SetDCPenColor() calls are not recorded. Too bad for you.
  • When using GetStockObject(), DC_BRUSH and DC_PEN are useless and will return a white pen and a black pen respectively. Just don't use them.
  • Expect no-op from ExtTextOut(..., ETO_GLYPH_INDEX, ...) if GDI32!GdiInitializeLanguagePack hasn't been called.

Thursday, 17 January 2008

Understanding vsprops files

I've began using .vsprops files (along side .vcproj files) on VS2005 SP1. I discovered that you can do something that looks like that:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" inheritedpropertysheets=".\randomprefix_$(RANDOM_ENVIRONMENT_VARIABLE).vsprops">
< /VisualStudioPropertySheet >
This is cool, you can modify which vsprops file will be inherited by an externally defined environment variable, before starting Visual Studio. Ok fine, then try further:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" inheritedpropertysheets="$(SolutionDir)..\randomdir\random_file.vsprops">
< /VisualStudioPropertySheet >
Cool again! I can use locally defined variable in Visual Studio. Ok, then let's try to do something useful:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" inheritedpropertysheets="randomprefix_$(ConfigurationName).vsprops">
< /VisualStudioPropertySheet >
It fails. :( That would have been useful: include a vsprops file named after the current configuration name (debug or release or whatever). Here a counter example:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" outputdirectory="$(SolutionDir)$(ConfigurationName)" >
< /VisualStudioPropertySheet >
Yes, that actually works. In fact, you can even set « CharacterSet="1" » in the vsprops even if the VS vsprops editor doesn't allow you to set this (the same applies to WholeProgramOptimization). So it seems like $(ConfigurationName) and $(SolutionDir) aren't defined at the same time, which is normal. The way VS looks at the project file looks like this:

  1. Initial parsing
  2. For each Configuration in Configurations
    1. Load the InheritedPropertySheets attribute
      1. Open recursively the property sheets
    2. Load the Name attribute in Configuration in the vcproj
    3. Process property sheets
    4. Process the rest of the attributes
    5. Load the rest
The thing is that you can use $(ConfigurationName) in the OutputDirectory attribute but not in the InheritedPropertySheet. Too bad, what a missed opportunity. I somewhat tried playing with UserMacro but without any success.

Disclaimer: I didn't try with VS2008.
Disclaimer: I know the blogger's editor sucks and that I couldn't write real XML. In fact, they know it too. I just wished they cared. We're just all eager to have it actually fixed.

Sunday, 13 January 2008

The undocumented frustration

I had some frustration when updating WINVER and _WIN32_WINNT from 0x501 to 0600 (okay we're late but better be late than sorry). I came across two things I'd like to document.

---

First I need to reference Nicolas Sylvain post about GENERIC_MAPPING changes to give some background. Then all I have to say is that there are other access masks that changed, but explicitly. The ones we hit were PROCESS_ALL_ACCESS and THREAD_ALL_ACCESS. They have a new bitmask. Here are the definition:
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
#define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
#else
#define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF)
#endif

#if (NTDDI_VERSION >= NTDDI_LONGHORN)
#define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
#else
#define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF)
#endif
The nice thing is that the new bitmasks are refused by Windows XP. So you need to use different flags depending on the OS, which you need to define yourself. Not great! The easiest work around is to use MAXIMUM_ALLOWED but this is not always what you want.

---

The second one is nasty. The NONCLIENTMETRICS structure's size silently changed between XP and Vista. Here is the definition:
typedef struct tagNONCLIENTMETRICSW
{
UINT cbSize;
int iBorderWidth;
int iScrollWidth;
int iScrollHeight;
int iCaptionWidth;
int iCaptionHeight;
LOGFONTW lfCaptionFont;
int iSmCaptionWidth;
int iSmCaptionHeight;
LOGFONTW lfSmCaptionFont;
int iMenuWidth;
int iMenuHeight;
LOGFONTW lfMenuFont;
LOGFONTW lfStatusFont;
LOGFONTW lfMessageFont;
#if(WINVER >= 0x0600)
int iPaddedBorderWidth;
#endif /* WINVER >= 0x0600 */
} NONCLIENTMETRICSW, *PNONCLIENTMETRICSW, FAR* LPNONCLIENTMETRICSW;

WTL 8.0 has a workaround for this
but let's face it, it looks more as a hack than anything else. It looks like the guy at Microsoft that changed the structure should have wrote a unit test...
Anything that is written that looks like this is bound to fail:
NONCLIENTMETRICS cm = { sizeof(NONCLIENTMETRICS) };
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &cm, 0);
I don't blame Microsoft for doing small errors like this. Managing an operating system is a tremendous task and we all know errors can slip through. The real problem I see is that even one year after the release, it's still not documented. Let's hope the Vista SP1 SDK will define PROCESS_ALL_ACCESS_XP, THREAD_ALL_ACCESS_XP and NONCLIENTMETRICS_v1.

Friday, 4 January 2008

Risk of using embedded MSHTML

There is always some risks involved in using third parties in UI.



This one is cute: It is the "My Web Sites on MSN" wizard that is hit by the IE ActiveX security bar. But this is really nice inside a dialog box, knowing that it is pure Microsoft code.

It is funny because it gives the feeling that it is less secure while in reality it doesn't change anything since it is simply a side-effect of using MSHTML for rendering.

Tuesday, 18 December 2007

Software Update Rant

Dear "software updater" software programmer,
  • Please don't "update" software that I haven't installed yet.
  • Please don't reinstall quicklaunch icons that I deliberately removed.
  • Please stop asking me to update, simply update. I don't care if I have the "Latest and greatest version", I just want to have my software work. Don't tell me to visit a web site to update it, I won't. (Actually I do but shhh!)
  • Please stop installing "[Insert name here] Speed Launcher", "[Insert name here] Task" or "[insert name here]UpdateSched" autoloading crap in my startup menu or even worst, in the registry; to be sure to increase the commit charge (total memory usage) of my system. A program can easily look at updating itself when it is actually started. If it is never started, I don't mind it to be never updated.
  • Please don't write updater that fails. (It happens on my system, no names here) I'm not even talking about bad software, simply bad updaters. If you're too dumb replace some files, get another job.
  • No, I won't reboot my system to install a media player. The next time I'll reboot will probably be because of a corporate enforced software BSOD'ing my system.
I know doing an installer is hard. I know the amount of work is high. Then, why don't you just do less during updates?


Here's a few examples:

#1 Apple Software "Update"

They should have called it "Apple installer". Yes I have Safari Beta and QuickTime installed. No I don't have iTunes nor I want that "update" installed on my computer.

Apple folks, please, look to see if the software is actually installed before "updating" it.

#2
Also, Apple folks, don't add back the quicklaunch icons on updates. If I removed them, I probably don't want them back. This also applies to Acrobat Reader updates and Office 2003 service packs.

#3
Auto start crap. Sun's Java and QuickTime are notorious to add their entries back in the registry on each update. Stop doing that!

Tuesday, 7 August 2007

Save the earth, kill your AV

Can you imagine how much power would be saved if everyone would uninstall their AV? My personal computers have been running AV-virgin for more than a decade now without an itch. What a relief!

Friday, 20 July 2007

Logitech dinovo edge pairing?

I tried to pair a Logitech dinovo edge with a Dell axim x51v with no luck. In fact, they paired correctly but nothing that I type in gets to the x51. That's pretty sad since the x51v is discontinued, it will never work. If anyone got both to work together, please contact me.

I got it to work with my lenovo T60, I had a hard time though. It seems like you have to type the numbers and press enter FAST, otherwise you won't hear the congratulation beep.
The included dongle works well too. It's just not as useful for portable devices. :)

The upper right Windows key starts Winamp, that's nice. :) The missing "application" (or if you prefer "context menu") key is really bothersome.

[Update 2007-07-26] To pair with the WIDCOMM Bluetooth stack, I had to update to version 5.1.0.3600 (For my W2K3 x64). Before the upgrade, I entered the keypass and nothing happened. On Vista, I installed the 6.0.1.5100 driver and I had no problem. To update the stack, you have to have a device that the manufacturer paid for support. That's pretty sad, given the poor support you have with Windows.

Hint: To backup your driver, look in your %TEMP% directory for a directory created at the moment your started the updater, during installation. Copy it in a safe place just in case and/or for analysis.

Thursday, 26 April 2007

Random Rant about Canon (again)

I wanted to scan some documents in MP Navigator 3.0 and generate a PDF. I typed a longer than usual name for the file name. Here's the message box I received:

---------------------------
MP Navigator
---------------------------
Le nom de fichier est trop long.La longueur maximale est de 32 caractères d’un octet.
---------------------------
OK
---------------------------

It roughly means: « The file name is too long. The maximum length is 32 characters of one byte. » (!?!)

Hummm welcome in 2007!

And I still haven't talked about my problem with the intelligent chipset on the color inkjet cartridge that stops working and that force you to buy a new cartridge even if yours is still almost full!

And forget about Canon's support. I tried. The only thing I received from them is *2* surveys to know if I'd buy Canon branded hardware again.