🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1698

Re: Dialog child window

#1698
From: JD
Date: Wed, 20 Jun 2007 09:04
96 lines
4355 bytes
> Don't know about TPrintDialog.
> Does it just wrap the common dialog?

Yes.

>>So .... Can I query the control to find out if it's checked
>>and dynamically check or uncheck it?
>
> The ID for Collate should be  PD_COLLATE
>
> So
> case WM_INITDIALOG:

I wanted to avoid using the win32 call so I just subclassed the control's 
Window Proc from
the Dialog's OnShow event:

//---------------------------------------------------------------------------
#ifdef STRICT
#define COLLATEWNDPROC WNDPROC
#else
#define COLLATEWNDPROC FARPROC
#endif
//---------------------------------------------------------------------------
    private:
        HWND CollateHandle;
        bool FCollate;
        LONG CollateWndProcPtr;
        COLLATEWNDPROC OldCollateWndProc;
        void __fastcall CollateWndProc( TMessage &Message );
        static bool __stdcall EnumChildCallBack( HWND hWnd, LPARAM lParam );
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void __fastcall TPreviewForm::PrintButtonClick(TObject *Sender)
{
    if( PrintDialog1->Execute() )
      {
          // check FCollate
      }
    if( CollateWndProcPtr ) FreeObjectInstance( 
reinterpret_cast<void*>(CollateWndProcPtr) );
}
//---------------------------------------------------------------------------
void __fastcall TPreviewForm::PrintDialog1Show(TObject *Sender)
{
    CollateHandle = NULL;
    CollateWndProcPtr = NULL;
    ::EnumChildWindows( PrintDialog1->Handle, 
(WNDENUMPROC)EnumChildCallBack, (LPARAM)this );
    if( CollateHandle )
      {
          CollateWndProcPtr = reinterpret_cast<LONG>( 
MakeObjectInstance(CollateWndProc) );
          OldCollateWndProc = reinterpret_cast<COLLATEWNDPROC>( 
::SetWindowLong(CollateHandle, GWL_WNDPROC, CollateWndProcPtr) );
      }
}
//---------------------------------------------------------------------------
bool __stdcall TPreviewForm::EnumChildCallBack( HWND hWnd, LPARAM lParam )
{
    char Buffer[256] = { 0 };
    if( ::GetClassName(hWnd, Buffer, 255) )
      {
          if( stricmp(Buffer, "Button") == 0 )
            {
                ::GetWindowText( hWnd, Buffer, 255 );
                if( stricmp(Buffer, "C&ollate") == 0 )
                  {
                      reinterpret_cast<TPreviewForm*>( 
lParam )->CollateHandle = hWnd;
                      return FALSE;
                  }
            }
      }
    return TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TPreviewForm::CollateWndProc( TMessage &Message )
{
    if( Message.Msg == WM_DESTROY )
      {
          if( ::SendMessage(CollateHandle, BM_GETCHECK, NULL, NULL) == 
BST_CHECKED ) FCollate = true;
          else FCollate = false;
          Message.Result = ::CallWindowProc( OldCollateWndProc, 
CollateHandle, Message.Msg, Message.WParam, Message.LParam );
          ::SetWindowLong( CollateHandle, GWL_WNDPROC, 
reinterpret_cast<LONG>(OldCollateWndProc) );
      }
    else Message.Result = ::CallWindowProc( OldCollateWndProc, 
CollateHandle, Message.Msg, Message.WParam, Message.LParam );
}
//---------------------------------------------------------------------------

~ JD
Technical Details
Message-ID: <4678eda6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46785769@newsgroups.borland.com> <erog7391dj2s0ivta3ct48v21hhjc72d0e@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,17b336d121cbb12d
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "JD" <nospam@nospam.com>
From: "JD" <nospam@nospam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <46785769@newsgroups.borland.com> <erog7391dj2s0ivta3ct48v21hhjc72d0e@4ax.com>
Subject: Re: Dialog child window
Date: Wed, 20 Jun 2007 04:04:36 -0500
Lines: 98
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 172.146.41.247
Message-ID: <4678eda6@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1182330278 172.146.41.247 (20 Jun 2007 02:04:38 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail