|
You could use an ActiveX control to get the input and display the translated output. Using the ATL Appwizard is a good start. A composite control would probably be your best bet.
It would probably be better to build each seperate language as a COM server that could be called from your ActiveX control.
Michael
|
|
|
|
|
I need to create an ActiveX control that uses tree controls. I am very familiar with the CTreeCtrl MFC class and would prefer to use this in the control.
Ordinarily I would just add the controls I needed to a dialog resource and then use ClassWizard to add the revelant member variables and event handlers. I'm very new to ActiveX control creation and I don't seem to be able to find a way of doing what I want to.
Does anyone know how this can best be achieved?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek Lakin wrote:
need to create an ActiveX control that uses tree controls. I am very familiar with the CTreeCtrl MFC class and would prefer to use this in the control
In the last step of creating your project,choose in "create control based on" SysTreeView32 .
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I already thought of that but I actually need two tree controls inside my ActiveX control.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek Lakin wrote:
I actually need two tree controls inside my ActiveX control.
You mean you don't know how to create second one?
The same as when you create a control in windows appication.
Definr one ,then with Create(),SetWindowPos()
in OnCreate() and OnSize of
your ActiveX.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I've created an ActiveX control using the MFC ActiveX Control Wizard. As standard it inherits from COleControl.
I've added a handler for WM_CREATE which looks like this atm:
int CMyCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
DWORD dwStyle = WS_CHILD | WS_VISIBLE |
TVS_HASLINES | TVS_DISABLEDRAGDROP;
UINT nFlags = SWP_NOMOVE | SWP_NOSIZE;
BOOL bCreate = m_tree.Create(dwStyle, CRect(7, 7, 70, 75), this, IDC_TREE);
if(TRUE == bCreate)
{
m_tree.SetWindowPos(&wndTop, 0, 0, 0, 0, nFlags);
}
return 0;
}
I've also added a handler for WM_SIZE as follows (I'm not worried about sizing yet):
void CMyCtrl::OnSize(UINT nType, int cx, int cy)
{
COleControl::OnSize(nType, cx, cy);
m_tree.SetWindowPos(&wndTop, 7, 7, 70, 75, 0);
}
The only other I've done is to remove the two default lines in OnDraw that fill the background white and draw an ellipse.
At the moment it draws absolutely nothing. I've stepped through and the creat calls, etc. succeed but I don't get a tree control drawn
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I think it has two reason:
First:
if(TRUE == bCreate)
{
m_tree.SetWindowPos(&wndTop, 0, 0, 0, 0, nFlags);
}
For the forth and fifth element you have to set width and height,here set them to 0,so yout reww control does not have any height and width so you can't see it.
Second:
You didn't add any item to tree control.you won't see anything until you add items.
Hope that helps
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Lets say I have two objects in my system: Cars and Trucks. They have similar functions: Start, Stop, SetPassengerCount.
Now I want to build Generic pool class so that I can hold and manipulate objects of the above classes, one pool for each class. The pool operations will be the same no matter the “type” of the pool.
When I instantiate a pool I want to tell it what type of pool it should be (Car or Truck) but I have no idea how to do this.
I tried to use void pointers but I really want to be able to “use” the objects from within the pool class. That is to say I want to “Start” , “Stop” the object but obviously I cant do this with void pointers.
I’ve searched the Internet but nothing I found really helps. Can someone suggest a few things that I should be looking into to solve this problem. I’m lost. Help.
|
|
|
|
|
Use a C++ feature called template classes. Any C++ book worth the price of paper is printed on should explain the ideas behind the template concept.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
class Pool<t>
{
};
Pool<car> MyCars;
Pool<truck> MyTrucks;
Good Luck,
Bill
|
|
|
|
|
Sorry, I lost some formatting in that post...
class Pool<T>
{
void Maintain();
T.Start();
};
To use it:
Pool<Cars> MyCars;
Pool<Trucks> MyTrucks;
MyTrucks.Start();
MyTrucks.Maintain();
Good Luck
|
|
|
|
|
I don't know why the formatting doesn't show up. What I was trying to tell you is to create a Template class to wrap either Trucks or Cars. For some reason, I can't get the less than and greater than signs to show up.
Sorry
|
|
|
|
|
If you insist on answering to me (instead of original poster), at least include the 'template' keyword in your example.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sorry, I thought I was. My screen resolution was a little to low. the original icon was out of sight
What do you mean by the "'template' keyword"? How does that help?
Thanks for the help,
Bill
|
|
|
|
|
Bill Wilson wrote:
What do you mean by the "'template' keyword"? How does that help?
I mean C++ 'template' keyword. The one you write when starting template class declaration
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am trying to build a PowerPoint presentation using automation in MFC and not getting real far. As usual, the code examples given by MS in MSDN on how to do this only shows the advanced topics and leaves the easy stuff as an exercise. The problem is that there is no offical documentation that I can find on doing the easy stuff like adding a text box and changing the font color.
I was wondering if anyone knows of any documention and/or better examples on adding/formatting slides in a presentation. What I am trying to do is simple and shouldn't be this hard . I am adding text boxes which I figured out after many hours but I am unable to change the font color. I would like to do more once I figure out how the interface works.
Thanks!
|
|
|
|
|
Todd Hoop wrote:
The problem is that there is no offical documentation that I can find on doing the easy stuff like adding a text box and changing the font color.
I didn't play with automating PowerPoint - only with Excel and Word. The best way to get basic knowledge of the object model is to record some macros. You'll get the VB code in VBA Editor which you should be able to quite easily translate into C++ calls - method names will be identical. Just add textboxes and change the color.
Also, press F2 in VBA and you'll get Object Browser which presents objects, methods and properties.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz,
Thanks for the reply. I tried that path which does give an idea on how the objects come together but when implemented (changing font color in this case), I received errors stating that I am using objects that are not allowed in the current view. I believe it is from a .Select() call which is used to select the text to receive the font color change.
I will check out Objects Browser to see if it offers any clues.
Thanks!
|
|
|
|
|
Since a moment, I experienced a lot of problem with focus change between windows in a multithreaded application.
I have found some article in MSDN talking about 2 functions
LockSetForegroundWindow and AllowSetForegroundWindow
They seem very interesting to me but I cannot access to them
I have Visual C++ 6.0 and pack 5. What can be done to be able to use those functions.
If somebody know where I can found precise info concerning how works focus change, say it to me. Thanks
|
|
|
|
|
gwenael dourmap wrote:
They seem very interesting to me but I cannot access to them
You'll need recent Platform SDK - it contains required header files and libraries. You can download it from:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
... but the download is huge.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello, first of all let me thank you for reading those 4 short questions, for your time and help.
>> INTRODUCTION:
I have to read and write information from a non thread safe DLL very often, imagine that we are talking about obtaining real time information from that DLL.
This DLL allow me to get errors, coordinates, what's happening in general... and set values to var's of/from another program.
I'm using WM_TIMER messages to get this information and each 10ms. the information is required.
>> QUESTIONS:
1.
What could happen if the WM_TIMER message handling time is bigger than the 10ms.?
2.
Is there any way to discard the messages received while one message is being handled?
3.
The information required from the DLL should be as recent as it could be, is this the most correct way of working?
4.
Is there any other way of requiring information continuously without getting the processor performance seriously affected?
Thank you very much.
|
|
|
|
|
AFAIR, Windows will not fill your message queue with WM_TIMER when you're processing them slowly.
Regarding questions 3 and 4:
Describe your application in more detailed fashion. Since you're worried about processing times longer than 10ms, the problem may be with slow display of information.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello, first of all, let me thank you for your interest.
Tomasz Sowinski wrote:
Describe your application in more detailed fashion
Here's the description:
My MVC++6 app. is only a GUI for another program (let's call it XProgram).
XProgram is a program that controls the movements of a machine it allows me to move motors, read positions with encoders, activate and deactivate actuators and read sensors state.
The DLL that I have is supplied with XProgram and it allow me to get access to what I will call an "adress" this adress can contain a value of any type (string, double, float, integer...) then I use that DLL to get and to store information from/to the XProgram.
I'm worried because of the fact that if anything fails the machine can stop working, or even worse, it can wound somebody.
The only way that I have to work is to continuously ask for the values that have to be shown, and I would like to get the best way of doing it without recompiling the code in each machine. Moreover, I would like to work as in a realtime app. discarding the messages that cannot be processed because another message of the same type is being processed.
Of course I'm still very novice, and now you know more about the way of working of my program, and about my problem too. Then, if you know another solution that can be a good deal for me, please, tell it to me.
SUMMING UP:
I obtain and send information to XProgram from my GUI program using a DLL.
I need this to be fast.
I need the processor as free as it would be possible (in order to let XProgram work).
Thank you very much.
|
|
|
|
|
Joan Murt wrote:
I need the processor as free as it would be possible (in order to let XProgram work).
This may be difficult, if you don't have the access to DLL code. In such case, you can only repeatedly check the values, which always results in high CPU usage.
If you have the access to DLL code, you can use various synchronization objects, just like Carl pointed out in his reply.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
1) Nothing could happen, besides that the update would occur less frequently. However, I believe 10 ms is too frequent if the update is made only for updating a GUI. It could probably be 250 ms (a quarter of a second), or even higher.
2/3/4) Using a WM_TIMER message to pull information is an old fashion, "16-bit" type solution, which, as you've noticed, usually affects performance. While it is possible to discard intermediate messages that have arrived during processing of another (by using the message filtering parameters of PeekMessage to remove such messages), it would be better to implement a push design in the DLL.
If you have the DLL's source code, you could change it to signal a kernel object (such as an event) as soon as new information is available. The event would typically be created by the consumer application, and be supplied to the DLL through some initialization function. The application would then wait on this object to become signaled, either in a separate worker thread (the better choice since it wouldn't lock up the GUI during update processing), or in its main thread by using MsgWaitForMultipleObjects (in order to allow for window message processing).
When signaled, the application should do whatever needs to be done for retrieving data from the DLL and updating the user interface, then return and wait for another update to occur. This way, the update thread will only be active when new data is available (which could be after 5 ms or 15 minutes).
If you need to limit the update interval (i.e., data is sometimes available more often than you'd like to update the GUI), you could create a WaitableTimer object with say a 50 ms interval, and let the thread wait for both the update event and the timer object to become signaled (WaitForMultipleObjects with bWaitAll = TRUE). This way the update cannot begin until the wait interval has expired even if data is available.
Good luck!
|
|
|
|
|