|
vasanth1004 wrote: The reason I need to do this, is because my dll needs to support an arbitrary callback function.
Clearly, this is something that I don't understand. Why do you want to do such a thing ? The purpose of the callback is to notify the 'registered' that something happened and in every case, the prototype of your function is the same.
vasanth1004 wrote: I was thinking I could make the user pass in the parameters, and number of parameters when the function is registered, then I could push it on the stack with inline assembly before I call the function.
However, this is a little bit tardy way of doing it.
Yes, this is quite tricky and not elegant at all
vasanth1004 wrote: Any better suggestions?
Yes, change your design so you don't have to use different prototypes .
Maybe, if you describe the situation why you need to have an arbitrary function, I can help you to find a better solution. But please, you have to describe the situation so that I can fully understand the problem (and maybe some RELEVANT code snippet can help, altough it's not necessary).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Basically, I am writing an openGL library to render a scene multiple times from different viewpoints.
So, the way my design works is I have the user pass in a pointer to their "Draw()" function (callback method), and my dll can call the Draw function multiple times, with different configurations each time. This is done so that the user doesn't have to explicitly call the Draw function multiple times.
My DLL code can work fine if there were no arguments, or I knew the arguments.
eg: typedef void (__stdcall *Draw)(void);
But what if the user's Draw method had many arguments? How would I change the prototype in the dll to reflect this?
This is my problem.
Thanks for your help.
|
|
|
|
|
Ok I see. But basically, I think there is a design problem there. Ok, let's suppose you have several Draw functions with each a different parameter list. How, in your dll, will you know what parameters you will need to pass ? There is a big problem there. You simply cannot call a function without knowing what you will pass to it, this makes non-sense.
I think you need probably to rethink a little bit the design. As I see, it is the users that will use your dll (so you don't have control over this 'code'). Why not simply have a standard callback function ? It work always like that: you have a specific function prototype that can be used as a callback and it's up to the user to follow this prototype (that seems logical).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Is there an API or a way to retrieve or Calculate %CPU Usage and Thread Count of a specified process? I am using 2000/XP.
Thanks.
|
|
|
|
|
|
|
Hi friends
If i want to code a big project in C++ in VS2005 which road must i follow?What do you advice me?
Especially i want to design it with plugin support.I write it skeleton, then other parts will be plugin or it can be developed by other coders.I want to learn what must i prepare before start coding.How must projects settings be for plugin support or for a such a big project.(For great extensibility)
I am looking for your answers.Any links , articles, advices will be very useful for me.
Thanks..
|
|
|
|
|
the easiest way to do a plugin system is with plain-old stdcall/cdecl DLLs. just define an interface (a set of required functions) and document how a plugin should behave within your system. then you just drop the DLLs into a specific folder and your app can do LoadLibrary/GetProcAddr on each *.DLL it finds in that folder.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thanks chris.
Do you know there are any sample applications about that.
Also are there also some information or settings that i must know before start coding?I asked this because i don't want to make mistake and turn back.
Thanks again...
|
|
|
|
|
hi
i can't think of any samples specifically related to "DLL as plugins", but i think just a simple introduction to DLLs using LodLibrary/GetProcAddr would do it. i'm sure there must be a bunch of those around.
i can't think of any special settings, really. just create your DLLs with C interfaces (not "MFC Extention" or COM or .Net), make sure you export the functions with C interfaces (stdcall or cdecl) and make sure you make your function interfaces as flexible as possible, to allow for easy growth (you don't want to be changing the interfaces once people have started writing plugins!).
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Halllo
I know i'm not realy right here. But i don't know where else to go.
My little software is ready and now i prepare everything for the installer.
I went to another machine to see the dll's i need. So far so good. Now
my App needs MFC71.dll but just copying the dll won't work
The error message is the message title.
Does any one have any suggestions ??
THX
Timen
|
|
|
|
|
from MSDN...
"MFC71.dll does not need to be redistributed with MFC applications if you statically linked to the MFC DLL (that is, unless you specified Use MFC in a Static Library on the General tab in the Project Settings dialog box)."
|
|
|
|
|
I'll try to be brief here because I could go on and on:
We have an existing app which keeps track of employee in/out status. It uses UDP in a client/server architecture.
We are starting to use Remote Desktop and are having some problems with this app. Originally, we kept getting the error that basically said the listen port (on the client app) was already in use. I made the change to allow reuse and that error is now gone.
Now, it seems that the first client to get the notification from the server (in the OnRecieve() call) is the only one that gets data. I have a feeling the data is removed from the socket buffer and the other apps are probably getting a recv length of 0. They may not be getting a notification at all - I need to verify this.
To be a little more clear - we are testing with multiple people logged into the Terminal Server. At the most, only one client works properly at any time.
How can I handle this?
-- modified at 15:53 Wednesday 7th June, 2006
|
|
|
|
|
i found some MDI extension classes called MDI tabbed interface or MTI. By using these classes, we can create tab in the workspace (main frame window) to navigate all the child window in this workspace.
My question is if we also have some classes which can be used to create multiple workspaces at the same MDI application and there is also a tab to navigate the workspaces. And we also can load and store workspace layout file for each workspace seperatedly.
note1: "Workspace" is another name for main frame window in MDI application, there might be several child windows in each workspace.
note2: i know there is a stock trading software call TradeStation, which has already implement this feature in its system.
thanks for all the help.
Bing
|
|
|
|
|
OK, here is what I have done.
I am looking to use a timer to complete some refresh operations every 2 seconds. However, I cannot get my OnTimer()function to be called.
I set up a timer with the following line of code:
SetTimer(1, 2000, 0);
Then, I have the Ontimer function, which I created from ClassWizard as a message handler for WM_TIMER.
That is, I have ON_WM_TIMER declared in my message map.
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Here is my handler:
void CProbeTalkMenu::OnTimer(UINT nIDEvent)
{
m_szStatus += "*";
UpdateData();
CDialog::OnTimer(nIDEvent);
}
OnTimer() is never called. I am afraid that I am failing to do something grossly important. Can anyone explain what my problem might be?
Brett Feero
|
|
|
|
|
Never mind......
UpdateData(); =====> UpdateData(0);
|
|
|
|
|
( with MFC, VC6/VS.net 2003 )
I have 2 docking windows in my MDI application, docking window A can dock on either the left or right side, and docking window B can dock on the bottom.
now, I have something like : where the docking window B takes the whole width of the frame.
--------------------------------------------|
| | |
| Dock| |
| ing | |
| | |
| Wind| |
| ow | |
| | |
| A | |
|-------------------------------------------|
| |
| Docking Window B |
--------------------------------------------|
Is there a way to have the docking windows look like this instead ? :
--------------------------------------------|
| | |
| Dock| |
| ing | Main Window ( child wnd ) |
| Wind| |
| ow | |
| A | |
| | |
| | |
| |-------------------------------------|
| | |
| | Docking Window B |
--------------------------------------------|
Maximilien Lincourt
Your Head A Splode - Strong Bad
-- modified at 14:45 Wednesday 7th June, 2006
|
|
|
|
|
I like to write a program to read several arrays of function of time and then to display these arrays in multiple channels stacked up in a page.
Please help me to get some key code segments to start with.
Thanks
|
|
|
|
|
I have a dialog box with lots of edit controls and some
check boxes and a date time control. Is there an easy
way to know when one of the items has changed, so that
I can then do:
SetModifiedFlag(TRUE);
The only way I can think of right now is to EN_CHANGE
on each and every control and if something changes, then
do:
SetModifiedFlag(TRUE);
Im hoping there is an easier way to know when at least
one control has changed just alittle.
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Could you not derive a class from CEdit , and put the ON_CONTROL_REFLECT(EN_CHANGE, ...) code in it?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
It works but it doesnt work. The function:
ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
calls the OnChange function when an edit box is changed. However,
in this new class, CMyEdit, I cant call:
m_pDocument->SetModifiedFlag(TRUE);
or,
GetDocument().SetModifiedFlag();
Im stumped on calling SetModifiedFlag in the OnChange function.
Please, please, any response you can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
When the OnChange() method is called, set a static member variable to true . Add a static method to your CEdit-derived class, something like:
bool CMyEdit::HasChanged( void )
{
return m_bChanged;
} Then in your code that needs to know if any of the edit controls were changed, simply call CMyEdit::HasChanged() . Make sense?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
WEll for edit controls you can derive them from a common CMyEDit class
and add the following macro
ON_CONTROL_REFLECT(EN_CHANGE, OnChangeVal);
OnChangeVal :- this function will be called on the change of the edit controls
Check for reflect Messages in MSDN.
Regards,
FarPointer
Blog:http://farpointer.blogspot.com/
|
|
|
|
|
I use a slightly modified version of the method described here[^]. I re-calculate the checksum in an OnIdle handler so t is always checked without having to worry about it in any of my other code.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Hi,
I have a tree control with checkboxes (using the following tip http://www.pocketpcdn.com/articles/checktree.html)
Now I'd like to know how I can retrieve the boxes that have been checked. And if it is possible NOT to display the checkboxes corresponding to some items of the tree (I'd like checkboxes only for the leafs of the tree).
Thanks
|
|
|
|