|
Kannan Kalyanaraman wrote:
Is it possible to call them using GetProcAddress..
No.
is it necessary that inorder to call a fn inside a dll it must be exported.
No, it can be a virtual member function of a class that resides in the DLL. Bot for ordinary functions you must export the symbol.
|
|
|
|
|
|
Hi everyone this is my first post so be gentle;)
How do you best share data between threads? For instance if you have two arrays and the main plus another thread has to have access to them what is then the best way to create the thread? As a worker or UI thread and what about parameters and so on? Of course one could do it with global vars but I dont like globals an I will do anything to avoid them
Any suggestions?
Tnx in advance
/Frank
|
|
|
|
|
You can give an pointer to the arrays, so the others thread can access the data. Dont ferget syncronization with Critical Section. A good idea is to work with Events.
Or you can send Messages between the threads.
|
|
|
|
|
If three threads [your primary thread + the two worker threads] are accessing the same array, then you'll be better off implementing some kind of data synchronization methods. Perhaps crictical sections would suite you well in this case. As for passing the data across threads, threads are usually passed an LPVOID parameter. You can pass a pointer to a struct that wraps all your shared arays. And this pointer can be passed to all your worker threads. But as I already said, you have to implement synchronization mechanisms else your data will get corrupted quite easily. And it won't be easy to debug as well.
Regards
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Tnx for the quick responce both of ya!
Got it then there is just one more qeustion
So I have to use a worker thread! Because of the LPVOID param right? Can you tell me why it not possible to do that in a UI thread...why is there no LPVOID param i the UI thread? (it dont make no sence to me)
Am I missing something here...
|
|
|
|
|
Got it
Just read something from Alexpro's post
Tnx again everyone
Regards
Frank
|
|
|
|
|
Read this article about worker threads and how you should pass data among them.
Best regards,
Alexandru Savescu
|
|
|
|
|
Hi everone,
I was just wondering on how to do this, assume you have a string like this:
string String1 = "MR AND MRS DAVID MACDONALD";
How would you sort this so that it will look like this:
"AND DAVID MACDONALD MR MRS"
Any Idea? please feel free to share it
Thanks/Regards
Sidney
|
|
|
|
|
I'd break up the string, and pass the words into a map as I go, then walk the map ( which is a sorted container ).
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
How about adding them to a vector, and then sorting the vector?
I would be interedted to see which was quicker. I suppose with the map, the sorting would be quicker, as you sort as you add to it, but walking a map is slower then walking a vector. hmmm
I love the STL.
|
|
|
|
|
If all strings are added at once and then sorted, it will probably be faster to uses a vector and sort it at the end.
On the other hand, if you want to add strings afterward a map would be faster since you won't start the sort again for each added items.
In pratice, in most situation a map (or multi-map if duplicate are allowed) would work fine and be easier to code...
Philippe Mori
|
|
|
|
|
Let All the Windows' Title Set by My Presetting String when they Created.
In simple words, I want to make all windows display the same title.
Who can do it?
|
|
|
|
|
Easy. All Windows on the system ? There is a function to enumerate all Windows, I forget the name. Do that, and call SetWindowText on them all in your callback function.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Does that only give you actual windows, or will it provide the HWND derived controls too?
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
From memory it return windows that cannot be seen as well, so some check like ::IsWindowVisible is necessary, but it does not list child controls.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
But By this method ,I have to set a Timer to check whether a new window is created and set its title.
I want to change the title when the windows is created.
|
|
|
|
|
Then I guess you need some sort of system wide hook.
With newbies, the thing is often that they ask HOW do do things, but the people who read the questions wonder WHY. What sort of user hostile UI disaster are you scheming here ?
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Are all of these windows that you want to change yours?
Basically, call SetWindowText for each window that you want to set the title of.
If you do not have a handle to each and every window then you can start with the main window in your program and call GetWindow to navigate through the chain of windows.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
yes, but how can I know when a window is created and I could set the title at once, or I set a Timer ??
|
|
|
|
|
I am curious as to what you intend to do with such a program. Is it part of an annoyance utilities package?
Just kidding pal
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Nish - Native CPian wrote:
Is it part of an annoyance utilities package
LOL. I think we've just found the next killer app
Michael
Errata 1: p. 154, section 'Defusing'. For 'red wire' read 'blue wire'.
|
|
|
|
|
I have a tab control on that i had placed a list controls .
If i select some item in the list control & move some other window over that then close that window.Now my list control will disapper.If i won't select anything in the list control,then it works fine.
Any idea?
Neha
|
|
|
|
|
How can a move this part of the complex.cpp into the header file:
double A,B,C,D;
char letter;
cout << "s Sum\nd Differnce\np Product\nq Quotient" << endl;
cout << "The operation is ";
cin >> letter;
cout << "A is ";
cin >> A;
cout << "B is ";
cin >> B;
cout << "C is ";
cin >> C;
cout << "D is ";
cin >> D;
//complex.cpp
// Complex
#include <iostream.h>
#include "complex.h"
main()
{
double A,B,C,D;
char letter;
cout << "s Sum\nd Differnce\np Product\nq Quotient" << endl;
cout << "The operation is ";
cin >> letter;
cout << "A is ";
cin >> A;
cout << "B is ";
cin >> B;
cout << "C is ";
cin >> C;
cout << "D is ";
cin >> D;
complex com1(A,B);
complex com2(C,D);
switch(letter)
{
case 's':
(com1+com2).print();
break;
case 'd':
(com1-com2).print();
break;
case 'p':
(com1*com2).print();
break;
case 'q':
(com1/com2).print();
break;
}
return 0;
}
// Header File
#ifndef _complex_h
#define _complex_h
class complex
{
public:
complex();
complex(double,double);
complex operator + (complex);
complex operator - (complex);
complex operator * (complex);
complex operator / (complex);
void print();
private:
double r, i;
};
complex::complex()
{
r=0;
i=0;
}
complex::complex(double a, double b)
{
r=a;
i=b;
}
complex complex::operator+(complex value)
{
double a,b,c,d,x,y;
a=r;
b=i;
c=value.r;
d=value.i;
x=a+c;
y=b+d;
complex answer(x,y);
return answer;
}
complex complex::operator-(complex value)
{
double a,b,c,d,x,y;
a=r;
b=i;
c=value.r;
d=value.i;
x=a-c;
y=b-d;
complex answer(x,y);
return answer;
}
complex complex::operator*(complex value)
{
double a,b,c,d,x,y;
a=r;
b=i;
c=value.r;
d=value.i;
x=a*c-b*d;
y=a*d+b*c;
complex answer(x,y);
return answer;
}
complex complex::operator/(complex value)
{
double a,b,c,d,x,y;
a=r;
b=i;
c=value.r;
d=value.i;
x=((a*c)+(b*d))/((c*c)+(d*d));
y=((b*d)-(a*d))/((c*c)+(d*d));
complex answer(x,y);
return answer;
}
void complex::print()
{
cout << r;
if (i>=0)
cout << "+";
cout << i << "i" << endl;
}
#endif
|
|
|
|
|