home *** CD-ROM | disk | FTP | other *** search
- /*
- ENDMENU.C -- Shows the system wide effect of EndMenu
-
- From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC ENDMENU (for Borland C++ v3.00)
- WINIOMS ENDMENU (for Microsoft C/SDK)
- */
-
- #include <windows.h>
- #include "winio.h"
-
- /* undocumented function */
- extern void FAR PASCAL EndMenu(void);
-
- #include "checkord.c"
-
- HANDLE hTimer;
- FARPROC lpfnTimerFunc;
-
- WORD FAR PASCAL TimerFunc(HWND hwnd, WORD wMsg,
- int nIDEvent, DWORD dwTime)
- {
- EndMenu();
- return 1;
- }
-
- BOOL CleanUp(HWND hwnd)
- {
- FreeProcInstance(lpfnTimerFunc);
- KillTimer(winio_current(), hTimer);
- return TRUE;
- }
-
- int main()
- {
- HMENU hMenu, hPopup;
-
- // Ord/name check
- if (! CheckOrdName("EndMenu", "USER", 187))
- return 0;
-
- winio_about("ENDMENU"
- "\nShows the system wide effect of EndMenu"
- "\n\nFrom Chapter 6 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek"
- );
-
- lpfnTimerFunc = MakeProcInstance((FARPROC) TimerFunc, __hInst);
-
- hPopup = CreateMenu();
- AppendMenu(hPopup, MF_GRAYED | MF_STRING,
- 1, "Watch me disappear...");
- AppendMenu(hPopup, MF_GRAYED | MF_STRING,
- 2, ".. within 3 seconds.");
-
- hMenu = winio_hmenumain(winio_current());
- AppendMenu(hMenu, MF_ENABLED | MF_STRING | MF_POPUP,
- hPopup, "Click Me");
-
- hTimer = SetTimer(winio_current(), 10, 3000, lpfnTimerFunc);
-
- winio_onclose(winio_current(), (DESTROY_FUNC) CleanUp);
-
- printf("\nClick once on the menu selection \"Click Me\" above,\n"
- "leaving the popup visible. Within a couple of seconds\n"
- "the popup will disappear by itself. This is caused by\n"
- "a call to EndMenu() within a timer event handler.\n\n"
- "Close the window to exit.");
-
- return 0;
- }
-
-