Oren (Halvani.de) <neroniker>wrote in message
Quote
when I try to compile the code you gave me I'll get these
error-messages:
[C++Error] Unit_Details.cpp(218): '_fastcall
Dialogs::TCommonDialog::TaskModalDialog(void *,void *)' is not
accessible.
[C++Error] Unit_Details.cpp(218): Use . or ->to call '_fastcall
Dialogs::TCommonDialog::TaskModalDialog(void *,void *)'.
Well, I assure you that I compiled and ran my code before I posted it,
in BCB3. I realize you can't post an entire project in a newsgroup,
so you probably haven't shown the real cause of these errors. I
suspect that your code wasn't in this kind of class (and better yet,
in a separate .cpp):
class PACKAGE TResizeableDialog : public TOpenDialog
{
}
I think the easiest way to build a new component is to use File|New|
Choose "Component", but you *don't* have to "install" the component to
use it. That's a distraction with many pitfalls! In the Component
wizard, chose TOpenDialog as "Ancestor", and type TResizeableDialog as
the "Classname". But do note that you have to Save the component
files in order to #include the new component header for use in your
little Form1 test program. Here are some more complete files. In
fact, you don't have to use the New Component wizard, you can just
write the constructor (which is empty) and TaskModalDialog, if you
know how to write a derived C++ class. Because I don't have access to
BCB3 today, this was done in BCB6. That means you probably *can't*
just paste in this code, you have to use the BCB3 wizard, or just
write a new .cpp file with the constructor and TaskModalDialog as the
only other member function.
Test program in Form1:
i.e. Don't do any of your own special coding until this skeleton
works!
// ----
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "ResizeableDialog.h"
// ---
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
// ----
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
TResizeableDialog * rsd=new TResizeableDialog(this);
rsd->Title="Oren's Test";
rsd->Execute();
Application->Terminate();
}
// ----
Component header file:
// ----
#ifndef ResizeableDialogH
#define ResizeableDialogH
// ----
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Dialogs.hpp>
// ----
class PACKAGE TResizeableDialog : public TOpenDialog
{
private:
protected:
BOOL __fastcall TResizeableDialog::TaskModalDialog(void * DialogFunc,
void* DialogData); // override Dialogs::TOpenDialog method
public:
__fastcall TResizeableDialog(TComponent* Owner);
__published:
};
// ----
#endif
BCB Generated .cpp with override pasted in:
// ---
#include <basepch.h>
#pragma hdrstop
#include "ResizeableDialog.h"
#pragma package(smart_init)
// ---
// ValidCtrCheck is used to assure that the components created do not
have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TResizeableDialog *)
{
new TResizeableDialog(NULL);
}
// ----
__fastcall TResizeableDialog::TResizeableDialog(TComponent* Owner)
: TOpenDialog(Owner)
{
}
#define OFN_ENABLESIZING 0x00800000
BOOL __fastcall TResizeableDialog::TaskModalDialog(void * DialogFunc,
void* DialogData) // override Dialogs::TOpenDialog method
{
((LPOPENFILENAMEA)DialogData)->Flags =
((LPOPENFILENAMEA)DialogData)->Flags | OFN_ENABLESIZING;
((LPOPENFILENAMEA)DialogData)->hInstance =
(void*)FindClassHInstance(this->ClassType());
return TCommonDialog::TaskModalDialog(DialogFunc, DialogData);
}
// ----
namespace Resizeabledialog
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TResizeableDialog)};
RegisterComponents("Samples", classes, 0);
}
}
// ----
This was coded and run in BCB6 WinXP Pro, (but it's unnecessary
because TOpenDialog *is* resizeable there.)