|
Presuming you're using Visual C++...
You want to use __declspec(dllexport) to define functions that are exported from the DLL and are thus callable from any other program (including the camera program). The best way to use it is like this:
- Declare the DLL's exported functions in a header file (note - replace THIS_FILE_H with some text representing the headers actual filename - THIS_FILE_H represents 'ThisFile.h'):
#ifndef __THIS_FILE_H__
#define __THIS_FILE_H__
#ifndef PLUGIN_API
#define PLUGIN_API __declspec(dllimport)
#endif
PLUGIN_API int DoSomething(int aParameter);
#endif // __THIS_FILE_H__
- Add a .cpp file to the plugin DLL project which defines the functions (
DoSomething in this case) you've exported. You need the following two lines in that file, BEFORE you define any of the functions (note: replace 'ThisFile.h' with whatever you called the header file in the previous step):
#define PLUGIN_API __declspec(dllexport)
#include "ThisFile.h" - In the camera program,
#include the header in the .cpp file where you want to call the plugin's functions. You also need to link the plugin's export library (a .lib file) to the camera program.
This page[^] has several useful links.
|
|
|
|
|
Hello Stuart,
I posted a reply about half an hour ago and it has not shown up on the forum. So I am experimenting to see if I used the wrong procedure to reply.
Tom Hubin
thubin@earthlink.net
|
|
|
|
|
Hello Stuart,
Well, I guess my first reply to you is lost in cyberspace. I'll try again.
BTW, I am using c++ in Visual Studio 2003.
The procedure that you suggest makes sense to me. I also used some of the keywords to find help topics. These also agreed. However, as you well know, the devil is in the details.
I am getting two warnings and cannot figure out why. Below are my brief header and cpp files and the warnings. What am I missing? Ignore the third warning.
I would not normally worry about a couple of warnings but I am also having errors compiling the calling program. So I am wondering what I need to specify to create the library here and how to import it at the calling end.
Tom Hubin
thubin@earthlink.net
**************************************************
// public.h
#ifndef __PUBLIC_H__
#define __PUBLIC_H__
//#pragma once
#ifndef PLUGIN_API
#define PLUGIN_API __declspec(dllimport)
#endif
PLUGIN_API int DoubleIt(int aaa);
#endif // __PUBLIC_H__
**************************************************
// public.cpp
#include "stdafx.h"
#include "dbg.h"
#define PLUGIN_API __declspec(dllexport);
#include "public.h"
PLUGIN_API int DoubleIt (int aaa)
{
int bbb ;
bbb = 2*aaa ;
return(bbb);
}
**************************************************
Output Window Compiling...
stdafx.cpp
Compiling...
XMLProfile.cpp
Utility.cpp
public.cpp
c:\CNC\Mach3Development\SDK2.62.00\th3dVid\public.h(12) : warning C4091: '__declspec(dllexport ) ' : ignored on left of 'int' when no variable is declared
c:\CNC\Mach3Development\SDK2.62.00\th3dVid\public.cpp(14) : warning C4091: '__declspec(dllexport ) ' : ignored on left of 'int' when no variable is declared
PluginTestDlg.cpp
dbg.cpp
CustomPluginImpl.cpp
c:\CNC\Mach3Development\SDK2.62.00\MachIncludes\Mach4View.h(18) : warning C4192: automatically excluding 'IServiceProvider' while importing type library 'ShockwaveFlash.ShockwaveFlash'
CustomPlugin.cpp
Generating Code...
Compiling resources...
Linking...
Creating library Debug/CustomPlugin.lib and object Debug/CustomPlugin.exp
Performing Post-Build Event...
1 file(s) copied.
Results Build log was saved at "file://c:\Cnc\Mach3Development\Sdk2.62.00\th3dVid\Debug\BuildLog.htm"
CustomPlugin - 0 error(s), 3 warning(s)
**************************************************
|
|
|
|
|
You've got a semi-colon at the end of #define PLUGIN_API __declspec(dllexport)<span style="font-weight: bold;">;</span> - you don't want that.
Also - you don't need to use PLUGIN_API in the cpp file - doesn't hurt, but it's not required.
|
|
|
|
|
Hello Stuart,
Thanx for catching that semicolon.
All compile and run ok.
In DoubleIt() I have added a call to the motion control EXE program for which the plugin is written and by which the plugin has been loaded. This new DoubleIt() works ok when called from elsewhere within the plugin but not when it is called from the vision control EXE program.
When the plugin function is called from the vision control EXE I get the message "The instruction at "0x0000000" referenced memory at "0x00000000". The memory could not be read."
This only occurs if the called plugin function is trying to call a function in its parent EXE. BTW, I get that same error message if the DLL is not loaded at all.
I think that the called plugin function is not exactly the same as the one that is loaded with the DLL. I am guessing that all the pointers must be found in memory as needed.
How do I setup the compiler options so that the vision control EXE program can call the motion control EXE program via the motion control's DLL plugin. Or perhaps directly from the vision control EXE to the motion control EXE since the motion control EXE program must have used dllexport so that the plugin can call motion control functions.
Tom Hubin
thubin@earthlink.net
|
|
|
|
|
Tom Hubin wrote: How do I setup the compiler options so that the vision control EXE program can call the motion control EXE program via the motion control's DLL plugin
Nothing to do with compiler options, I suspect. I guess the plugin is expecting the executable that loads it to provide certain capabilities - there must be some defined mechanism by which it knows the addresses of the functions in the EXE.
Tom Hubin wrote: motion control EXE program must have used dllexport so that the plugin can call motion control functions
Not necessarily - there might be some other mechanism by which the plugin can get function addresses.
I feel you're on your own, I'm afraid - if there's a specification for the plugin interface, that might define how you get the exe function addresses?
|
|
|
|
|
Create a named event in the plugin and wait on that event to become set.
When the event becomes set, call the required function.
From the camera program set the event when needed.
You may want to look at CreateEvent and SetEvent .
«_Superman_»
|
|
|
|
|
Hi all,
i have an CListCtrl, i m sort it according to diffrent columns in acsending or decsending order.
i want to set up and down arrow on list header according to sorting.
please explain me with example.
how can i do this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
modified on Thursday, January 29, 2009 1:55 AM
|
|
|
|
|
You can modify the header text .. Does it make sense??
Regards,
Sandip.
|
|
|
|
|
The way it's done in the sorted list view control in the WTL library[^] is to use the hbm member of the HDITEM [^] attribute of the header of the sorted column to set an up arrow or down arrow bitmap for the header. If you tell the bitmap to be to the right of the header's text, you'll get the effect you're wanting.
The bitmaps are available in shell32.dll as image resources 133 and 134.
You can learn a lot about this by looking at the implementation of CSortListViewImpl in the file atlctrlx.h in WTL...
The SetSortColumn method of this class shows how to set the bitmaps correctly, while the CreateSortBitmaps method shows how to create the bitmaps.
|
|
|
|
|
Invalidate does not work for me. Any other way?
|
|
|
|
|
ThisIsMeRon wrote: Invalidate does not work for me.
Reason??
Regards,
Sandip.
|
|
|
|
|
ThisIsMeRon wrote: Invalidate does not work for me.
You should ask Microsoft for a custom Invalidate, working for you.
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]
|
|
|
|
|
ThisIsMeRon wrote: Invalidate does not work for me.
i dont know what his problem is, but i have similar issue with InvalidateRect when when i was creating a control in win32, i tried RedrawWindow also but not worked. I solved issue by using the following code.
HWND hParent = GetParent( hChildControl ) ;
InvalidateRect( hParent , &rChildRect , TRUE ) ;
|
|
|
|
|
What kind of child was that? I mean was it a static control? What was its class styles?
- ns ami -
|
|
|
|
|
Your site is better I think it has a function Invalidatemyrequest(very urgent);
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
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]
|
|
|
|
|
ThisIsMeRon wrote: Invalidate does not work for me.
You must be using this API on wrong object. There is no way Microsoft has put some switch condition, not to work on your machine.
|
|
|
|
|
Did you use like this?
Invalidate();
UpdateWindow();
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hello all,
I created a window. Over that window i created some controls of the class CButton, CEdit,CStatic, CComboBox.
My problem is that, i have to assign the tab order for this controls. I set the WS_TABSTOP property while creating this controls. But tab order is not set for this controls. How can i set tab order for this controls.
********************
CEdit* pedtName = new CEdit();
pedtName->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP,CRect(160,140,300,170) ,this,EDITNAME);
|
|
|
|
|
use
pedtName->SetWindowPos(...)
see the first parameter of SetWindowsPos
|
|
|
|
|
Sorry sir, it doesn't work.
I created two edit control as follows on the OnCreate() method of the application.
**************
CEdit* pedtName = new CEdit();
pedtName->Create(ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,CRect(160,100,300,130) ,this,EDITNAME);
pedtName->SetFont(pFont,TRUE);
CEdit* pedtSurName = new CEdit();
pedtSurName->Create(ES_AUTOVSCROLL | ES_AUTOHSCROLL |ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,CRect(160,140,300,170) ,this,EDITSURNAME);
*****************
When i run the application, focus will automatically set to pedtName control. When i press tab key, tab focus will set on pedtSurName.
But now it doesn't work. How to do this?
|
|
|
|
|
As other reply says you can use SetWindowPos for altering tab order.
You can also check here[^]..
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
Why don't you simply create the controls in the order that you want.
«_Superman_»
|
|
|
|
|
If you want to set Tab Order on the dialog forum you must be press Ctrl+D or runtime liek this:
CWnd *m_pWnd1 = GetDlgItem (IDC_BUTTON1);
CWnd *m_pWnd2 = GetDlgItem (IDC_EDIT2);
m_pWnd1->SetWindowPos (m_pWnd2, 0,0,0,0, SWP_NOMOVE | SWPNOSIZE);
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|