Writing your own menu-like window

Date:August 20, 2004 / year-entry #312
Tags:code
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20040820-00/?p=38103
Comments:    32
Summary:Hereby incorporating by reference the "FakeMenu" sample in the Platform SDK. It's in the winui\shell\fakemenu directory. For those who don't have the Platform SDK, what are you doing writing Win32 programs without the Platform SDK? Download it if it didn't come with your development tools. If for some reason you don't want the Platform SDK...

Hereby incorporating by reference the "FakeMenu" sample in the Platform SDK. It's in the winui\shell\fakemenu directory.

For those who don't have the Platform SDK, what are you doing writing Win32 programs without the Platform SDK? Download it if it didn't come with your development tools.

If for some reason you don't want the Platform SDK yet you want to write Win32 programs (I bet you're the sort of person who throws away the manual as soon as you buy something), you can look at the version that Chris Becke has stashed away on this page.


Comments (32)
  1. Jonathan says:

    Raymond,

    Do you know if the XP SP2 changes are going to be incorporated into the main Platform SDK anytime soon? I know there is a separate XP SP2 RC2 SDK (yay for acronyms!) available for download, but I’m hoping to be able to get it all in one place.

  2. Phil Weber says:

    "For those who don’t have the Platform SDK, what are you doing writing Win32 programs without the Platform SDK?"

    Who writes Win32 programs anymore? The new millenium is all about managed code! ;-)

  3. Ben Hutchings says:

    "not actually a .NET blog"

  4. Will says:

    Heh, Jonathan beat me to it, but I had the exact same question about the Platform SDK. :P It used to be updated every 3-6 months it seemed, but now there hasn’t been an update in over a year.

  5. Gary says:

    I actually work with a guy who refuses to download Platform SDK. He doesn’t understand why we need it and thinks it’s a waste of space.

    Phil: Boo for managed code. Go Win32!! :)

  6. Mike Dunn says:

    When I’m answering programming questions from people who are trying to call some API and getting an undefined-symbol error, the most common cause is they’re still using the headers that came with VC 6. How they expect to use headers/libs from 1998 to call APIs written in 2002, I’ll never know. (The windows.h in VC 6 is so old, it mentions "NT 5.0")

  7. Morten Andersen says:

    The reason why I lived without the Platform SDK for VERY long time, is that it is/was so dammed difficult to install from the site you refer.

    First: You can’t access the site using Moz. – Have to use IE.

    Second: Ok, I used IE, but was unable to use the "automatic install", as it required MS XML 3 (some specific sub version), and I had long time ago installed MS XML 4. So I tried a couple of things, but was never able to get it to work. (at least I assume that is why it failed?)

    Third: The links on the full download site http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm was defect at least until July this year (sorry I am on "another" platform without IE right now, so I can’t verify if the links are still defect, as the section with the links seem to be generated by some ActiveX component?).

    I assume even the maintainer(s) of the SDK download site, gave up on getting the links to work correctly. Instead they updated the FAQ for the download with information about substituting the defect "NA" section with the correct version for the February 2003 version. (sorry that I can find the FAQ right now, but the site won’t let me enter at all with Mozilla :-)).

    So, I didn’t know whether I should cry or laugh in how much of an adventure it is/was to install the Platform SDK, from the web :-).

  8. Alex Feinman says:

    Johnatan, Will: Supposedly very soon

  9. Morten Andersen says:

    Update to my last comment on how hard it was to install the Platform SDK. I just booted to an IE-friendly OS, and it wasn’t in the FAQ the broken links is mentioned, it is in the "Troubleshooting Installation" section on the "Instructions" page:

    http://www.microsoft.com/msdownload/platformsdk/sdkupdate/sdkhelp.htm

    There is probably a very good reason why an ActiveX component must create the links, but it does seem a little bit mysterious that it is so hard to supply 15 correct links :-)

  10. There will be a new PSDK for WinXP SP2 in a matter of days.

    We are changing SDKUpdate. It will work much like any other MSDN download from now on and that should eliminate the downloading hassles that folks experienced with the SDK Update site.

    If you’d like to continue the discussion about the PSDK and the problems you’re having or have had with it, comment at my blog http://blogs.msdn.com/loripe/ or continue here and I’ll try to keep looking.

    THANKS FOR ALL THE COMMENTS SO FAR! We are trying to create a better experience with the PSDK and would love to hear how you’d like to see us change it

  11. Jim says:

    Call me silly, but exactly what sorts of things does the Platform SDK have that I don’t already have with VC6+SP5? I’ve spent the last 45 minutes googling and have yet to find a decent description of what the PSDK is. I assume that PSDK contains tools and resources for using Windows features invented since 1998 and possibly documentation for formerly "secret" stuff required by the lawsuit settlement. What else is there and why should I care?

  12. Chris Becke says:

    Eeep. How did you find that? I didn’t know it was there!

    When last did I update that anyway. And more worrying – what happened to the time I used to have to do the updates in…

  13. Mike Dunn says:

    Jim> On VC 6 without the PSDK, you have headers and libs that were built in 1998. At that time, the shipping platforms were Win 95 OSR2, NT 4, and IE 4, so your headers/libs only have the APIs that were written up to that time.

    Now, try using anything in Win32 written after 1998, like a rebar (in IE 5) or SetWindowTheme (XP). It won’t be in your header files so how are you going to use it?

  14. I also remember installing the Platform SDK a BIG hassle. I couldn’t use the automagic install (don’t ask me why, it just failed).

    So I tried the full download but IE would only download like 65k of each cab-file and nothing more.

    So in the end what I had to do was to copy the link to each cab-file from IE into Mozilla. That worked but I have done more funny things in my life.

  15. Sven says:

    It seems that the new Platform SDK does not support VC6 anymore:

    strsafe.lib(strsafe.obj) : fatal error LNK1103: debugging information corrupt; recompile module

    Also the debug symbols of SP2 are not compatible to VC6 anymore. Isn’t it possible to add PDB7 support to VC6?

  16. David Candy says:

    To Lori

    The SDK is filled with totally irrelevent stuff. I generally want i header file as the MSDN CDs doesn’t include the values of constants. These days I search google for the .h file as I can read it in 10 seconds compared to an hour to install then uninstall the PSDK.

    Why don’t you put it up as a folder structure so we can take what we want from it, which is generally 0.000000001% of it.

  17. Mike Dunn says:

    Sven> I hate VC 2003 so I never use it if I can help it, but at this point, any new code that MS releases publicly is going to require 2003. At work we just got hit with this – we used to use VC 6, but we got new libs from the WMP team that wouldn’t compile in 6, so we had to burn a week converting all our stuff to work in 2003 (and casting various evil spells and curses on the awful 2003 IDE).

  18. Sven says:

    I tried to work with VS 2003, but after two weeks I returned to VC6. The missing Class Wizard is really annoing, besides that I found some things slowing down my daily work:

    1) Folder display in Solution Explorer

    In my projects I use folders to group files. In the first level of a project all files are sorted after the folders (as in VC6), but from second level all files are sorted before the folders.

    2) Resource view

    The projects in the resource view are sorted case-sensitive, while the projects in the solution explorer are sorted case-insensitive.

    3) Filenames in IDE

    The files in IDE always have a small drive letter. You can see this in the "Window" dialog box, in the task list or in the tooltip for the tab.

    4) Output and Intermediate Directory

    Both directories are always created with small letters. If I specify ".objsUnicode_Release" than ".objsunicode_release" is created.

    5) String Table Editor

    – If I open the string table editor than the items are not sorted by value.

    – I miss the separator lines every 16 items. These lines are very helpful if I compare string tables for different languages to find out, which items are missing.

    – The column widths should be stored in the registry.

    – New items are created at the bottom while VC6 inserted the items in the line below.

    6) Dialog editor

    If keyboard cues are disabled, the dialog editor does not show the mnemonic keys in the layout view. If I press <Enter> on a dialog item (this opens the property window in VC6) the text of the dialog item is deleted and there is no undo support.

    7) F4/Shift-F4 goes to the next/previous compiler error. In VC6 the cursor is set automatically on the error line, while in VC7 you have to press <Return> everytime.

    8) F4/Shift-F4 does not work for "Find in files" anymore.

  19. Norman Diamond says:

    In VS 2003, not only is the Class Wizard missing, but the help files give incorrect instructions on where to look for the missing functionality.

    Meanwhile VS6 SP6 is dated this year, 2004. Header files that needed to be changed between 1998 and 2004 sure ought to be updated by SP6.

    Plus, with VS6 and VS2003 side by side, the SDK integrated itself with VS2003 but not with VS6. In some thread last year, someone kindly gave me instructions on how to solve that.

    Then, with VS6 (SP5 then) and the SDK cooperating, compilation errors arose which didn’t arise before installing the SDK. For example an identifier that used to be a typedef changed to a macro or vice-versa, making problems for a header that hadn’t been updated. For example the number of closest-match candidates for some COM method call increased from 1 to 2, creating an ambiguity so I had to find the actual class names and guess which one to specify.

  20. Dante Shamest says:

    Been looking for such a sample for some time. Didn’t know it was all along on my computer in the Platform SDK. ^__^

    Annoyance: right-clicking again on the owner window doesn’t seem to show another "fake menu". The first "fake menu" has to be closed first.

  21. Centaur says:

    What are valid uses for a menu-like window? That is, what can you do with a menu-like window that you can’t with a proper menu?

  22. Dante Shamest says:

    > what can you do with a menu-like window that you can’t with a proper menu?

    I guess it allows for more customization. You could make irregular shaped menus with window regions. And you can do your own drawing instead of owner-drawing regular menus.

  23. asdf says:

    Not just menus. Anything that pops up like making your own combo box or code completion dropdown.

  24. Centaur says:

    So, these are the “I-want-to-be-different” uses… What can you do with a menu-like window that you *absolutely* can’t with a proper menu or combo box?

  25. asdf says:

    The FakeMenu code is how you implement any modal window including dialogs, menus, and comboboxes. You spin your own message loop and then return whatever value you need to the caller doing your own message filtering and dispatching.

    The reason Raymond posted this article is because of:

    http://blogs.msdn.com/oldnewthing/archive/2003/10/29/55479.aspx#55485

    I’m sure you can retrofit the drop down color picker in word, radial menus, and the hotbar in maya to use real menus or a combobox but it’s a pain in the ass. I’d be willing to bet drag and drop, the move/resize window code, and autoscrolling (the thing where you middle click and that circle appears so you can scroll around by moving the mouse) are implemented in similar ways.

  26. asdf says:

    @rem echo http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm

    @rem echo wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.bat

    @rem echo PSDK-FULL.bat and extract.exe are always the same

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.bat

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/extract.exe

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.1.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.2.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.3.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.4.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.5.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.6.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.7.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.8.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.9.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.10.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.11.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.12.cab

    wget -c http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/2600.2180/FULL/PSDK-FULL.13.cab

  27. jfo's coding says:

    Orangy asks:

    Hello, thanks for nice articles. Could you please write one about creating combobox-style…

  28. jfo's coding says:

    Orangy asks:

    Hello, thanks for nice articles. Could you please write one about creating combobox-style…

  29. It was for scrolling menus.

Comments are closed.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index