Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

The Ultimate Toolbox - Updates and User Contributions

, 12 Feb 2013
Updates and User Contributions for the Ultimate Toolbox Libraries
OutlookDemoUpdate.zip
Ultimate Grid
Demos
OutlookStyle
OutlookStyle.aps
OutlookStyle.dsp
OutlookStyle.dsw
OutlookStyle.suo
res
bitmap1.bmp
bmattach.bmp
bmp00001.bmp
bmp00002.bmp
bmp00003.bmp
Flags.bmp
OutlookStyle.ico
OutlookStyleDoc.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
toolbarf.bmp
UltimateGrid72_Src_Update01.zip
CellTypes
Include
Source
UltimateGrid72_Src_Update02.zip
DataSources
ODBC
OleDB
EditControls
UltimateGrid72_Src_Update03.zip
UltimateGrid72_Src_Update04.zip
UltimateGrid73_src.zip
BuildDLL
Build DLL.dsp
Build DLL.dsw
res
BuildLib
ugmfclib.dsp
ugmfclib.dsw
Lib
Skel
UltimateTCP-IP42_Src_Update01.zip
Ultimate TCP-IP
Include
Security
Include
Source
source
UltimateTCP-IP42_Src_Update02.zip
Examples
Client
Mail
icon1.ico
icon2.ico
MailClientS.suo
test.dsp
test.dsw
UltimateTCP-IP42_Src_Update03.zip
ultimatetoolbox93_src_update01.zip
Ultimate Toolbox
include
source
UltimateToolbox93_Src_Update02.zip
lib
Build DLLs
Build Libs
UltimateToolbox93_Src_Update03.zip
UltimateToolbox93_Src_Update04.zip
UltimateToolbox93_Src_Update05.zip
// =================================================================
//  class: CUH_Control
//  File:  uh_ctrl.h
//
//  Purpose:
//
//      Provide output to custom control and file logging 
//      for status messages.
//
// =================================================================
// Ultimate TCP/IP v4.2
// Copyright (C) The Ultimate Toolbox 1995-2007, all rights reserverd
// =================================================================
 
#ifndef _CUH_CONTROL
#define _CUH_CONTROL

#include <stdio.h>
#include <time.h>
#include "utstrlst.h"
#include "ut_strop.h"


// thread safe define, rem out for single threaded environments
// or include for this class to be safe in multi-threaded programs
#ifndef UH_THREADSAFE
#define UH_THREADSAFE
#endif

#define UH_SUCCESS 0
#define UH_ERROR   1
#define UH_SET_THIS_PTR     WM_USER+135


//history linked list
typedef struct UH_HistoryListTag{
    LPTSTR               m_string;
    COLORREF            m_textColor;
    COLORREF            m_backColor;
    int                 m_len;
    UH_HistoryListTag * m_next;
    UH_HistoryListTag * m_prev;
}UH_HistoryList;


//history-logging control class
class CUH_Control{

private:

    //log info
    LPTSTR       m_logName;
    BOOLEAN     m_enableLog;
    BOOLEAN     m_timeStampedLog;
    int         m_logDay,m_logMonth,m_logYear;
    FILE*       m_fileHandle;

    //current settings
    COLORREF    m_textColor;
    COLORREF    m_backColor;
    int         m_alignment;
    int         m_margin;
    HFONT       m_font;
    int         m_fontHeight;
    int         m_fontWidth;
    
    //history list info
    UH_HistoryList *m_historyList;
    int m_historyListMaxLen;

    UH_HistoryList *m_HLCurrentPosPtr;
    int             m_HLCurrentPos;
    UH_HistoryList *m_HLEndPosPtr;
    int             m_HLEndPos;
    
    //scrollbar values
    int m_vScrollRange;
    int m_vScrollPos;
    int m_hScrollRange;
    int m_hScrollPos;
    int m_vScrollPageSize;
    int m_hScrollPageSize;

    //max line width
    int m_maxLineWidth;

    _TCHAR * m_DateFormatString;

