|
Can I please re-phrase your word?
1. For COINIT_APARTMENTTHREADED (single threaded apartment), I created a control in thread A (which had make a call to CoInitializeEx). If there is another thread B wish to use the control, thread B had to make call to CoInitializeEx/ CoUninitialize before/ after using the control.
However, in multi thread apartment, I just need to call CoInitializeEx ONCE in thread A. thread B need NOT to call CoInitializeEx.
2. May I know what is mean by "marshall interfaces" ?
Thanks
|
|
|
|
|
Yes something like that, but in single threaded apartment model other threads have to call CoInitialize before using the control, not after.
In multi threaded apartment although it's not necessary for each thread to call CoInitialize, it's recommended to make that call, to avoid problems, like access violations.
If you access a COM interface from another apartment you'll get an exception, so when you are using single threaded apaprment model you have to marshall interfaces between threads. You do that by calling CoMarshalInterThreadInterfaceInStream() from the thread in which you called first CoInitialize(), and pass the IStream interface you get to the other thread, from which you want to access the object. In that thread call CoGetInterfaceAndReleaseStream() passing the IStream as argument and you'll get the interface.
The easiest way is to marshall the IDispatch interface, because after that you can call directly any methods you want.
|
|
|
|
|
marshall interfaces seems not easy
i think i will go directly for multithread apartment to avoid using marshall interfaces. since providing a synchronized protection on my activex control object much easier.
thanks for help. this solve my doubt.
|
|
|
|
|
How to create a Excel file in Visual C/C++
Pls Help me
thanx in advance
KK
|
|
|
|
|
Hi,
show to http://www.codeproject.com/cpp/miniexcel.asp.
It may help you
Best regards
|
|
|
|
|
Check out MSDN article Q178749.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
How to change font of tooltip of Toolbar in MDI App developped with VC++6 and MFC ?
Any suggestion/solution?
Ana
|
|
|
|
|
I suppose you could subclass the tooltip and change the font or create your own tooltip class window and do whatever you like.
|
|
|
|
|
dear all,
pls mail me with the origin of visual studio, perticularly about VC++.
the help files are some what complex and hard for me to easily understand so pls send me some sites which explains about the general use of visual studio.
what r the vs tools and its use?
thk u for the trouble.
best regards
Ajo T.
|
|
|
|
|
Use MSDN help on Visual C/C++. It was very useful and easy to understand
by
KK
|
|
|
|
|
i understand that MSDN is help full but is there any other sites which give me details
|
|
|
|
|
Hi
Other useful sites are www.programmersheaven.com and www.codeguru.com
you can also download samples from above site
With Regards
KK
|
|
|
|
|
Will this[^] help you......?
|
|
|
|
|
Your question is way too broad to be answered in just a sentence or two (e.g., there are whole books devoted to the subject). What exactly are you wanting to know?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
How to change font of menu/submenu in MDI App developped with VC++6 and MFC ?
Any suggestion/solution?
Ana
|
|
|
|
|
I think you have to make the menu owner-drawn. There's an example i MSDN titled "Setting Fonts for Menu-Item Text Strings", it's in te Platform SDK docs.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I want to handle WM_PAINT in my class which is derived from CStatic, but the control can't received msgs like WM_MOUSEMOVE, the parent received it. How can I let the control handle WM_MOUSEMOVE?
Thanks.
|
|
|
|
|
The control needs SS_NOTIFY,
so go to properties by right clicking the control and check the "Notify" checkbox within the "Styles" tab
SkyWalker
-- modified at 2:25 Thursday 22nd September, 2005
|
|
|
|
|
That solves something I have been thinking about recently, thank you
It pays to browse the message boards.
The tigress is here
|
|
|
|
|
i want to access the message queue of windowsSystem.
All the Events (like MouseEvents, keyboardEvents) will first enters in to the windowsSystem message queue and then operating system extract the messages and sends them into corresponding windows messageQueues...
I need to access the WindowsSystem message queue using MFC Application...
is there any functions to accesss message queue of windowsSytem.?
|
|
|
|
|
Look for articles on system wide message hooking, there is more than one at CP.
INTP
Every thing is relative...
|
|
|
|
|
Have you considered GetMessage() and/or PeekMessage() ?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I am creating a C++ programme which has a large use of Matlab functions that have been combined into a DLL. The C++ (Win Console) application calls the Matlab functions fine.
As the Matlab are very detailed (and written by colleague) once the DLL is entered, it uses 100% of the PC resources and does not return until processing is finished. Currently the Matlab DLL outputs text to the Console window as it progresses.
What I would like to do is to breakup the DLL call with calls back to C++ and replace the Matlab Console text outputs to be via a C++ DLL routine (which could be eventually turned into a Dialog Window) - the whole thing will still be compiled under C++.
I have had a go with the example:
http://www.codeproject.com/dll/beginnerdll.asp#xx846359xx[^]
And this is fine for creation of a DLL.
So I thought: how about use this DLL under the Matlab environment using the loadlibrary and calllib functions? It loads, but it cannot find the function SayHello. (which IS in the DLL)
I am hoping that any Matlab command lines I use to load and execute DLL functions in a specific DLL, will be able to be compiled and operate the same when itself is in a DLL.
My Matlab command lines are:
- loadlibrary('MyLib.dll', 'cMyClass.h')
this returns:
Warning: The data type 'error' used by function SayHello does not exist (x 3)
and
Warning: The function 'SayHello' was not found in the libary
- calllib('MyLib.dll')
This returns an empty array.
I think the warning messages when I load the library are due to the
CString definition (which I cannot seem to easily locate in a C++ h file)
1. Are there any good examples of Matlab calling a C-compiled DLL?
2. Is there a better way to reduce my 100% useage of resources which the Matlab code is running?
Any pointers will be greatly appreciated....
ntrprs
|
|
|
|
|
i am writing a code to send a packet of data in the form of structures over the comm port to hyper terminal. The code while compiling does not give any errors but at the hyper terminal i receive all junk values.
pls help me to work this out.
here is the code that i wrote
//____________________________________________________-
// to write from one port & to read on the other port using hyper terminal
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "windows.h"
#include "dos.h"
#include "time.h"
#include "string.h"
#include "process.h"
#include "iostream.h"
struct human
{
char Name[4] ;
char grp[5] ;
int Age ;
};
char *port="COM2";
HANDLE hCom;
DCB dcb;
COMMTIMEOUTS comTimeout;
unsigned long n;
char ch;
int open_com(char * com);
void writecom(human *);
//----------------------------------------------------------------------------
void main()
{ human me = {"ajo","good",21};
human *s = &me;
open_com(port);
while(1)
{ writecom(&me);
ch = getch();
}
}
//----------------------------------------------------------------------------
int open_com(char * com){
hCom = CreateFile(com, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hCom == INVALID_HANDLE_VALUE)
{
printf("Open COM port failed!!!\n");
exit(0);
}
GetCommState(hCom, &dcb);
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState(hCom, &dcb);
comTimeout.ReadIntervalTimeout = 300;
comTimeout.ReadTotalTimeoutMultiplier=300;
comTimeout.ReadTotalTimeoutConstant=300;
comTimeout.WriteTotalTimeoutMultiplier = 3;
comTimeout.WriteTotalTimeoutConstant = 2;
SetCommTimeouts(hCom, &comTimeout);
return 1;
}
//----------------------------------------------------------------------------
void writecom(human *s) {
WriteFile(hCom,s,sizeof(*s),&n,NULL);
}
|
|
|
|