|
I need to create a dll component that shows dialog form that performs some things.
This component have to match to work in client program of Delphi.
So Which type of dll I need create for it ? (ATL/ ACTIVE X or another )
-----------------------------------------------------------------------
I maked it as MFC Extention DLL but it works only in client program of VC (not in Delphi !)
------------------------------------------------------------------------
Please help ! It is very urgent !!!
|
|
|
|
|
I maked it as MFC Extention DLL but it works only in client program of VC (not in Delphi !)
extension dll's work just in mfc... so you can't use em in delphi, visual basic or whatever..
i am not expert.. but if you want to use the component everywhere you have to use
ActiveX or COM..
to decrease size of the component it is better if you implement it using ATL and not MFC... that makes the whole dll smaller and you don't have to link with the MFC (static or dynamic linking)...
if you need tutorials building a component see the sections in codeproject...
hope this helps a little bit
bernhard
stolen sig #18
"Pseudocode is code to demonstrate a concept, not designed to be run. Like certain Microsoft software. "
|
|
|
|
|
Thank you.
So you suggest me to use in ATL.
But I understood that there are problem in ATL if I want to use in class CDialog of MFC and I need use Dialog form as basis to my implementation.
What do you say about it ?
|
|
|
|
|
You can use a dialog resource to make an ATL dialog, but you won't use any MFC classes, like CDialog. There are ATL equivalents of these. In the ATL object wizrd thingy, under the miscellaneous tab, there is a "dialog" option. Chose that. You'll have an ATL dialog. The resulting dialog is NOT a COM object yet, though. Go back into the new object wizrd thingy, and select new Simple object, and make a COM object that contains an instance of the dialog class as a member, and expose functionality of the dialog through the COM objects interface. Then you can use the dialog in VB, or wherever COM objects may be used.
|
|
|
|
|
|
or you can use WTL (Windows Template Library) for your dialogs
|
|
|
|
|
Manny Thanks !
IN ATL :
Can I insert dialog by Go to Insert ATL Object, Select Category - Miscellaneous and double click on Dialog.
Which is option better ? (ATL or WTL) and why ?
Remmember : I need it for another language (Delphi) !
|
|
|
|
|
HO !! I'm in troubles
I try to add to ATL project dialog in two ways and there are problems
If I add a sinple dialog in resources as Aron suggest and I create class for the dialog I gets errors because it is base :MFC CDialog
If I Insert ATL Object, Select Category - Miscellaneous - Dialog.
I see that the code that I gets from the wizard is very strange and I dont know how to add my methods to that class.
|
|
|
|
|
MFC can be used in ATL projects. I don't tend to use it now but it can be used. So if you want to try the MFC route, post the errors and related code and we'll see if we can't help you out.
If you want to go the straight ATL route, there is a bit of a learning curve from MFC because the code is slightly different to MFC classes. What methods are you trying to add to your class?
Michael
|
|
|
|
|
The errors that I gets if I trys to add class from base CDialog for my dialog resource are:
c:\windows\שולחן עבודה\222\dlg.h(14) : error C2504: 'CDialog' : base class undefined
c:\windows\שולחן עבודה\222\dlg.h(17) : error C2629: unexpected 'class Dlg ('
c:\windows\שולחן עבודה\222\dlg.h(17) : error C2238: unexpected token(s) preceding ';'
c:\windows\שולחן עבודה\222\dlg.h(21) : error C2065: 'IDD_DIALOG1' : undeclared identifier
c:\windows\שולחן עבודה\222\dlg.h(21) : error C2057: expected constant expression
c:\windows\שולחן עבודה\222\dlg.h(30) : error C2061: syntax error : identifier 'CDataExchange'
c:\windows\שולחן עבודה\222\dlg.h(41) : error C2143: syntax error : missing ';' before '}'
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(18) : error C2065: 'CWnd' : undeclared identifier
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(18) : error C2065: 'pParent' : undeclared identifier
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(19) : error C2448: '<unknown>' : function-style initializer appears to be a function definition
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(19) : error C2143: syntax error : missing ';' before ':'
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(20) : error C2448: '<unknown>' : function-style initializer appears to be a function definition
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(27) : error C2065: 'CDataExchange' : undeclared identifier
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(27) : error C2065: 'pDX' : undeclared identifier
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(28) : error C2448: '<unknown>' : function-style initializer appears to be a function definition
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(36) : error C2061: syntax error : identifier 'CDialog'
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(40) : error C2146: syntax error : missing ';' before identifier 'END_MESSAGE_MAP'
C:\WINDOWS\שולחן עבודה\222\Dlg.cpp(40) : fatal error C1004: unexpected end of file found
Generating Code...
Error executing cl.exe.
222.dll - 18 error(s), 0 warning(s)
_____________________________________________________
I anderstand that the normal way in my case is to use
the straight ATL route.
I need add manny code to this class , mainly to the methods OnOK and OnDestoy.
Can I use simple code that I use in MFC ?
|
|
|
|
|
Hi,
Inside of the constructor of an object, I want to specify a callback routine which belongs to the same object (member function). How can I do this
If my callback routine is static everything's ok, but I need a different callback routine for every object.
I read something about wrappers which should work fine if I could write the code for the caller, but I can't because it's an OpenGL function:
glutDisplayFunc (pointerToMyMemberFunction);
In the above line (which I want to use in my object's constructor) I tell OpenGL which function it has to call when the time has come to refresh the screen.
I could do something non-object-oriented with an array of function-pointers, but that's not nice
Can anyone help me??
|
|
|
|
|
See the VC forum FAQ.
--Mike--
http://home.inreach.com/mdunn/
"Listen you footwarriors, can you hold down a bit with the firing? I've just got three impromptu weddings breaking out behind me!" -- Arthur Dent
your with and
|
|
|
|
|
I had a look but it says there:
"Windows APIs that use a callback function have a void* parameter that you can use for whatever purpose you like"
The problem is that
glutDisplayFunc (pointerToAFunction);
is not a window API !!!
So there's no possibility to pass two arguments like
glutDisplayFunc (pointerToAFunction,(void*) this );
Any other suggestion
|
|
|
|
|
Doing stuff like this within a constructor is error prone, since the object is not fully constructed until the constructor returns. You might want to have a separate init() method that properly initializes the object.
This requires that a user of your object ALWAYS call init() after constructing it. To ensure this, you should have a static method that serves up properly initialized objects, and make the default constructor protected. For example:
CMyObject* pObject = CMyObject::newInstance();
ASSERT (pObject != NULL);
ASSERT (pObject->isValid()); /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi
I am invoking dialogbox from applications InitInstance(). Can I handle IDOK button message of dialog from document object?. Can you help if you can handle..
Thank you
Srinivasa Raju Bhairraju
Member - Technical
Cysphere.com Pvt Ltd
Ashoka Bhopal Chambers
S.P.Road
Secunderabad - 3
Email: sraju@cysphere.com
|
|
|
|
|
If the dialog box is modeless, then you can catch WM_COMMAND. If it's modal, then obviously you don't have a hope in hell.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I had written a dialog based application.
It contained a button named "Try"
When I clicked the "Try" button,opened an other
dialog named "Test" which contained a button named "Open".
When I first clicked "Open" button and clicked the "OK"
button in Open File Dialog,everything is ok,and then
close the "Test" Dialog.
But When I click "Try" button again,it showed me wrong.
Who can please tell me what's wrong with my code??
******************************************************************
void CFirstDlg::OnButtonTry()
{
// TODO: Add your control notification handler code here
CTestDialog* dlg;
dlg=new CTestDialog;
dlg->DoModal();
}
******************************************************************
BOOL CTestDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString sCon;
_ConnectionPtr m_pCon;
_RecordsetPtr m_pRs;
sCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=main.mdb";
CoInitialize (NULL);
HRESULT hr=S_OK;
try
{
hr=m_pCon.CreateInstance(__uuidof(Connection));
if(FAILED(m_pCon->Open(_bstr_t(sCon),"","",adModeUnknown)))
AfxMessageBox("Can not open the database!");
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("Failed!\r\nError Message:%s",e.ErrorMessage());
AfxMessageBox(errormessage);
}
m_pRs.CreateInstance("ADODB.Recordset");
if(FAILED(m_pRs->Open("SELECT * FROM employeer",_variant_t((IDispatch*)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText)))
AfxMessageBox("Can not open the record set!");
if((m_pRs->State & adStateOpen) == adStateOpen)
m_pRs->Close();
if ( (m_pCon->State & adStateOpen) == adStateOpen)
m_pCon->Close();
CoUninitialize();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
***********************************************************************
void CTestDialog::OnButtonOpen()
{
// TODO: Add your control notification handler code here
static char BASED_CODE szFilter[]="Bitmap Files (*.bmp)|*.bmp||";
CFileDialog *fd;
fd=new CFileDialog(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFilter,this);
if(IDOK!=fd->DoModal())
return;
else
AfxMessageBox(fd->GetFileName());
delete fd;
}
|
|
|
|
|
at a quick glance, you're not deleting the memory you allocate for CTestDialog. Why not use:
<br />
void CFirstDlg::OnButtonTry() <br />
{<br />
CTestDialog dlg;<br />
dlg.DoModal();<br />
}<br />
Also you're not freeing memory in your OnButtonOpen() if the dialog doesn't return IDOK.
What is the error message, is it a com exception or unhandled exception?
I'd also consider setting all com pointers to null before calling CreateInstance. eg.
<br />
pConnection = NULL;<br />
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));<br />
|
|
|
|
|
Because I am a beginner of VC++ from China,and the error message was showed in Chinese,I only know the error number is 0x80004005,I don't know what is means?Please Help me.
|
|
|
|
|
I've been playing with ADO a bit lately and I've found that if you pass in a bad string, it crashes, and crashes HARD.
if(FAILED(m_pRs->Open("SELECT * FROM employeer",_variant_t((IDispatch*)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText)))
Is 'employer' spelled wrong in the database as well ? If not, a typo here would cause a crash every time, and not a graceful or easily traceable one.
I'd also suggest it is poor form to name local variables m_, that indicates a member variable ( one declared in your header file and therefore visible to the entire class ).
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Do you need to end a statement with a ';' too? as in,
<br />
pCommand->CommandText = _bstr_t("SELECT `tblImages`.* FROM `tblImages` WHERE `tblImages`.`visitID` = `param1`;");<br />
|
|
|
|
|
No, I don't believe so ( the code is at home so I cannot check, but I don't think SQL wants a ; ).
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
No,I means when I click the "Try" button again,the wrong message appeared,while when I first clicked the "Try" button,everything is OK.
I tried to change my code with an other way such as:
CFirstDialog::OnButtonTry()
{
CTestDialog dlg;
dlg.DoModal();
}
It's still wrong.
Because I use Chinese,so the error message was showed in Chinese,I only know the error number is 0x80004005,what it means?
|
|
|
|
|
The following code will translate an error number for you
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
0x80004005,
0,
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
In this case it is 'unspecified error', which is what ADO always seems to give ( but it could well come from elsewhere all the same ).
Changing your code as you have done is obviously a step forward, no need for a pointer, plus an ugly memory leak. You should do the same for your FileDialog, or at least delete the thing if people press cancel.
Are you trying to run in F5 ( debug ) mode ? Are you pressing cancel and letting the debugger show you where it is crashing ? If the above code is crashing ( just a domodal() call, then it's dying in the dialog code, and I would continue to maintain in your ADO code. You should set a break point and step through the OnInitDialog as a first step. Are you closing your connection to the database ? It may well be crashing the second time because your first connection is still open.
Also your database path is not absolute, if something else in the dialog is changing the current directory, that will also mean it cannot find the file and will crash.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thanks,you're right.
When I open the "Open/Save File Dialog",it changed the current directory.
It cannot find the database,so the wrong message appeared.
Thanks again.
|
|
|
|