November, 2008

Larry Osterman's WebLog

Confessions of an Old Fogey
  • Larry Osterman's WebLog

    The ducking whitepaper is now online

    • 12 Comments

    I just got an email indicating that the powers that be have just published the Ducking (automatic volume adjustment for communications applications) whitepaper that I mentioned during my PDC Talk.    It's the whitepaper entitled "Stream Attenuation in Windows 7".  This is a preliminary version of the final ducking documentation and should be good enough to help anyone wanting to work with the ducking feature get started.  It also covers some of the subtleties that I wasn’t able to cover in my talk.

    Enjoy!

     

    EDIT: Added which paper it was and a definition of "Ducking".

     

  • Larry Osterman's WebLog

    I get more spam :)

    • 11 Comments

    I just received this phishing letter, I liked it simply because it was so remarkably brazen:

    --

    Dear Webmail User,

    This message was sent automatically by a program on Webmail which periodically checks the size of inbox, where new messages are received. The program is run weekly to ensure no one's inbox grows too large. If your inbox becomes too large, you will be unable to receive new email.

    Just before this message was sent, you had 18 Megabytes (MB) or more of messages stored in your inbox on Webmail. To help us re-set your SPACE on our database prior to maintain our INBOX, you must reply

    to this e-mail and enter your Current UserID: ( ) and

    Password ( ) Select server ( ) if any

    You will continue to receive this warning message periodically if your

    inbox size continues to be between 18 and 20 MB. If your inbox size grows

    to 20 MB, then a program on Webmail will move your oldest

    email to a folder in your home directory to ensure that you will

    continue to be able to receive incoming email. You will be notified by email

    that this has taken place. If your inbox grows to 25 MB, you will be unable to

    receive new email as it will be returned to the sender.After you read a

    message, it is best to REPLY and SAVE it to another folder.

    Thank you for your cooperation.

    Webmail Help Desk

    ---------------------------------------------------------------------------

    3webXS HiSpeed Dial-up...surf up to 5x faster than regular dial-up alone...

    just $14.90/mo...visit www.get3web.com for details

     

    The email was in plain text from “Webmail Service Support [general@3web.net]” (I don’t feel bad about including their real email address on a post on the web, after all they deserve to get spam, right?

     

    As I said, I thought it was remarkably brazen and very low budget.  Why bother trying to set up a domain when you can get the victim to send you their credentials by email :).

  • Larry Osterman's WebLog

    What’s wrong with this code, part 25 – the answers

    • 3 Comments

    Yesterday I described a very real bug in some of the Windows UI.

    CControlLayout::CControlLayout(const HWND hWndControl, const HWND hWndDlg)
        : m_hWnd(hWndControl)
        , m_hWndDlg(hWndDlg)
    {
        // Get the parent (dialog) rect, and the control rect
        ::GetClientRect(m_hWndDlg, &m_rcRefDlg);
        ::GetWindowRect(m_hWnd, &m_rcRef);
        ScreenToClientRect(hWndDlg, m_rcRef);
    }
    void ScreenToClientRect(/* [in] */ const HWND hWndClient,                         /* [in/out] */ RECT &rcInOut)
    {
        CPoint ptTopLeft(rcInOut.left, rcInOut.top); 
        CPoint ptBottomRight(rcInOut.right, rcInOut.bottom); 
        ::ScreenToClient(hWndClient, &ptTopLeft); 
        ::ScreenToClient(hWndClient, &ptBottomRight); 
        rcInOut.left = ptTopLeft.x; 
        rcInOut.top = ptTopLeft.y; 
        rcInOut.right = ptBottomRight.x; 
        rcInOut.bottom = ptBottomRight.y;
    }

    And as David Gladfelter pointed out, the root cause of the problem is that the routine calls ScreenToClient.  This works just fine when you’re running on Left-to-Right builds of Windows, but on Right-to-Left languages (Arabic, Hebrew, etc), this code sets the rcInOut.left to the wrong location.

    It turns out that MSDN has a warning that is explicitly about this kind of problem:

    For example, applications often use code similar to the following to position a control in a window:

    Copy Code

    // DO NOT USE THIS IF APPLICATION MIRRORS THE WINDOW
    
    // get coordinates of the window in screen coordinates
    GetWindowRect(hControl, (LPRECT) &rControlRect);  
    
    // map screen coordinates to client coordinates in dialog
    ScreenToClient(hDialog, (LPPOINT) &rControlRect.left); 
    ScreenToClient(hDialog, (LPPOINT) &rControlRect.right);

    This causes problems in mirroring because the left edge of the rectangle becomes the right edge in a mirrored window, and vice versa. To avoid this problem, replace the ScreenToClient calls with a call to MapWindowPoints as follows:

    Copy Code

    // USE THIS FOR MIRRORING
    
    GetWindowRect(hControl, (LPRECT) &rControlRect);
    MapWindowPoints(NULL, hDialog, (LPPOINT) &rControlRect, 2)

    It turns out that this is explicitly the mistake that was made in the code.  The good news is that the “Use this for mirroring” code listed in the article is exactly the fix necessary to solve this problem.

     

    As I mentioned, David Gladfelter was the first person to pick up the problem, kudos to him!

  • Larry Osterman's WebLog

    What’s wrong with this code, part 25

    • 12 Comments

    Wow, 25 already.

    This one’s pretty straightforward.  Once again, it’s a UI issue, since I’ve been spending most of my time doing UI lately.

    In this particular case, the code comes from the constructor for an auto-layout class that is used internally in one of our tools.  It saves away window handles for a control and the dialog which holds the control, then saves the size of the dialog and relative location of the control within that dialog.  There’s other code that handles resizing and adjusting the layout of the control when the dialog is resized. 

    CControlLayout::CControlLayout(const HWND hWndControl, const HWND hWndDlg)
        : m_hWnd(hWndControl)
        , m_hWndDlg(hWndDlg)
    {
        // Get the parent (dialog) rect, and the control rect
        ::GetClientRect(m_hWndDlg, &m_rcRefDlg);
        ::GetWindowRect(m_hWnd, &m_rcRef);
        ScreenToClientRect(hWndDlg, m_rcRef);
    }
    void ScreenToClientRect(/* [in] */ const HWND hWndClient, 
                            /* [in/out] */ RECT &rcInOut)
    {
     CPoint ptTopLeft(rcInOut.left, rcInOut.top);
     CPoint ptBottomRight(rcInOut.right, rcInOut.bottom);
     ::ScreenToClient(hWndClient, &ptTopLeft);
     ::ScreenToClient(hWndClient, &ptBottomRight);
     rcInOut.left = ptTopLeft.x;
     rcInOut.top = ptTopLeft.y;
     rcInOut.right = ptBottomRight.x;
     rcInOut.bottom = ptBottomRight.y;
    }

    m_rcRefDlg holds the reference rect for the dialog and m_rcRef holds the reference rect for the control relative to the dialog.

    This code has been in the UI for quite a while and recently one of our testers discovered a nasty bug while running a test pass.

    The question is: What’s wrong with this code.  I believe we shipped Windows Vista with this bug (I’m not 100% sure, since I don’t have a Windows Vista machine to test it), so it’s pretty subtle.

     

    Edit: OOPS - I forgot to include ScreenToClientRect.

     

  • Larry Osterman's WebLog

    If you live in the US, don’t forget to vote today

    • 11 Comments

    It’s a really big deal, regardless of your political persuasion.

     

    Already the MSFT internal mailing lists have been filled with people asking “how long are the lines at my polling place”.  The good news is that the times appear to be pretty good – people seem to be getting in and out in very little time (at least in the town in which I live).

     

    For people living in King and Pierce counties in Washington State, this will be the last time that they will vote in person.  The rest of the state already votes entirely by mail, and starting next year, both counties will also switch to vote-by-mail.

     

    The state of Oregon has already switched to a 100% vote-by-mail system, with the switchover in King and Pierce counties, Washington state will join Oregon in eliminating the ballot box.

     

    Valorie and I have been voting absentee for about 5 years now, personally I like it – by voting at home, we have the opportunity to scope out the candidates at our leisure.  That in turn means that we’re going to vote more accurately.

     

    So if you live in the US, please, PLEASE vote today.

  • Larry Osterman's WebLog

    PDC 2008, Day 4 (and finale)

    • 6 Comments

    Ok, the PDC’s finally over and I’ve had a chance to decompress a bit.  So here’s my day 4 report, only a few days late :).

    I got up at 6:15, finished packing and schlepped my stuff to the convention center for my tech check at 7:40.

     

    At the tech check, I learned that (a) I wasn’t going to be able to use presenter view in PowerPoint (which means I wouldn’t have access to my notes), and I wasn’t going to be able to see my presentation while doing my demos :(.  All of these are minor annoyances, not fatal, but still annoying.

    I then went to the speakers lounge to chill for a couple of hours while I waited for my talk – this was my first time talking to such a big convention so I was a bit nervous.

    At about 11:30 I headed out to the room (151, with a capacity of 1000 people).  I hooked up my kit to the stage and waited until noon for my presentation to begin:

    Larry's talk is up next

    I think the talk went quite well – the demos worked perfectly and I didn’t make too many mistakes (I missed one of my talking points :(). 

     

    I knew I wasn’t going to fill the room since I was speaking (a) on the last day of the convention and (b) opposite lunch and (c) a fairly geeky topic but I was still a smidge disappointed that only 53 people showed up :(.

    Here’s the view from the podium after my talk:

    The view from the podium

     

    After the talk, I chatted with some folks in the Win7 lounge and basically hung out until 3ish when I got together with my cousin Stacy (who I haven’t seen in a long time).  We wandered over to his restaurant and I met his wife Mindy and mother Selma.  We then went to his house where I met his kids and we hung out and chatted until it was time to go to the airport for the return flight. 

     

     

    For those of you who were wondering what a PDC presenter brings to the PDC, here’s what was in my backpack:

    My PDC Kit 

    Left to right, from top to bottom there was:

    My backpack

    Lego Boeing 787 (I didn’t take that to the PDC).  Two cases for my 2 sets of Altec Lansing T515 bluetooth speakers Laptop 1 (my primary laptop)  Laptop 2 (my demo laptop).

    Power supplies for the laptops, a Jabra BT620SD bluetooth headphones, a Plantronics Voyager 510 Bluetooth headset, the 2 Altec Lansing T515 speakers, a Creative Labs talk microphone.

    Headphones for my portable media player, 2 notepads for notes from the conference, my Creative Zen Vision:M portable media player, 2 bluetooth USB dongles, a USB hub, a box of business cards, my PDC badge from the last PDC I attended (1991), and a Jabra USB headset.

     

    Most of the kit was there for redundancy – in case something got lost or broke, I wanted to make sure I had a backup for everything.    Some of the kit was just there to be props during my talk.

    And I’m glad I did – as I was returning from the conference, one of the T515 devices (the one I own) disappeared between the hotel when I packed it and my house.  I have no idea what happened to it.

Page 1 of 1 (6 items)