"Remy Lebeau \(TeamB\)" <
XXXX@XXXXX.COM >schrieb:
Remy, thanks of your answers.
Quote
<MR>wrote in message news: XXXX@XXXXX.COM ...
>What can be the reason, when method CreateWnd() not being called?
Because you did not override it correctly. Or you are not doing anything
that requires the Handle to be allocated in the first place.
>So I tried to combine these two into one component TMyButton,
>also for an exercise...
Then you likely did not merge then correctly. Please show the actual code.
Here is the header-file. I'm not sure if I'm allowed to publish the
.cpp-file here (copyright-reasons of the original delphi-authors, even
if the Delphi-source-code is available in the net), but I suppose it
is not really necessary, because there is no error occuring in
CreateWin, it is just not being called.
But I suppose it would be ok, to send it directly per Email, if you
want this.
// From TColorButton
// ->
delphi.about.com/library/code/ncaa061104a.htm
// From TMultiLineButton
// ->
//---------------------------------------------------------------------------
#ifndef TMRButtonH
#define TMRButtonH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <SysUtils.hpp>
//---------------------------------------------------------------------------
class PACKAGE TMRButton : public TButton
{
public:
__fastcall TMRButton(TComponent* Owner);
__fastcall ~TMRButton();
void __fastcall CreateParams(TCreateParams &Params);
void __fastcall CreateWnd(void);
void __fastcall WndProc(TMessage &Message);
// MultiLineButton
private:
typedef TButton inherited;
bool FMultiLine;
public:
void __fastcall TMRButton_MultiLineButton__Constructor(TComponent*
Owner);
void __fastcall TMRButton_MultiLineButton__Destructor();
private:
void __fastcall SetMultiLine(bool _is_multi_line) {
FMultiLine=_is_multi_line;
}
protected:
void __fastcall TMRButton_MultiLineButton__CreateWnd(void);
__published:
__property bool MultiLine={read=FMultiLine, write=SetMultiLine};
// ColorButton
private:
TColor FBackBeforeHoverColor;
TCanvas *FCanvas;
bool IsFocused;
TColor FBackColor;
TColor FForeColor;
TColor FHoverColor;
public:
void __fastcall TMRButton_ColorButton__Constructor(TComponent*
Owner);
void __fastcall TMRButton_ColorButton__Destructor();
private:
void __fastcall SetBackColor(const TColor Value);
void __fastcall SetForeColor(const TColor Value);
void __fastcall SetHoverColor(const TColor Value);
__property TColor BackBeforeHoverColor={read=FBackBeforeHoverColor,
write=FBackBeforeHoverColor};
protected:
void __fastcall TMRButton_ColorButton__CreateParams(TCreateParams
&Params);
void __fastcall TMRButton_ColorButton__WndProc(TMessage &Message);
void __fastcall SetButtonStyle(bool Value);
void __fastcall DrawButton(TRect Rect, unsigned State);
// procedure CMEnabledChanged(var Message: TMessage); message
CM_ENABLEDCHANGED;
MESSAGE void __fastcall CMEnabledChanged(TMessage &Msg);
// procedure CMFontChanged(var Message: TMessage); message
CM_FONTCHANGED;
MESSAGE void __fastcall CMFontChanged(TMessage &Msg);
// procedure CNMeasureItem(var Message: TWMMeasureItem); message
CN_MEASUREITEM;
MESSAGE void __fastcall CNMeasureItem(TWMMeasureItem &Msg);
// procedure CNDrawItem(var Message: TWMDrawItem); message
CN_DRAWITEM;
MESSAGE void __fastcall CNDrawItem(TWMDrawItem &Msg);
//
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_ENABLEDCHANGED, TMessage, CMEnabledChanged)
MESSAGE_HANDLER(CM_FONTCHANGED, TMessage, CMFontChanged)
MESSAGE_HANDLER(CN_MEASUREITEM, TWMMeasureItem, CNMeasureItem)
MESSAGE_HANDLER(CN_DRAWITEM, TWMDrawItem, CNDrawItem)
// END_MESSAGE_MAP(TMRButton) // =>Stack overflow...
END_MESSAGE_MAP(inherited)
__published:
__property TColor BackColor={read=FBackColor, write=SetBackColor,
default=clBtnFace};
__property TColor ForeColor={read=FForeColor, write=SetForeColor,
default=clBtnText};
__property TColor HoverColor={read=FHoverColor, write=SetHoverColor,
default=clBtnFace};
};
//---------------------------------------------------------------------------
#endif
Thank you,
Michael