|
What do you mean?
I got the specified h files like CApplication.h and stuff...
and yes, I included them, but as I said, get thousands more errors in those h files.
DKT
|
|
|
|
|
Are you saying that ClassWizard created more than one .h and .cpp file? If so, I've not seen that happen before.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hmm... I found a thing that might help me:
http://www.lordjoe.com/Java2Com/CPPCode.html[^]
But I have the problem with the following line:
hr = Invoke(pdispApplication, DISPATCH_METHOD, &vRet, NULL, NULL,
OLESTR("WorkBooks"), NULL);
if (FAILED(hr))
goto error;
I get: "Member not found".
This means WorkBooks is ok, but something is missing, had the same before for another method.
My question: I am searching for a reference to find the detailed properties for those methods. How to find out, how to invoke those methods correctly?
Damn, C++ and OLE is quiete hard...
DKT
|
|
|
|
|
Anonymous wrote:
How to find out, how to invoke those methods correctly?
See MSDN article Q222101.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Ok, I could solve my problems till now. Thanks for that David!
But I still dont see what methods I can use and which not.
For example: I record a macro which runs another macro.
I see the vb code:
Application.Run
So, If I try to use Invoke with Run as OLESTR, it says "unknown". But other things like add or range work.
What is the methods name for run? Isnt there any paper for all possible methods for non-MFC based c++ OLE code?
MSDN says itself:
C/C++ Automation is much more difficult, but sometimes necessary to avoid overhead with MFC, or problems with #import. Basically, you work with such APIs as CoCreateInstance(), and COM interfaces such as IDispatch and IUnknown.
Yeah, it is difficult, but is it impossible?
Anyway, thanks alot for your help till now David, it helped alot.
DKT
|
|
|
|
|
I have an Excel file with a macro named DisplayMsg. To open that file and run that macro, I used:
_Application app;
Workbooks books;
_Workbook book;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtTrue((short) TRUE),
vtFalse((short) FALSE);
if (app.CreateDispatch("Excel.Application") == TRUE)
{
books = app.GetWorkbooks();
book = books.Open("C:\\Book2.xls",
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
app.Run(COleVariant("DisplayMsg"),
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
} Does that help any?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
No, sorry!
I am using the help files from Microsoft: INVHelp.cpp and INVHelp.h
Those work quiete well. It uses easier ways to use the invoke function.
Here, everything is getting invoked. Like:
V_VT(&v) = VT_I2;
V_I2(&v) = 20;
hr = Invoke(pdispRange, DISPATCH_PROPERTYPUT, NULL, NULL, NULL,
OLESTR("Value"), TEXT("v"), v);
The problem for me is now: I cant use Run or VBProject.
hr = Invoke(pdispWorksheet, DISPATCH_PROPERTYGET, &vRet, NULL, NULL,
OLESTR("VBProject"), NULL);
It gives me "exception error" in hr.
I just cant get it working. Normally this VBProject doesnt need more than the return value, right?
If Id just get this to work...
DKT
|
|
|
|
|
Ok, here my code excerpts:
hr = CreateObject(OLESTR("Excel.Application"), &pdispApplication);
V_VT(&v) = VT_BOOL;
V_BOOL(&v) = TRUE;
hr = Invoke(pdispApplication, DISPATCH_PROPERTYPUT, NULL, NULL, NULL,
OLESTR("Visible"), TEXT("v"), v);
hr = Invoke(pdispApplication, DISPATCH_PROPERTYGET, &vRet, NULL, NULL,
OLESTR("WorkBooks"), NULL);
pdispWorkbooks = V_DISPATCH(&vRet);
V_VT(&v) = VT_I2;
V_I2(&v) = xlWorkSheet;
hr = Invoke (pdispWorkbooks, DISPATCH_METHOD, &vRet, NULL, NULL,
OLESTR("Add"), TEXT("v"), v);
hr = Invoke(pdispApplication, DISPATCH_PROPERTYGET, &vRet, NULL, NULL,
OLESTR("ActiveWorkBook"), NULL);
pdispWorksheet = V_DISPATCH(&vRet);
hr = Invoke(pdispWorksheet, DISPATCH_PROPERTYGET, &vRet, NULL, NULL,
OLESTR("VBProject"), NULL);
Everything works fine till the last invoke. Excel gets started, and a new workbook opened. ActiveWorkBook also works, but not the last invoke. I even cant call ThisWorkbook, same result: exception error...
DKT
|
|
|
|
|
Anonymous wrote:
hr = Invoke(pdispWorksheet, DISPATCH_PROPERTYGET, &vRet, NULL, NULL,
OLESTR("VBProject"), NULL);
Are the first and sixth arguments correct?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I think so.
As I saw in the VBA "code", it is called like that:
ActiveWorkbook.VBProject.VBComponents.Import
What I did: I call "ActiveWorkbook" to get the active workbook. This gets stored in the pdispWorksheet, and is used for "VBProject". (I know this pdispWorksheet is confusing, but its just for testing).
I also tried to take the pdisp of my newly added Workbook directly, but it gets me the same result.
If I use pdispApplication or something like this, it shows me: Unknown method. If I change DISPATCH_PROPERTYGET to something else, I get: wrong member.
So, I thought it should be ok, how I am calling the method. But I dont see any logic why I get exceptions all the time. Theres not much more in this Invoke...
DKT
|
|
|
|
|
What I just found out:
I also got exceptions when Invoking "Run" to run a given macro.
I just found out that it happens cause the macro didnt exist in the sheet.
I put a breakpoint before the run, and created a little macro with the correct name. Then I traced over the run, and wow, it works...
What does that mean for the VBProject? I mean, it doesnt take any parameters, does it?
It just holds a retVal which is from type VARIANT.
DKT
|
|
|
|
|
how can i get a BYTE* from a bmp file?
thankyou
|
|
|
|
|
REPOST !!!
you didn't even way 1 hour !!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
dave2k wrote:
how can i get a BYTE* from a bmp file?
check out this api :- [CBitmap::GetBitmapBits]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have facing a problem. I have a tool bar on a window.
When the child window is resized the tool buttons are obscured which I did like. So solve the problem I used rebar control hosted my tool bars on this rebar when the window is resized now and hides a portion of the toolbar ,a chevron appears. when you click on the chevron a menu pop ups which contains the obscured buttons.
BUT THE PROBLEM is that some of my tool bars contain a combo boxes.
HOW SHOULD I AM I GOING TO MAKE THE MENU DISPLAY MY COMBO BOXES TOO?
ANY IDEA ,ANY ONE
|
|
|
|
|
why wouldn't you make it a sub menu instead ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
both of us share the same point of view but my does not seem to agree with us .
A little while ago i got the idea that instead of using a menu I should create a dialog box where the menu should have appeared .
But i will need your help in doing so.
|
|
|
|
|
hum, i'm not sure i understand what is that new point you want to achieve.
moreover, what is the relation with the first point you asked on the forum ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
What I want achieve is to show a combo in a menu box.
but creating a combox requires it to be created as child window of some other window. But since Menu is not derived from cwnd so we cant make a menu a parent of a combo box. I hope I am clear till this point.
What i am trying to do is not something very new. because in visual studio.net 2003 when you resize tool bars the combo boxes can now appear in the pop up menu that appears when you click the >> (chevron).
What I was trying to suggest was since we cant use the CMenu class now ,we should consider using a dialog box. This dialog log box will appear where the menu appears now when we click the >> button on a tool whose all buttons are not visible.
The dialog will act as a menu and we will make it act like as menu i.e. hightlighting and unhighlighting items when mouse moves over it and destroy it when it loses focus.
I hope I make some sense this time.
if anything is still obscure please ask
|
|
|
|
|
What I want achieve is to show a combo in a menu box.
but creating a combox requires it to be created as child window of some other window. But since Menu is not derived from cwnd so we cant make a menu a parent of a combo box. I hope I am clear till this point.
What i am trying to do is not something very new. because in visual studio.net 2003 when you resize tool bars the combo boxes can now appear in the pop up menu that appears when you click the >> (chevron).
What I was trying to suggest was since we cant use the CMenu class now ,we should consider using a dialog box. This dialog log box will appear where the menu appears now when we click the >> button on a tool whose all buttons are not visible.
The dialog will act as a menu and we will make it act like as menu i.e. hightlighting and unhighlighting items when mouse moves over it and destroy it when it loses focus.
I hope I make some sense this time.
if anything is still obscure please ask
|
|
|
|
|
I'm having a small problem with my test program.
I have a Dialogbased program that has a bunch of buttons.
When I click on one of them, another Dialog appears. This new Dialog has only one button, called
"Continue".
Here's where my problem starts. This new dialog that appears should after a couple of seconds
activate another Dialog. This is done by a timer or Sleep function. The thing is that I manage
to get the third Dialog to appear automatically but I found that the Second Dialog with the button
"Continue" didn't show the button. It's like the Dialog is drawn but not the button.
Hope you understand my problem.
Is there any event that is sent afte the whole Dialog is painted, including the button or other controls?
I've tryed, WM_PAINT, WM_ACTIVATE, WM_SHOWWINDOW.
Please help!
|
|
|
|
|
Hachaso wrote:
When I click on one of them, another Dialog appears. This new Dialog has only one button, called
"Continue".
Here's where my problem starts. This new dialog that appears should after a couple of seconds
activate another Dialog.
Is your third Dialog is Model or ModelLess i.e. is it created with CDialog::DoModal [Model] or CDialog::Create and CDialog::ShowWindow [Modelless].....
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
My thir Dialog is ModelLess.
Hope you have an answer to my problem.
|
|
|
|
|
Hachaso wrote:
Hope you have an answer to my problem.
I can help, But your problem seems to very unique!!.... can you show me little code snippet... so i can dig into you code.....
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
If you want I can attach the whole project.
I'm trying to do this unique things to learn.
Where can I send you all my files?
This way you can see my problem.
|
|
|
|
|