Home > Archive > Smartphone Developer Forum > March 2006 > Can we rely on undocumented behaviour?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Can we rely on undocumented behaviour?
|
|
| Norman Diamond 2006-01-19, 7:10 pm |
| I created an eVC++4 project TestSDK as instructed by the Readme file in the
Smartphone 2003 SDK. The TestSDK project includes the following code,
straight from Microsoft:
// Set the previous instance as the foreground window
// The "| 0x01" in the code below activates
// the correct owned window of the
// previous instance's main window.
SetForegroundWindow((HWND) (((ULONG) hwnd) | 0x01));
MSDN page
http://msdn.microsoft.com/library/d...roundwindow.asp
says:
> SetForegroundWindow
> This function puts the thread that created the specified window into the
> foreground and activates the window.
[...]
> Parameters
> hWnd
> [in] Handle to the window that should be activated and brought to the
> foreground.
MSDN does not give Microsoft's SDK example programmer (or readers of the
example) permission to play with the hwnd parameter that way. MSDN also
says that the window would be activated even if we don't play with the hwnd
parameter that way.
So why did Microsoft rely on undocumented behaviour? And more importantly,
should other programmers rely on the example?
Some famous Microsoft programmers hate companies that rely on undocumented
behaviour.
| |
|
| Norman Diamond wrote:
> I created an eVC++4 project TestSDK as instructed by the Readme file in the
> Smartphone 2003 SDK. The TestSDK project includes the following code,
> straight from Microsoft:
>
> // Set the previous instance as the foreground window
> // The "| 0x01" in the code below activates
> // the correct owned window of the
> // previous instance's main window.
> SetForegroundWindow((HWND) (((ULONG) hwnd) | 0x01));
>
> MSDN page
> http://msdn.microsoft.com/library/d...roundwindow.asp
>
> says:
>
>
> [...]
>
>
>
> MSDN does not give Microsoft's SDK example programmer (or readers of the
> example) permission to play with the hwnd parameter that way. MSDN also
> says that the window would be activated even if we don't play with the
> hwnd parameter that way.
>
> So why did Microsoft rely on undocumented behaviour? And more
> importantly, should other programmers rely on the example?
You don't have to use it, but given the wizard has been producing code
like that for a while now, i doubt it will break any time soon:
http://groups.google.com/group/micr...a2e0fe99ba2630/
riki
This post made from 100% post-consumer recycled magnetic domains. No
binary trees were cut down to make it.
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
Latest Betas have WM5 layout and speed dial support
| |
| Yaroslav Goncharov 2006-03-20, 3:58 am |
| You SHOULD use this trick in your single instance implementation. It is safe
to do so. If you don't do it, your single instance code won't work correctly
in some cases.
--
Yaroslav Goncharov
Spb Software House
"Norman Diamond" <ndiamond@community.nospam> wrote in message
news:uxWSSrVHGHA.1132@TK2MSFTNGP10.phx.gbl...
>I created an eVC++4 project TestSDK as instructed by the Readme file in the
> Smartphone 2003 SDK. The TestSDK project includes the following code,
> straight from Microsoft:
>
> // Set the previous instance as the foreground window
> // The "| 0x01" in the code below activates
> // the correct owned window of the
> // previous instance's main window.
> SetForegroundWindow((HWND) (((ULONG) hwnd) | 0x01));
>
> MSDN page
> http://msdn.microsoft.com/library/d...roundwindow.asp
> says:
> [...]
>
> MSDN does not give Microsoft's SDK example programmer (or readers of the
> example) permission to play with the hwnd parameter that way. MSDN also
> says that the window would be activated even if we don't play with the
> hwnd parameter that way.
>
> So why did Microsoft rely on undocumented behaviour? And more
> importantly, should other programmers rely on the example?
>
> Some famous Microsoft programmers hate companies that rely on undocumented
> behaviour.
|
|
|
|
|