Hello Andrue,
"Andrue Cope" <not.a.va...@email.address.sorry> schreef in bericht
news:VA.00000ecf.00ef801b@email.address.sorry...
Quote
> I'm trying to draw an image onto the background of an MDI parent.
> Placing a VCL component doesn't work too well since the component is
> either invisible or appears infront of all non-modal forms (but
> behind modal forms).
> I read somewhere that the answer was to respond to WM_ERASEBKGND so I
Hmm, that's only part of it<g>, you have to subclass the client area.
I've used the following example successful on W95 and W98se, don't know if
anything
has changed with newer versions though.
// in the TForm's header
private:
Pointer OriginalClientProc;
Pointer ClientObjectInstance;
protected:
virtual void __fastcall CreateWnd();
virtual void __fastcall DestroyWnd();
virtual void __fastcall ClientProc(TMessage & Msg);
virtual void __fastcall DrawClientWindow(HDC & Hdc);
void __fastcall WMEraseBkgnd(TWMEraseBkgnd & Msg);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
END_MESSAGE_MAP(TForm)
// in the TForm's source
void __fastcall TMainForm::CreateWnd()
{
TForm::CreateWnd();
ClientObjectInstance = MakeObjectInstance(ClientProc);
OriginalClientProc = (Pointer)SetWindowLong(ClientHandle, GWL_WNDPROC,
(long)ClientObjectInstance);
// -------------------------------------------------------------------------
void __fastcall TMainForm::DestroyWnd()
{
SetWindowLong(ClientHandle, GWL_WNDPROC, (long)OriginalClientProc);
FreeObjectInstance(ClientObjectInstance);
TForm::DestroyWnd();
// -------------------------------------------------------------------------
void __fastcall TMainForm::ClientProc(TMessage & Msg)
{
switch( Msg.Msg ) {
case WM_ERASEBKGND:
DrawClientWindow((HDC)Msg.WParam);
Msg.Result = true;
break;
case WM_HSCROLL:
case WM_VSCROLL:
Msg.Result = CallWindowProc( (FARPROC)OriginalClientProc,
ClientHandle,
Msg.Msg, Msg.WParam, Msg.LParam );
InvalidateRect(ClientHandle, 0, true);
break;
default:
Msg.Result = CallWindowProc( (FARPROC)OriginalClientProc,
ClientHandle,
Msg.Msg, Msg.WParam, Msg.LParam );
}
// -------------------------------------------------------------------------
void __fastcall TMainForm::WMEraseBkgnd(TWMEraseBkgnd & Msg)
{
Msg.Result = false;
Btw, the DrawClientWindow() member you have to do yourself<g>
Quote
> If anyone has any ideas as to how to draw on a form's background I'd
> love to read them..
Hope this toggles the brain...;-))
--
Greetings from overcast Amsterdam
Jan
email: bijs...@worldonline.nl
http://home.worldonline.nl/~bijster