|
Only a note:
If you want that all the view become a property sheet, you should change the base class of the view you want to change for the CPropertySheet.
|
|
|
|
|
Hello,
I have an applilcation wich requires several tools (but without knowing the existence of them). So, all of these tools are defined in a add-in dll and they all inherit from a common class (say CGenericTool).
This works fine but what I want to do now is that I want to produce several different dll depending of what tools the client require. So, in the dll I will have a function that 'tells' to the main application wich tools are available in it.
I have a "ToolFactory" class that produces the tools (based on the COM technology) and I want to ask this class wich tools it can produce. I want it to be very easy to add or remove tools. I though of something like this: in the file where the factory is define, I just have to add or remove the header file from the specified tool and the class would automatically knows about that!
Something like:
#include "stdafx.h"
#include "ToolFactory.h"
#include "GenericTool.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CToolFactory::CToolFactory()
{
}
CToolFactory::~CToolFactory()
{
}
HRESULT CToolFactory::CreateTool(CGenericTool** ppObject, int ToolType)
{
switch (ToolType)
{
#ifdef TOOL1_H
case TOOL1:
*ppObject = new CTool1;
return NO_ERROR;
#endif
#ifdef TOOL2_H
case TOOL2:
*ppObject = new CTool2;
return NO_ERROR;
#endif
default:
return -1;
}
return NO_ERROR;
}
int GetToolAvailable()
{
int Count = 0;
#ifdef TOOL1_H
Count++;
#endif
#ifdef TOOL2_H
Count++;
#endif
return Count;
}
Do you think it's a good way to do this ?? Or do you know any better idea??
I'm waiting for all your suggestion and ideas
Moonen Cédric
|
|
|
|
|
Hi!
I need a lib or something like that to draw trees or networks or everyhing that looks like nodes bound together with lines (like in Matlab/Simulink for example).
Do we have that here on CP ?
~RaGE();
|
|
|
|
|
I haven't seen anything on CP. In my experience, commercial graphing/layout libs aren't cheap.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello,
I'm trying to directly set the html in a web browser (CWebBrowser2) control using something like
m_browser.SomeMethod("<html><body>Hello, World!</body></html>")
Is this possible, using either a direct method or by getting an interface to the document properties? I can't find a list of the properties anywhere on MSDN or on the web.
If all fails I will just save the text to a temporary file and get the browser to navigate to the file.
Thanks,
John
|
|
|
|
|
Hello,
I'm doing an app in which I read a video file frame by frame. Once the "play" button has been pressed, I grab the next image until a "pause" button has been pressed.
I grab the message indicating that the pause button has been pressed with the peek method :
while( ::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)){
if((user_paused)&&(msg.message == BN_CLICKED)&&(msg.wParam == IDC_BUTTON_PAUSE)){
// stop the video
break;
}
if((msg.message == BN_CLICKED)&&(msg.wParam == IDC_BUTTON_CAPTURE)){
// continue the video but show the captured frame
}
if (!AfxGetApp()->PumpMessage()){
::PostQuitMessage(0);
return;
}
}
The message is grabbed since my video pauses but the loop never stops although I had a loop on a boolean user_paused which I put to true when the user presses on the pause button.
Since I don't understand exactly how the peek & pump function work, I don't know what's wrong. Could anyone help me ?
Thank you.
|
|
|
|
|
sandrineV wrote:
The message is grabbed since my video pauses but the loop never stops although I had a loop on a boolean user_paused which I put to true when the user presses on the pause button.
Not possible. It had to stop. Try :
bool bVideoPlaying;
while(bVideoPlaying)
{
::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE);
if((user_paused)&&((msg.message & BN_CLICKED)==0)&&((msg.wParam == IDC_BUTTON_PAUSE))
{
bVideoPlaying=false;
break;
}
else if(((msg.message & BN_CLICKED)==0)&&(msg.wParam == IDC_BUTTON_CAPTURE))
{
PlayVideo()
}
if (!AfxGetApp()->PumpMessage())
{
::PostQuitMessage(0);
return;
}
}
Here, if the video stops, it will exit the while loop, whatever happens.
Is sandrine your forename ? It sounds french...
~RaGE();
|
|
|
|
|
How to set WS_EX_TOPMOST style to a dialog window at runtime? I'm trying with ModifyStyleEx function but it's not working. Am I missing something?
|
|
|
|
|
Try SetWindowPos() with HWND_TOPMOST
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi
I've made a menu named 'IDR_MAINFRAME' (CMainFrame) which is loaded into the project.
This is the dutch version of the menu.
Now i want to be able to change some menu-captions at runtime.
I've looked up a few things @ MSDN but doesn't seem to work tho
I've tried to change the menu @ runtime like this:
void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{
CFrameWnd::OnShowWindow(bShow, nStatus);
//Check wheither dutch or french version
if ( !bDutch )
{
PutMenuIntoFrench();
//This will change a menu-caption into something else
}
}
void CMainFrame::ZetMenuInFrans()
{
CMenu* pMenu = GetMenu();
int iPos;
iPos = FindMenuItem(pMenu, "&Message");
pMenu->ModifyMenu(iPos, MF_BYCOMMAND, iPos, "&Voir Remarque");
}
FindMenuItem(..) was provided into some code @ msdn:
int CMainFrame::FindMenuItem(CMenu * Menu, LPCTSTR MenuString)
{
ASSERT(Menu);
ASSERT(::IsMenu(Menu->GetSafeHmenu()));
int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, MenuString) == 0))
return i;
}
return -1;
}
Anyone knows what the problem might be?
Would appreciate it much
Greetings
Jens
I already found the error:
pMenu->ModifyMenu(iPos, MF_BYPOSITION, id, "&Mytext");
i didn't check the param. very well
so everything works fine now
The only thing that bothers me is that this check is always performed OnShowWindow. It only needs 1x to be executed. I have a form where the user can select language: dutch / french
Can i call CMainFrame::ChangingOfMenu() there somewhere?
Greetings
Jens
Cyaz
|
|
|
|
|
Suppose I have a template class (Hash) which receives 4 types. The following template declaration is the find method of the template class:
template <class Key, class Data, class HashFunc, class KeyEqualFunc>
CsHash<Key, Data, HashFunc, KeyEqualFunc>::listIter CsHash<Key, Data, HashFunc, KeyEqualFunc>::find(const key_type& key)
How can I make these declarations shorter?
|
|
|
|
|
Are you sure you want to define find outside the definition body of CsHash ? Due to well known problems with template instantiation, standard practice is to define methods in place:
template<...>
class CsHash
{
...
listIter find(const key_type& key)
{
}
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for your response.
In the book I read, the definitions of the methods are outside the body of the class. Furtheremore, the definitions of these methods are quite long (almost the whole window in VC++). In this case, should I still define them inside the body of the class? Isn't there some other way using typedefs to accomplish this? I tried but got strange compiler errors.
Any suggestions?
|
|
|
|
|
You can move the definitions of your methods out of the class body by declaring them inline . But this gets you back to the long names problem. typedef s are of little help here, since they should have to be declared as part of the class, thus forcing you again to instantiate them with template parameters.
This is the way C++ syntax is. I'm afraid you'll have to live with overwhelming template declarations and/or bloated class bodies. In case this makes you happier, everybody else just resorts to the second solution and provides some sort of documentation where the class interface is stated in clearer terms.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, everyone!
In the following functions, I want to push a new object into a
vector. The vector is a global vector (variable). I have seen
two ways of doing this. I simply want to know which way is correct
and which way is more efficient? Are there some potential problems
in either of the two methods?
Source code:
--------
Function1 (T& NewElement)
{
GlobalVector.push_back (NewElement);
}
Function2 (T NewElement)
{
GlobalVector.push_back (NewElement);
}
--------
Thanks in advance,
George
|
|
|
|
|
std::vector::push_back() makes a copy of the object you give it - all STL containers do. (It is worth to keep that in mind, because you are responsible to provide working copy-constructors and assignment operators.)
The best way would be the one you did not write:
Function0 (const T& NewElement)
{
GlobalVector.push_back (NewElement);
} using a const reference.
A non const reference would be OK here, but if you do not intend to manipulate NewElement , you can as well tell that, and make your Function1 able to cope with constant NewElement s.
By-value arguments (Function 2 ) would result in an additional temporary local copy, which is in turn copied into the vector. Maybe the compiler optimiser would get rid of the unneeded copying, but is wise to rely on that?
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddy!
From your reply, I think I must supply my class
a copy constructor if I want to push it in STL
container. Am I correct?
But, what form of copy constructors should I
define? Since copy constructor has many form.
regards,
George
|
|
|
|
|
George2 wrote:
From your reply, I think I must supply my class
a copy constructor if I want to push it in STL
container.
If you do not, the compiler will automagically do that for you.
But what the compiler provides is very basic: It copies each element of your object.
Bitwise copying with basic types (int, double etc.) and calling the copy constructor with objects.
That may well be exactly what you want - then there is no need to write one yourself.
But if you need complicated stuff you need to write that yourself. And while you are at it, you also need to make an assignment operator, doing the same.
George2 wrote:
Since copy constructor has many form
No. it has exactly one form:
NewElement(const NewElement& rhs);
The ones I write are mostly very small, because I only call the assignment operator in them:
NewElement::NewElement(const NewElement& rhs)
{
*this = rhs;
} My assignment operator then does all the copying. So the two are always consistent.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddy!
I think in your case, when vector.push_back is called,
the copy constructor and assignment operator will be
called. I think in your case, copy constructor will be
called first and then copy constructor will invoke the
assignment operator. Am I correct?
regards,
George
|
|
|
|
|
George2 wrote:
copy constructor will be
called first and then copy constructor will invoke the
assignment operator
Yes. That is the way it is intended. There is only one place I have to update if I add another member variable.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddy!
I know that the system will supply me a default copy ctor.
It copies member-wise. My question is, if I supplied my
own version of copy ctor. Must I supply the assignment
operator? Why? How can I decide the case?
regards,
George
|
|
|
|
|
George2 wrote:
if I supplied my
own version of copy ctor. Must I supply the assignment
operator?
I am not totally sure if you must, but I am sure that you absolutly should! How do you guarantee consistence, between construction and assignment when you have written only one of them?
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddy!
George
|
|
|
|
|
NewElement::NewElement(const NewElement& rhs)
{
*this = rhs;
} This is not, IMHO, good practice. It works for sure, but you are incurring the innecesary overhead of default constructing your object prior to assignment. For small classes this could be negligible, not so if the default constructor is heavier.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, Joaquín buddy!
Hmmmm... I do not understand what you mean. But I think
you are correct.
So, can you show me an example?
regards,
George
|
|
|
|