Source

oberchatten / InfoBoxUnit.h

/*
$Id: InfoBoxUnit.h,v 0.6 2006/03/04 08:55:00 ddrp Exp $

Copyright (C) 2001-2006 Daybo Logic.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/*
  Here are some resources for dialogs like this:

  http://www.codeproject.com/dialog/xmessagebox.asp
  http://www.visualcomponentlibrary.com/bcb/functions/msgbox.htm
*/
//---------------------------------------------------------------------------
#ifndef InfoBoxUnitH
#define InfoBoxUnitH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
#ifdef INFOBOX_DLL
# error ("INFOBOX_DLL needs more code written by DDRP first")
#else
# define INFOBOX_ICONS_RESHANDLE (HInstance)
#endif //INFOBOX_DLL
//---------------------------------------------------------------------------
class TInfoBox : public TForm
{
__published:	// IDE-managed Components
        TButton *Button1;
        TButton *Button2;
        TButton *Button3;
        TImage *IconImage;
        TMemo *InfoMemo;
        void __fastcall FormShow(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall BtnClick(TObject *Sender);
private:	// User declarations
        int idValue; // The user choice
        UINT style;
        unsigned int iconVer;
        dtlock_t moveHandlingLock;
        TShadowForm* shadow;
        void __fastcall OnMove(TWMMove& Message);
protected:
        void SetIcon(UINT Style);
        void SetButtons(UINT Style);
        unsigned int GetNumberOfButtons();
        void NumberOfButtons(unsigned int NumBtns);
        // Block / unblock calls to OnMove()
        void LockOnMove(bool Locking = true);
        void UpdateShadow();
        void SetDefFocus(UINT Style);
        void SetDefFocus();
public:		// User declarations
        __fastcall TInfoBox(TComponent* Owner);
        __fastcall ~TInfoBox();
        inline int GetIDValue() { return this->idValue; }
        void SetStyle(UINT SetStyle);
        inline UINT GetStyle() { return this->style; }
        // Change version of icons being used
        unsigned int IconVersion(unsigned int NewIconVersion=0);
        void SetText(TStrings& Strings);
        void SetText(const char* Text);

        // Message map table
        BEGIN_MESSAGE_MAP
          MESSAGE_HANDLER(WM_MOVE, TWMMove, OnMove)
        END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern PACKAGE TInfoBox *InfoBox;

int InformationBox(TComponent* Owner,    // handle of owner window
                   LPCTSTR lpszMessage,  // message box text
                   LPCTSTR lpszCaption,  // message box title
                   UINT nStyle,          // style of message box
                   UINT nHelpId          // help context id (use INFOBOX_NOHELP)
);

/*
  The above function is called InformationBox to avoid a conflict with Borland's
  global identifer to identify the form above, this macro will allow us to
  call InfoBox() regardless.
*/
#define InfoBox(hwnd, msg, cap, style, hid) \
          InformationBox((hwnd), (msg), (cap), (style), (hid))

/*
  Use the code below to avoid using help IDs, then when you want to add help, get rid of this
  to find all places in the source code which need changing with the help of the compiler
  whinging ;)
*/
#define INFOBOX_NOHELP (0)
//---------------------------------------------------------------------------
#endif