|
I simplified as follows and it seems to have done the trick. Thanks.
HTREEITEM hTreeItem = pMyTree->InsertItem(_T(buffer),0,0,NULL, TVI_LAST);
-kg
Ken Goguen
Principle Design Engineer
EMC Corporation
|
|
|
|
|
I'm working on a non-MFC DLL (that doesn't have a DllMain). I need to get the HINSTANCE of this DLL (for use inside the DLL). How do I do that?
I can't use AfxGetInstance().
|
|
|
|
|
If your DLL doesn't have DllMain, it must have other entrypoint with identical set of parameters. 1st param is HINSTANCE you're looking for - just store the value in global variable.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am new to OleAutomation. I am trying to execute an Access macro from VC++. I believe I am missing something. It doesn't work. The code is attached below.
_Application oAccess;
IDoCmd cmd;
LPDISPATCH lpDisp;
/////////////////////////////////////////////////////////////////////////////
// CTemp1App initialization
BOOL CTemp1App::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
if (!oAccess.CreateDispatch("Access.Application"))
{
AfxMessageBox("Couldn't CreateDispatch on Access");
}
oAccess.OpenCurrentDatabase("S:\\Ses\\User\\VKaruppiah\\Upfitter97.mdb", FALSE);
COleVariant macroName = "GMDIDProcessing";
COleVariant repeatCount = "";
COleVariant repeatExp = "";
cmd.RunMacro(macroName, repeatCount, repeatExp);
cmd.ReleaseDispatch(); // Release the object-IDispatch binding.
oAccess.ReleaseDispatch();
cmd = NULL; // Destroy the object references.
oAccess = NULL;
}
Any help would be greatly appreciated.
Thanks,
|
|
|
|
|
Which bit of code fails? Have you put any try and catch code around the COM calls to access.
Michael
|
|
|
|
|
The code does not fail anywhere. But it doesn't run the macro either. The line that is giving me trouble is
cmd.RunMacro(macroName, repeatCount, repeatExp);
If I put a watch on cmd after executing this line, m_lpDispatch value = "Error expression cannot be evaluated".
Any ideas/suggestions would be appreciated.
Thanks,
|
|
|
|
|
put a try and catch around the RunMacro and see what error it returns
try
{
cmd.RunMacro(macroName, repeatCount, repeatExp);
}
catch(CException& e)
{
}
|
|
|
|
|
Yes you need to acces to the CommandInterfase from the database interfase.
Something like this
lpDisp = oAccess.GetCommands();
ASSERT(lpDisp);
cmd.AttachDispatch(lpDisp);
Note: I don't know if the method is GetCommand or something like this.
Best Regards!!!
Carlos Antollini.
|
|
|
|
|
Hi,
I did add the above lines in the program but it doesn't solve it. The method is GetDoCmd() which is what I used. May be I am including these lines in the wrong place. Attached below is my code. Any idea what I am doing wrong?
if (!oAccess.CreateDispatch("Access.Application"))
{
AfxMessageBox("Couldn't CreateDispatch on Access");
}
oAccess.OpenCurrentDatabase("S:\\Ses\\User\\VKaruppiah\\Upfitter97.mdb", FALSE);
COleVariant macroName = "GMDIDProcessing";
COleVariant repeatCount = "";
COleVariant repeatExp = "";
lpDisp = oAccess.GetDoCmd(); //Get an IDispatch pointer. I think
//that Here is your problem
ASSERT(lpDisp);
cmd.AttachDispatch(lpDisp);
cmd.RunMacro(macroName, repeatCount, repeatExp);
oAccess.CloseCurrentDatabase();
cmd.ReleaseDispatch(); // Release the object-IDispatch binding.
oAccess.ReleaseDispatch();
cmd = NULL; // Destroy the object references.
oAccess = NULL;
Thanks,
|
|
|
|
|
I don't have a MS Access in my work but I promise that I can see your problem in my home. If you want that, please send me the mdb file to carlos.antollini@nixor.com.ar.
Bests Regards.
Carlos Antollini.
|
|
|
|
|
Hi,
For data sensitivity reasons, I won't be able to send you the actual database. But I can give you a good feel for what is in the database. Some tables and a macro that has 2 steps. TransferText (this file xxx.txt that gets loaded into the database)and OpenQuery (opens a query and loads the result data into a table). I want to execute this Macro from VC++ through OleAutomation.
Your help is very much appreciated.
Thanks,
|
|
|
|
|
I Understand, Don't worry for that, I will see your code in my home.
Best Regards!!!
Carlos Antollini.
Happy Friday!!!
|
|
|
|
|
Is there a trick to radio buttons where each button themselves may have a grouping of radio buttons? I want my sub-buttons to be disabled until the "parent" choice is selected.
Thanks.
|
|
|
|
|
Will this help?
http://codeproject.com/staticctrl/ccheckstatic.asp
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I think you want the "parent" buttons to belong to one group, and each collection of "sub-buttons" belong to individual groups.
Also, this seems like a good candidate for a mediator pattern. The sub-buttons would be listeners of the mediator. When a parent radio button is (un)checked, a message would be sent to the mediator, which would fire notifications to the sub-button. A sub-button would query the mediator for its enabled/disabled state.
You can also use the mediator to set focus to a specific group of sub-buttons when a parent is clicked. This makes the GUI user-friendly.
Finally, I would consider a different GUI approach. Choices within choices are easier to select when only ONE value of the parent is known at any time. For example, the parent radio buttons could be replaced by a single combo box which would cause a different set of sub-buttons to appear. You could also use one of these approaches:
http://codeproject.com/property/saprefs.asp
http://codeproject.com/dialog/ezoptionsdlg.asp
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I've developped a good control, I want to do an active X whit it, I still don't know anything about it... someone know a good tutorial
thanks
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
Hi ,I am trying to connect to an Access DB created using Access 2000.I am using VC6SP5.I keep on getting the CDaoException "Unrecognised Database Format".Even when trying to create a class out of class wizard , i get the same error.I have MDAC2.6 + Jet drivers installed.Am i doing something wrong???What do i need to do to make it work??
Thanks for your help.
|
|
|
|
|
Visual C++ Wizard don't support Access 2000 database, but anyway you can access it from a Visual C++ app.
Add this code
CMyApp::InitInstance()
{
AfxGetModuleState()->m_dwVersion = 0x0601;
// ....... your needs
}
If you to create an Access 2000 Database
CDaoDatabase db;
db.Create("NewDatabase.mdb",dbLangGeneral,0x40); // 0x40 DB Version
For additional information, please see the following article in the Microsoft Knowledge Base:
236991 PRB: Unrecognized Database Format Error with Access 2000 Database
|
|
|
|
|
I have been building alot of 'Explorer' like apps lately in MFC. You know the type, TREEVIEW on the left and LISTVIEW on the right. Everytime he reviews what I have done, he sighs, and comments how great it would be to have the ability to move the border between the two controls (in an Explorer - esque) fashion.
Could some one point me in the direction of some MFC code to do this ?
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
I did something like that once by setting the cursor to an arrow in SetCursor if I was on the edge of the line, and simultaneously setting a bool to tell me if the user pressed the left button and started using the mouse I'd be repositioning controls. It's not hard to do, just call SetWindowPos or MoveWindow on the controls ( I like SetWindowPos because you can specify SWP_NOMOVE and just provide a size for the tree control ).
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 am developing in CE,
OnMouseMove doesn't seems to work doh!
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
|
The MFC AppWizard can make an Explorer-style app, with two views in a splitter. You might want to make a dummy project with that wizard to see how it's done.
--Mike--
http://home.inreach.com/mdunn/
Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese?
Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?
|
|
|
|
|
HRESULT hr=ADsGetObject(L"WinNT://chenway",
IID_IADsContainer,
(void**)&pSchema);
LPOLESTR szBuffer = new OLECHAR[MAX_PATH*2];
wcscpy(szBuffer,L"cn=");
wcscat(szBuffer,L"TestAttrName");
if (!pSchema)
return E_POINTER;
hr = pSchema->Create(L"attributeSchema",szBuffer,&pDisp);
the pDisp pointer is returned NULL?why?
I want to add the user class a new attribute.
|
|
|
|
|
Hi, all!!!
==========
I want to create my own DataBase.
new and improved DataBase,
fast and efficient DataBase,
source free Data Base...
But I have a little tiny problem:
I don't know where to begin
please help
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|