    //critical section variables
    #ifdef UH_THREADSAFE
    CRITICAL_SECTION m_criticalSection;
    #endif



public:
    HWND        m_hWnd;

protected:

    //intern

    void OnPaint();
    void OnSize();

	// v4.2 - update 01 - 64-bit - changed return type from long to LRESULT
    static LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);

    void OnHScroll(int code,int pos);
    void OnVScroll(int code,int pos);
    void SetCurrentPosPtr(int pos);
    void UpdateScrollRange();
    BOOL OnKeyDown(int nKeyCode);

    int  GetTimeDateStamp(LPTSTR string,int len);

    void WriteToLog(LPCTSTR string,int newline);
    int  OpenLog();
    int  CloseLog();

public:

    //contructor - destructor
    
    CUH_Control();
    virtual ~CUH_Control();

    //window creation
    
    int CreateHistoryWindow(HWND parent,DWORD style,RECT &rect);
    int AttachHistoryWindow(HWND parent,UINT ID);
    static int RegisterWindowClass(HINSTANCE hInstance);

    //setup
    
    int     SetTextColor(COLORREF color);
    COLORREF GetTextColor() const;

    int     SetBackColor(COLORREF color);
    COLORREF GetBackColor() const;

    int     SetMargin(int margin);
    int     GetMargin() const;

    int     SetAlignment(int alignment);
    int     GetAlignment() const;

    int     SetLogName(LPCTSTR logName);
    LPCTSTR  GetLogName() const;

    int     EnableLog(BOOLEAN yesNo);
    BOOL    IsLogEnabled() const;

    int     EnableTimeStampedLog(BOOLEAN yesNo);
    BOOL    IsTimeStampedLogEnabled() const;

    int     SetHistoryLength(int len);
    int     GetHistoryLength() const;

    int     SetFont(HFONT font);

    int     SetTimeStampFormat(LPCTSTR formatString);
    LPCTSTR  GetTimeStampFormat() const;

    //operations
	int     ClearHistory();

    int     AddLine(LPCTSTR string, COLORREF TextColor = 0xFFFFFFFF, COLORREF BackColor = 0xFFFFFFFF, BOOLEAN addToLog = TRUE);
    int     AddStampedLine(LPCTSTR string, COLORREF TextColor = 0xFFFFFFFF, COLORREF BackColor = 0xFFFFFFFF, BOOLEAN addToLog = TRUE);
    int     AppendToLine(LPCTSTR string,BOOLEAN addToLog = TRUE);

#if defined _UNICODE
	// some char based protocol classes will send server responses etc. as LPSTRs in a _UNICODE build. These
	// overloads can convert params and call the wide char versions.
    int     AddLine(LPCSTR string, COLORREF TextColor = 0xFFFFFFFF, COLORREF BackColor = 0xFFFFFFFF, BOOLEAN addToLog = TRUE);
    int     AddStampedLine(LPCSTR string, COLORREF TextColor = 0xFFFFFFFF, COLORREF BackColor = 0xFFFFFFFF, BOOLEAN addToLog = TRUE);
    int     AppendToLine(LPCSTR string,BOOLEAN addToLog = TRUE);
#endif
  
};

/**********************************
Static method that takes the same 
parameters as sprintf function and 
returning a pointer to the internal
buffer.

This method simplifies the use of the 
methods like AddLine if you need to
create the string first.

  Ex: AddLine(S("Number of errors: %d", nErrors));
***********************************/    
// v4.3 this generates too many warning 4505s.
/*
static LPCTSTR S(LPCTSTR lpszFormat, ...) 
{
    va_list         marker;
    static _TCHAR   szSBuffer[1024];

    // Initialize variable arguments
    va_start( marker, lpszFormat);  

    // Write formatted output using a pointer to a list of arguments
	CUT_Str::sntprintf(szSBuffer,sizeof(szSBuffer)-1, sizeof(szSBuffer)-1, lpszFormat, marker); 
    // Reset variable arguments
    va_end( marker );    

    // Return the pointer to the static buffer
    return szSBuffer;
}
*/
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.
 
Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

387 members


| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 13 Feb 2013
Article Copyright 2008 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid