|
Actually you used office 2000 type library.right!Now your application will work fine in all probability for all the later versions.However, try it on a machine with some prior office version(prior than office 2000) & it may fail.
To play safe, it is suggested to use as earliest possible type library,probably office 95.However, there is an exception for access 97 which fails if run on access 2000 machine.Moreover, this early binding is not entirely reliable because some methods may be unavailable.
The solution is late binding which although cost an overhead , it is for multiversion office automation.One hybrid binding(DISPID binding) is also used. i am still going through it to get more info.
I would like anyone to help & shed some light on late binding & hybrid binding(DISPID binding).Looking forward to some ideas,
Regards,
Ankush Mehta
|
|
|
|
|
I don’t have any means for testing. All of my computers are running 2000 or newer and I’m far too lazy to test it anyway.
I do know you incur an initial performance hit with late binding; but after the object has been created the performance should be the same as early.
I guess it comes down to how often are you creating the object (of access I guess in this case). If this is a database based app why not roll your own function that you’re relying on for access?
What are you trying to accomplish?
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
|
|
|
|
|
I assume your trying to use office automation to print an access table as posted here http://www.codeproject.com/script/comments/forums.asp?msg=1298682&forumid=1647#xx1298682xx[^]. Here is a good quick way to dump a recordset to a excel file, then call shellexecute to print that file. Delete it it after your done.
CString str;
str.Format("SELECT * INTO [Excel 8.0;DATABASE=%s].[%s] FROM [%s]", ExcelFile, Worksheet, table);
Create an ADO Connection object to the database then call.
pConn->Execute(str.AllocSysString(), NULL, adExecuteNoRecords);
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
|
|
|
|
|
Well, let me explain the scenario.
i wanted to create an application to print
1) Word Document
2) Text file
3) Excel Sheet
4) Access tables
5) Powerpoint Slide
6) Webpage
7) images(bmp,jpg,jpeg,gif)
i initially started with using automation.As an afterthought, i found 1),2),3),7) can be printed using shell Execute.
However, for 4),5),6) automation is the solution(that is what i think).Since my application is supposed to run on muliversion, Late binding must be used.As a matter of fact, i have even achieved printing using automation but i don't know if it is early binding or late binding and that is where i don't have any idea buddy......
Ankush Mehta
|
|
|
|
|
i need process handle without using Psapi.lib to terminate a application. i have window handle (HWND).
-- modified at 3:56 Wednesday 7th December, 2005
|
|
|
|
|
gpswamy wrote: i have window handle
What about sending WM_CLOSE message using SendMessageTimeout!
gpswamy wrote: i need process handle without using Psapi.lib to terminate a application
The code I send you last night, doesn't depend upon psapi.lib i.e. TerminateProcess uses kernel32.lib and Process32First,Process32Next and CreateToolhelp32Snapshot use toolhelp.lib . {OT}Is your boss at ZI not helping you?
"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 haven't tested this solution but, you can use:
DWORD GetWindowThreadProcessId(HWND hWnd,LPDWORD lpdwProcessId);
to get the thread id that created the window hWnd .
Then use OpenThread(...) to get the thread handle of the thread-id returned by the GetWindowThreadProcessId(...) function. Then use TerminateThread(...);
The requirements for OpenThread(...) are high:
Client:
Requires Windows XP, Windows 2000 Professional, or Windows Me.
Server:
Requires Windows Server 2003 or Windows 2000 Server
this is this.
|
|
|
|
|
CPictureHolder ph;
ph.CreateFromBitmap(IDB_BITMAP1);
m_iml.SetRefListImages(ph.GetPictureDispatch());
//CImageList1 m_iml , it's a class with the activex control
It's a runtime error.
|
|
|
|
|
I want to add new controls to Common dialog boxes. I have gone through the Customizing Common Dialog Boxes article and it does not provides a standard procedure for adding new controls to Common Dialog Boxes.
|
|
|
|
|
I want to use a control called "Microsoft ImageList Control 6.0 (SP6)",
but I don't know how to use it after inserted it to my project.
Thanks.
|
|
|
|
|
Can I restrict a class not to have more than 2 objects?
How it is possiable?
For example:
class CMyClass{};
void main()
{
CMyClass *pCls1 = new CMyClass();
CMyClass *pCls2 = new CMyClass();
CMyClass *pCls3 = new CMyClass();
}
Any one please help me.
Nice talking to you.
|
|
|
|
|
static CMyClass ::Counter=0;<br />
<br />
initilaize a static member to zero;<br />
CMyClass()<br />
{<br />
CMyClass ::counter++;<br />
<br />
if(CMyClass ::Counter>2)<br />
{<br />
this->~CMyClass()<br />
return;<br />
}<br />
<br />
}<br />
<br />
~CMyClass()<br />
{<br />
if(CMyClass ::Counter>2)<br />
{CMyClass ::counter--;<br />
return;<br />
}<br />
CMyClass ::counter--;<br />
}<br />
//dont go for default constructor
-- modified at 3:04 Wednesday 7th December, 2005
|
|
|
|
|
Thank you.
I also thought near to you.
class CMyClass{
public:
static int i;
CMyClass()
{
++i;
if(i>2)
{
printf("cannot create more than 2 instances");
~CMyClass();
}
}
~CMyClass()
{
--i;
}
};
void main()
{
CMyClass *pCls1 = new CMyClass();
CMyClass *pCls2 = new CMyClass();
CMyClass *pCls3 = new CMyClass();
}
But my friend sayingthat
Look up Singleton design pattern, since this is related to such a design pattern. Basically, you make the constructor private, and provide a public static member function to create an object. The static function controls whether to actually create a new object, or return one of the already created objects. Can I expect the solution in this way.
I dont know what is design patterns? Please help me.
Nice talking to you.
|
|
|
|
|
just know i have modified it.Check it
|
|
|
|
|
Just look at my other solution if you want something build on the singleton design pattern. It is the same pattern except that it allows creation of @ instances instead of just one
|
|
|
|
|
There is some problems with this implementation: first, what will happen if you do this:
CMyClass class1;<br />
CMyClass class2;<br />
CMyClass class3;
Then you will have a little problem .
And, what will return the new when you call the destructor inside the constructor ? I don't think it is a good idea to destruct an object that is not completely constructed, this could lead to some big troubles (pointers not initialized, ...).
|
|
|
|
|
sunit5 wrote: ForumVisual C++
Subject:Re: Can I restrict a class not to have more than 2 objects?
Sender:sunit5
Date:2:52 7 Dec '05
static CMyClass ::Counter=0;
initilaize a static member to zero;
// class constructor
CMyClass()
{
CMyClass ::counter++;
if(CMyClass ::Counter>2)
{
// call the destructor
this->~CMyClass()
return;
}
Hello Sir, AFAIK is know Explicit call to the Destructor is not good programming Practice.
"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
|
|
|
|
|
sunit5 wrote: CMyClass()
{
CMyClass ::counter++;
if(CMyClass ::Counter>2)
{
// call the destructor
this->~CMyClass()
return;
}
AFAIK, Whatever Goes.. The Object is still created.. but in your case destructor will call two times... here a dummy source code that will demonstrate that :-
#include<iostream.h>
class Classa
{
public:
Classa()
{
cout<<"in const"<<endl;
this->~Classa();
}
void print()
{
cout<<"abc"<<endl;
}
~Classa()
{
cout<<"In Dest"<<endl;
}
};
void main()
{
Classa a;
a.print();
}
calling Destructor doesn't mean the object is destroyed.. it is for doing cleanup tasks at end
"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
|
|
|
|
|
Here is another approach, a little bit more 'protected' than the one from sunit.
First, put your constructor and destructor private. This will prevent to create an instance of the class when it's not allowed. So for example you won't be able to do that:
CMyClass MyClass;
As the constructor is protected, you will have a compile error.
Then, to be able to get an instance of the class, declare a static member function (it must be static so it can be called without having an instance of the object). You need to have also a static counter that counts the number of instances (it must be static as it must be shared among all instances):
class CMyClass<br />
{<br />
public:<br />
static CMyClass* GetNewInstance();<br />
<br />
protected:<br />
CMyClass();<br />
~CMyClass();<br />
<br />
private:<br />
static int m_iCounter;<br />
}
int CMyClass::m_iCounter = 0;<br />
CMyClass* CMyClass::GetNewInstance()<br />
{<br />
if (m_iCounter<2)<br />
{<br />
m_iCounter++;<br />
return new CMyClass;<br />
}<br />
return NULL;<br />
}
Now, the last thing to add is to be able to free the memory (and then decrement the counter when one of the object is freed). Add a public Destroy method:
void CMyClass::Destroy()<br />
{<br />
m_iCounter--;<br />
delete this;<br />
}
So, when you need a new instance of the object, call GetNewInstance:
CMyClass* NewClass = CMyClass::GetNewInstance();
It will return the new instance if succesfull or NULL if 2 instances already exists. Then, don't forget to free your object when not needed anymore:
NewClass->Destroy();
-- modified at 3:20 Wednesday 7th December, 2005
Sorry, I forgot to put my GetNewInstance function static
|
|
|
|
|
Hello,
It kinda scares me that the 'calling destructor inside constructor' solution was brought foward before this one! It's just scary to see that some people even think about doing that...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
nobody's perfect and we have to get them back on the right way
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|
You are really great. This is the reason I like you & your simplisity.
Nice talking to you.
|
|
|
|
|
Would you actually want the instantiation of the third object to fail, or would it suffice to make the object's methods unavailable if more than two exist?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Try the following:
1. Create a windows form application in Visual Studio (2003)
2. Set form background image to a picture. (mine is a 24 kb PNG file)
3. Create a textbox in the form. (AutoSize = false, Multiline = true)
4. Set form Opacity to < 100% (I set it to 50%)
Now run the program and type in the textbox. Just before the text "overflows", instead of smoothly auto scrolling the text down, my screen freezes for a good 20 secs. After doing this for a couple of times I get a ialmrnt5 display driver fail error and my Windows XP crashes and restarts.
Has this happened to anyone else? Is there a way around this? Thanks.
|
|
|
|
|
Hi,
How do I retrieve data in 5th parameter of this API. Since I dont know what will be the length of data n how will I allocate memory to this param???
Even if I declare array of maximum size it gives me error "234" i.e. "ERROR_MORE_DATA"
Here is sample code...
DWORD dwretrievedDataType = NULL;
DWORD dwretrievedLenOfData = NULL;
LPWSTR wzretrievedData = NULL;
.
.
.
// I have already given proper values for 1st 3 params
dwretValue = SHGetValue(hkeyRoot, wzkeyPath, wzvalueOfKey,
&dwretrievedDataType, wzretrievedData, &dwretrievedLenOfData);
.
.
.
PLz do let me know asap if anyone knows abt it...
thanks n regards
Supriya Tonape
|
|
|
|