|
I'm just starting with COM and DCOM
I want to develop a program with two parts 1° A controller, 2° a GUI.
The GUI sends commands to the controller and displays info from the controller.
Several persons will use several copys of the same program.
Sometimes maybe I will need access to the controller of another user, running in a remote machine.
I want to have remote access to the controller, I was thinking about to communicate the GUI with the controller using DCOM.
The keypoint is: I dont want two programs "GUI client" and "Controller server", I want the GUI and the controller running on the same program, with the GUI able to switch to a remote controller.
I was trying a very "easy" example:
A MFC Dialog base GUI with two buttons A and B, and a text box.
The GUI tells the controller which button was pressed.
The GUI asks the controller what to display in the text box (what button)
I've got confused with DCOM, I could't write this program.
All the examples I found in the net use two different programs for the server and the client.
Could anyone help me with the general design/structure ?
Could I find a similar example somewhere ?
Is better use CORBA for this approache ?
Thanks a lot
|
|
|
|
|
u mean like the Microsoft Terminal server and Clients like architecture..????????
Renjith-CPian.
|
|
|
|
|
Yes but not so complex, I don't want multiple-sessions control, central server and so on...
Just your GUI able to switch to another running program to have a look what is going on there.
To start with an easy example I would like to:
1° Create a MFC Dialog based project -> OK
2° Add some buttons and text-dialogs -> OK
3° Create a new class called CController -> OK
4° Add ATL/COM support (new ATL object) -> OK
5° Use the COM object between the Dialog and the controller -> FAIL !!!
GUI <---> DCOM <---> CONTROLLER
I am not sure what declarations a need, how to connect the dialog with the interface...
I saw in "Add->new ATL object" there is an object called "dialog", maybe this is the way.
Thanks for reading !
|
|
|
|
|
do you want the Dialog Support for your ATL COM?
WUSIWUG
|
|
|
|
|
please provide the link of different comprehancive examples of com and com+
and a little help how to run it?
r00d0034@yahoo.com
|
|
|
|
|
Get some books to read first, then write some simple code
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Buy "Inside COM"(MSPRESS) by Dale rodgerson,
Then you've got pretty good samples on the MSDEV CD,
And I swallow a small raisin.
|
|
|
|
|
So you want to write a fugue,
You've got an urge to write a fugue,
You've got a nerve to write a fugue,
So go ahead and write a fugue
Glenn Gould
Go ahead! Read some books first. You must read something
Vagif Abilov
MCP (Visual C++)
Oslo, Norway
If you're in a war, instead of throwing a hand grenade at the enemy, throw one of those small pumpkins. Maybe it'll make everyone think how stupid war is, and while they are thinking, you can throw a real grenade at them.
Jack Handey, Deep Thoughts
|
|
|
|
|
Hi.
I want to display thumbnails of images. I tried using the "Imaging for Windows" ActiveX control imgthumb.ocx (Kodak image thumbnail) that comes along with Windows2000. I use VC++6.0.
I want to dynamically create the thumbnails. I am unable to figure out which functions to call.
Here is my code snippet.
It does not show any error, but nothing is displayed.
Can you point out what is wrong?
m_thumb = new CImgThumbnail;
BOOL res = m_thumb->Create("Thumbnail", WS_CHILD | WS_VISIBLE | WS_BORDER,
CRect(100, 100, 170, 170), this, 1341);
m_thumb->SetThumbWidth(50);
m_thumb->SetThumbHeight(50);
m_thumb->SetImage("c:\\flowers.jpg");
m_thumb->SetEnabled(true);
m_thumb->SetThumbCaption("seen???");
m_thumb->SetThumbBackColor(0);
m_thumb->SetThumbCaptionColor(100);
VARIANT image, page;
BSTR bst;
CString str="c:\\database_n\\flowers\\21099_wallpaper110.jpg";
bst = (unsigned short *)str.GetAt(0);
image.vt = VT_BSTR;
image.bstrVal = bst;
page.vt = VT_I2;
page.iVal = 1;
m_thumb->UISetThumbSize(image, page);
VARIANT thumbno, options;
thumbno.vt = VT_I4;
thumbno.lVal = 1;
options.vt = VT_I2;
options.iVal = 0;
CString str1 = m_thumb->GetImage();
m_thumb->DisplayThumbs(thumbno, options);
//m_thumb->Refresh();
However, the thumbnail is displayed when I put the control in a dialog box (using the editor), and set its properties.
Where am I going wrong in the dynamic creation process?
Hope somebody can throw some light.
Thanks.
Logic is a systematic method of coming to the wrong conclusion with
confidence.
|
|
|
|
|
Instead of posting the same question over and over again, why don't you try to come up with a simple well formulated question,
I happen to remember that your real issue was about using this control within a view. This has nothing to do with the question you ask, or is it me ?
And I swallow a small raisin.
|
|
|
|
|
I had posted the same question in 2 forums, (VC++ and COM), at the same time, expecting to get an answer from at least one of them.
Now, is there a way to remove or flag off a thread once answered?
Logic is a systematic method of coming to the wrong conclusion with
confidence.
|
|
|
|
|
Try to throw an exception in the TranslateAccelerator function.
Once, I did it in the ShowContextMenu function and IE shows the default menu.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
I resolved this issue, finally, and figured I'd post the solution for those of you that want an answer to this question as well.
The TranslateAccelerator() method in the IDocHostUIHandler interface is extended and key events are handled based on a flag passed from the container object (in this case, a window). I originally tried to pass the accelerator KB message to the parent window by using SendMessage() but that only caught the first key of the key stroke (i.e. an ALT-F would only catch the ALT key ).
Instead, I ended-up using a PostMessage call, which is able to properly handle the dispatched accelerator message.
Here's a code snippet for ya:
<br />
if ( m_vbEnableAllAccels == VARIANT_FALSE ) { <br />
HWND hWndParent = ::GetAncestor( lpMsg->hwnd, GA_ROOT );<br />
ATLASSERT( hWndParent );<br />
PostMessage( hWndParent, lpMsg->message, lpMsg->wParam, lpMsg->lParam );<br />
}<br />
else if (m_vbEnableAllAccels == VARIANT_TRUE<br />
|| (GetKeyState(VK_CONTROL) >= 0<br />
&& GetKeyState(VK_SHIFT) >= 0 && GetKeyState(VK_MENU) >= 0))<br />
{ ...<br />
D.
|
|
|
|
|
Hello,
why i can't make any changes to a ByRef passed Com MEthod Variable ?
The variable ha s the same value before and after the Com Method invokation.
Any Ideas ?
|
|
|
|
|
The behaviour is clear once we look at the IDL file
HRESULT Run(
[in] BSTR ProcedureName,
[in] SAFEARRAY(VARIANT)* Parameters,
[out, retval] VARIANT* pvarResult);
Which means your parameters are passed by value [in] and not by reference [in,out].
VOTD: 27 "Religion that God our Father accepts as pure and faultless is this:
to look after orphans and widows in their distress and to keep oneself from being polluted by the world." - Jam 1:27 (NIV)
|
|
|
|
|
Hello,
means retval that the scripting host knows, that he can change the variable ?
I've made ...[out] long* _value);
In VBScript i use ... CLng(_variantvar) to make the conversions.
Can i use only Variant Vars in the COM Interface ?
|
|
|
|
|
Well '[out,retval]' is used only for return value. '[in]' says that whatever you passed to your script function, you can't change it inside of your script since data are passed by value. Think of it as a C++ function:
int Sum(int num1, int num2) { return num1+ num2; }
changes to num1 and num2 affect local value only and 'return' is like a constant. I hope it is clearer now.
VOTD: 27 "Religion that God our Father accepts as pure and faultless is this:
to look after orphans and widows in their distress and to keep oneself from being polluted by the world." - Jam 1:27 (NIV)
|
|
|
|
|
Hello,
thanks, now it works !
BUT, is there no posibility to make this without to use a return variable ?
My VB Programms and C++ Clients are all working perfectly with a ByRef Call.
Must i really change all clients to use the RetVal, only because i want to use COM-Scripting with VBScript ?
In VBScript i can made ByRef Callings without problems.
Like :
Sub DoSubroutine( )
Dim x
x = 10
msgbox x
CallAnotherSub x
msgbox x
End Sub
Sub CallAnotherSub(ByRef var1)
var1 = var1^2
End Sub
|
|
|
|
|
Well VB and VBScript are different. VB supports a whole lot more data types than VBScript.
VOTD: 15 "The eyes of the Lord are on the righteous and his ears are attentive to their cry;
16 the face of the Lord is against those who do evil, to cut off the memory of them from the earth. " - Psalm 34:15-16 (1 Peter 3:11-12) (NIV)
|
|
|
|
|
Hello Ernest,
i ve noticed, that the article "Adding VBScript and JScript support in ..."
is yours. That had inspired me to make my COM-Servers available to scripting.
Now i've made my COM INterfaces scriptable und the next Problem occurs.
I need the Event's from my COM Objects in the VBScript. I have made it with
" Set msport = WScript.CreateObject("MSCOMSRV.Port","msport_") ". This is OK, if i runs it from the shell with WSH. In your Applikation i get the error
" Object needed WScript ". In which enviroment are the Scripts running (in your Application) ?.
My thought was to make the custom-Scripts like Plug-Ins in my C++ Main Applikation.
Koep ( author of the anonymous messages in the thread, but i ve forgot my password and the remind me action failed )
|
|
|
|
|
"WScript" is a different 'HOST' engine than the ActiveX version. I am still planning to write an article about it (give me 1-2 week). You can create COM object from your script and catch the event. In VBScript, create your activex (COM object) by calling
Set MsCOMSVR = CreateObject("MSCOMSRV.Port") MsCOMSVR_OnEvent is the name of the event function. MsCOMSVR must be global in VBScript, if you declare it inside of a 'Sub' it will be destroyed when the 'Sub' terminates.
VOTD: 15 "The eyes of the Lord are on the righteous and his ears are attentive to their cry;
16 the face of the Lord is against those who do evil, to cut off the memory of them from the earth. " - Psalm 34:15-16 (1 Peter 3:11-12) (NIV)
|
|
|
|
|
Are u sure ?
I think, and my tests confirm this, that u can't use events in normal VBScript. When i use "Set msport = WScript.CreateObject("MSCOMSRV.Port","msport_")" then it's possible. Because the WSH can do event action. The "wscript.sleep 10000" is also important for the event listening stuff. How would u do this without the WScript object ? The WScript can't used from the msscript.ocx . So i have no idea to make event-scripting available from C++ Code, because i don't want to create 10th or 100th of individual WScript processes.
Marco
|
|
|
|
|
Yep! it is possible, hopefully I will submit a new article this coming weekend that
demonstrate just that. Watch for it Saturday or Sunday!
ÿVOTD: 8 "Love never fails. But where there are prophecies, they will cease;
where there are tongues, they will be stilled; where there is knowledge, it will pass away." - 1 Cor 13:8 (NIV)
|
|
|
|
|
I just re-read your comment correctly and you are right about it. MSscript.ocx does not allow you to handle script event from your script but funnyly you can add/connect object with it.
ÿVOTD: 8 "Love never fails. But where there are prophecies, they will cease;
where there are tongues, they will be stilled; where there is knowledge, it will pass away." - 1 Cor 13:8 (NIV)
|
|
|
|
|
My program is a client (c++) that link to an activex dll created in VB.
I use this function :
hresult = m_connection->LoadData(OLESTR("01"),OLESTR("B20"), 0,0,&ResulVar,OLESTR("thisMachine"),ADO_ODBC , &m_E );
Hresult tells me everything worked fine but ResulVar return empty.
ResulVar is a VARIANT.
m_E is an object that receive error from the server. It tells me that :
ActiveX component can't create object.(usualy, it's when dll are not registred)
With an other program in vb I tested the same function an it worked perfectly, so I know my dll are registered.
If it can provide me with the error message from m_E, Why the VARIANT doesn't receive the data?
Does anyone have a clue?
Thanks
|
|
|
|