#ifndef WIN32UTILS_H #define WIN32UTILS_H /////////////////////////////////////////////////////////////////// // // // Win32utils.h - useful helper functions for Win32 API // // ver 1.0 // // // // Language: Visual C, ver 6.0 // // Platform: Micron Dual Pentium Pro 200, Win NT 4.0 // // Application: CSE691 Project #1 // // Author: Jim Fawcett, Instructor, CSE691, Fall '99 // // CST 2-187, Syracuse Univ, (315) 443-3948 // // fawcett@ecs.syr.edu // // // /////////////////////////////////////////////////////////////////// /* Module Operations: ================== This module provides a few helper functions for Win32 programming. Public Interface: ================= showCurrentThreadID(hwnd,"WinMain thread ID is "); // shows messagebox showSysError("context of error",GetLastError()); // shows messagebox string s = makeString("thread ID = ",GetCurrentThreadID()); */ /////////////////////////////////////////////////////////////////// // build process // /////////////////////////////////////////////////////////////////// // required files: // // Win32utils.h, Win32utils.cpp // // // // building in IDE: // // - build Win32 Application project // // - add these files // // - compile, line, and run // /////////////////////////////////////////////////////////////////// /* Maintenance History: ==================== ver 1.0 : 06 Nov 99 - first release */ // #include #include #include //----< make string from generic type, prepend literal string >---- // // template function bodies must be in header file // non-template function bodies must be in implementation file // template std::string makeString(const char *msg, const T &t) { std::ostrstream format; if(!format.good()) { showSysError("construct ostrstream failed in makeString",GetLastError()); exit(1); } if(msg != NULL) format << msg; format << t; format << ends; return format.str(); } void showCurrentThreadID(HWND hwnd=NULL, const char *Msg=NULL); void showSysError(const char *pMsg, DWORD errCode); #endif