C Programming Column
by Al Stevens


Example 1: 

.1
GNU compiler
Unix
.2
UNICODE
BASIC
ASCII
EBCDIC
FORTRAN
COBOL
Pascal
Quincy 97
functions\\printf
functions\\scanf
.3
GNU compiler
Ritchie, Dennis
AT&T Bell Laboratories
BCPL
ALGOL
PDP-11
Unix
Thompson, Ken
operators\+
operators\-


Example 2: 

ALGOL, 3
ASCII, 2
AT&T Bell Laboratories, 3
BASIC, 2
BCPL, 3
COBOL, 2
EBCDIC, 2
FORTRAN, 2
functions\\printf, 2
functions\\scanf, 2
GNU compiler, 1
GNU compiler, 3
operators\+, 3
operators\-, 3
Pascal, 2
PDP-11, 3
Quincy 97, 2
Ritchie, Dennis, 3
Thompson, Ken, 3
UNICODE, 2
Unix, 1
Unix, 3



Example 3: 

ALGOL, 3
ASCII, 2
AT&T Bell Laboratories, 3

BASIC, 2
BCPL, 3

COBOL, 2

EBCDIC, 2

FORTRAN, 2
functions
  printf, 2
  scanf, 2

GNU compiler, 1, 3

operators
  +, 3
  -, 3

Pascal, 2
PDP-11, 3
printf, 2

Quincy 97, 2

Ritchie, Dennis, 3

scanf, 2

Thompson, Ken, 3

UNICODE, 2
Unix, 1, 3


Listing One
// ProgressDlg.h
#if !defined(AFX_PROGRESSDLG_H__49A4AF82_EA2A_11D0_
                                              8FB3_00C0A80034F0__INCLUDED_)
#define AFX_PROGRESSDLG_H__49A4AF82_EA2A_11D0_8FB3_00C0A80034F0__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

class CProgressDlg : public CDialog
{
public:
    CProgressDlg(CWnd* pParent = 0);

    //{{AFX_DATA(CProgressDlg)
    enum { IDD = IDD_PROGRESSDLG };
    CProgressCtrl   m_Progress;
    //}}AFX_DATA
    //{{AFX_VIRTUAL(CProgressDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);
    //}}AFX_VIRTUAL
    //{{AFX_MSG(CProgressDlg)
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
#endif // !defined(AFX_PROGRESSDLG_H__49A4AF82_EA2A_11D0_
                                             8FB3_00C0A80034F0__INCLUDED_)


Listing Two
// ProgressDlg.cpp

#include "stdafx.h"
#include "Indexer.h"
#include "ProgressDlg.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CProgressDlg::CProgressDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CProgressDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CProgressDlg)
    //}}AFX_DATA_INIT
}
void CProgressDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CProgressDlg)
    DDX_Control(pDX, IDC_PROGRESS, m_Progress);
    //}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProgressDlg, CDialog)
    //{{AFX_MSG_MAP(CProgressDlg)
    ON_WM_CREATE()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

int CProgressDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    if (CDialog::OnCreate(lpCreateStruct) == -1)
        return -1;
    if (m_hWnd != 0)    {
        // --- get window position of mainframe window
        WINDOWPLACEMENT mfwndpl = { sizeof(WINDOWPLACEMENT) };
        theApp.m_pMainWnd->GetWindowPlacement(&mfwndpl);
        // --- get window position of statusbar
        WINDOWPLACEMENT stwndpl = { sizeof(WINDOWPLACEMENT) };
        ((CMainFrame*)(theApp.m_pMainWnd))->
                                 m_wndStatusBar.GetWindowPlacement(&stwndpl);
        int nStatusBarHeight = stwndpl.rcNormalPosition.bottom - 
                                 stwndpl.rcNormalPosition.top + 1;
        // --- get window position of progress dialog window
        WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
        GetWindowPlacement(&wndpl);
       int nProgressBarHeight = wndpl.rcNormalPosition.bottom - 
                                             wndpl.rcNormalPosition.top + 1;
        // --- relocate the progress dialog to the status bar
        const int marginoffset = 75;
        wndpl.rcNormalPosition.right += marginoffset;
        wndpl.rcNormalPosition.left += marginoffset;
        wndpl.rcNormalPosition.top = stwndpl.rcNormalPosition.top + 
                             (nStatusBarHeight - nProgressBarHeight) / 2 + 2;
        wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + 
                              nProgressBarHeight - 1;
        SetWindowPlacement(&wndpl);
        ShowWindow(SW_SHOW);
    }
    return 0;
}

