home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / Status.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  2.3 KB  |  70 lines

  1. //-----------------------------------------------------------------------------------//
  2. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  3. //                             ISBN  0-13-086985-6                                   //
  4. //                                                                                   //
  5. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  6. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  7. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  8. //                                                                                   //
  9. //  FileName   : status.cpp                                                             //
  10. //  Description: Status window                                                       //
  11. //  Version    : 1.00.000, May 31, 2000                                              //
  12. //-----------------------------------------------------------------------------------//
  13.  
  14. #define STRICT
  15. #define WIN32_LEAN_AND_MEAN
  16.  
  17. #include <windows.h>
  18. #include <commctrl.h>
  19. #include <tchar.h>
  20. #include <assert.h>
  21.  
  22. #include "win.h"
  23. #include "Status.h"
  24.  
  25. #pragma comment(lib, "comctl32.lib")
  26.  
  27.  
  28. void KStatusWindow::Create(HWND hParent, UINT nControlID)
  29. {
  30.     m_ControlID = nControlID;
  31.     m_hWnd      = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP,
  32.                                      NULL, hParent, nControlID);
  33. }
  34.  
  35.  
  36. void KStatusWindow::Resize(HWND hParent, int width, int height)
  37. {
  38.     RECT Parent;
  39.     RECT Self;
  40.     int  parts[3];
  41.  
  42.     GetClientRect(hParent, & Parent);
  43.     GetClientRect(m_hWnd,  & Self);
  44.  
  45.     // (width-60)/2, (width-60)/2, 40, 20
  46.     parts[0] = (width - 60) / 2;
  47.     parts[1] = width - 60;
  48.     parts[2] = width - 20;
  49.     SendMessage(m_hWnd, SB_SETPARTS, 3, (LPARAM) parts);
  50.  
  51.     MoveWindow(m_hWnd, 0, Parent.bottom-Self.bottom, width, height, TRUE);
  52. }
  53.  
  54.  
  55. void KStatusWindow::SetText(int pane, HINSTANCE hInst, int messid, int param)
  56. {
  57.     TCHAR pattern[MAX_PATH], message[MAX_PATH];
  58.  
  59.     LoadString(hInst, messid, pattern, sizeof(pattern));
  60.     wsprintf(message, pattern, param);
  61.  
  62.     SendMessage(m_hWnd, SB_SETTEXT, pane, (LPARAM) message);
  63. }
  64.  
  65.  
  66. void KStatusWindow::SetText(int pane, LPCTSTR message)
  67. {
  68.     SendMessage(m_hWnd, SB_SETTEXT, pane, (LPARAM) message);
  69. }
  70.