|
Hi
in my project i import msado15.dll to opetate data from database
now i want to let the data can print in ms-word,so i
#import "C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.dll" rename_namespace("AAA")
but it said:
error C2011: '_Application' : 'class' type redefinition
error C2011: '_Global' : 'class' type redefinition
error C2011: 'FontNames' : 'class' type redefinition
error C2011: 'Languages' : 'class' type redefinition
error C2011: 'Language' : 'class' type redefinition
error C2011: 'Documents' : 'class' type redefinition
error C2011: '_Document' : 'class' type redefinition
..........................
i know it should rename_namespace, but i am a fresh man, i can not find example
how can i work this problem, how to rename namespace, and what name should be renamed
thanks a lot
Sincerely
|
|
|
|
|
Are you using the same namespace name in both #imports ?
If both DLLs contain the _Application object you will get this error.
So try this -
#import msado15.dll rename_namespace("AAA")
#import mso.dll rename_namespace("BBB")
Now you can access the ADO object as AAA::_Application and the Office object as BBB::_Application .
|
|
|
|
|
can i use
#import msado15.dll no_namespace
#import mso.dll rename_namespace("BBB")
because if msado15 renamed,my project many code should be modified,because msado's method i have used
thanks a lot
|
|
|
|
|
Sure.
Now you can access MSADO15's class as just _Application and MSO's class as BBB::_Application .
|
|
|
|
|
|
Have you tried something like:
#import <mso.dll> rename("_Application","_MSOApplication") Although Superman's suggestion is a bit cleaner.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Dear,
how to get and print dial-in tab properties of user object in active directory using c++
|
|
|
|
|
I've some dialogs that I use as child dialogs in a FormView driving them with a TabControl.
My problem is that when dialogs are shown, they doesn't catch events like mouse click, so that
the user cannot handle any control inside the window.
If I switch the windows property from Child to Popup any control works properly but the windows are
not shown correctly within the TabControl.
So.. how can I let all events work fine for child dialogs ?
|
|
|
|
|
My only thought is that the windows are visible, but disabled.
Use Spy++, and check the WS_VISIBLE / WS_DISABLED for the windows involved.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
I have a static class I use for caching data. This will now be accessed from multiple threads which means I need to add a CRITICAL_SECTION to make updating the cache thread safe. I now have the problem of who initialises the CRITICAL_SECTION given a static class doesn't have a constructor.
std::map<int,std::string> CMY_CACHE::m_cache_map;
CRITICAL_SECTION CMY_CACHE::m_critical_section;
class CMY_CACHE
{
private:
static std::map<int,std::string> m_cache_map;
static CRITICAL_SECTION m_critical_section;
public:
std::string read(int index)
{
EnterCriticalSection(&m_critical_section);
std::map<int,std::string>::iterator it=m_cache_map.find(index);
if (it==m_cache_map.end())
{
}
LeaveCriticalSection(&m_critical_section);
return(it->second);
}
...
std::string s=CMY_CACHE::read(0);
modified on Friday, October 16, 2009 8:28 AM
|
|
|
|
|
Instead of having all members static, you could use a singleton pattern: it is a design pattern that makes sure your class is created only once. I won't go into much details here but I suggest you google for "Thread safe singleton pattern". Basically, you add a public static function that returns a pointer to your single instance (CMY_CACHE* CMY_CACHE::instance for example).
Once your class is a singleton, you can simply create your critical section in the class constructor. Your read method is no more a static function and you call it this way:
CMY_CACHE::instance()->read(0);
|
|
|
|
|
The quick & dirty (you're warned...) trick: wrap the CRITICAL_SECTION in a struct and do initialization (cleanup) in struct constructor (destructor).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
... or, instead of a singleton, you could write a CRITICAL_SECTION wrapper class.
e.g. something like
class CS : public CRITICAL_SECTION
{
public:
CS( ulong SPINCOUNT = 4000 ) {
#ifdef _DEBUG
::InitializeCriticalSectionEx(this, SPINCOUNT, 0);
#else
::InitializeCriticalSectionEx(this, SPINCOUNT, CRITICAL_SECTION_NO_DEBUG_INFO);
#endif
}
~CS() {
::DeleteCriticalSection(this);
}
};
then use it wherever you used CRITICAL_SECTION.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Anyone know the code for Handling keyboard strokes like enter,delete in TreeCntrl?
|
|
|
|
|
BOOL CTreeCtrlPlus::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_RETURN)
{
TRACE(_T("VK_RETURN\n"));
}
if (pMsg->wParam == VK_DELETE)
{
TRACE(_T("VK_DELETE\n"));
}
}
return CTreeCtrl::PreTranslateMessage(pMsg);
}
In the header file, insert:
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
|
|
|
|
How to show/hide CWebBrowser2 control? the ShowWindow(...) function is not working for the control.
|
|
|
|
|
Are you using OleCreate() to create the browser object?
|
|
|
|
|
I have a project (VS6 C++ MFC) and my 'project.rc' file appears to be corrupted or somehow has missing data - all has been working fine until recently, is there any easy way to recover the missing data?
|
|
|
|
|
Caslen wrote: appears to be corrupted or somehow has missing data
How do you know that? Are you getting an error message?
|
|
|
|
|
Yeah I perhaps should have mentioned that when I try to open the resources for the project in the resource view I get a "Guideline must specify type" message whatever that means. Also I have an older version of the file which has lines missing that I am pretty sure aren't due to any of my edits
|
|
|
|
|
I am writing a multithreaded TCP Server Application(MFC).
I have written simple TCP server earlier n it worked fine. The tutorial I used told that for
multithreaded server I have to use more than one Socket variable and It also told that the server
should spin individual thread for every client.
But I think I am writing wrong code.
Where am I going wrong? any suggestions please.
My Code looks like this:-
class CsockDlg : public CDialog
{
public:
CsockDlg(CWnd* pParent = NULL);
.
.
.
private:
CMySocket m_sListenSocket;
CMySocket m_sConnectSocket;
public:
void OnAccept(void);
void OnConnect(void);
void OnClose(void);
void OnReceive(void);
void OnSend(void);
static UINT ThreadServer(LPVOID pParam);
void TS(void);
};
BOOL CsockDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
.
.
.
int m_iPort = 4000;
m_sListenSocket.Create(m_iPort);
m_sListenSocket.Listen();
return TRUE;
}
void CsockDlg::OnAccept(void)
{
AfxBeginThread(ThreadServer, this);
}
UINT CsockDlg::ThreadServer(LPVOID pParam)
{
CsockDlg* O = (CsockDlg*)pParam;
CMySocket c;
O->m_sListenSocket.Accept(c);
return 0;
}
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Question: Where did you get that example from?
There are plenty of examples out there that can help setting up a working networking application (with or without multi threading). For some examples using sockets see Winsock FAQ[^].
/M
Future lies in the future.
|
|
|
|
|
Tutorial was only for Simple TCP server.
This is my experimental code.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Please have a look at the link I posted, perhaps you can find something that fits your needs. If you want to write a GUI application with networking it could be worth to have a look at event-based examples (e.g. using MFC's CAsyncSocket ) it saves you the hassle of using threads and locks.
Btw, there are other socket libraries than MFC out there:
* Alhem
* Boost
* SharkEngine
* QT
* and many others
Hope it helps!
The past lies in the future
|
|
|
|
|
Calculate factorial of any number less than 10000,but I don't know how to start with? I just want to get an idea, not the source code.
|
|
|
|