|
led mike wrote: Really, that's your advice?
Yes.
led mike wrote: Are you kidding me!
Why do you think that?
OK you're right, in my proposal there is (almost ) no way to avoid the troublesome interdependency of the headers.
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.
modified on Tuesday, December 11, 2007 11:12:43 AM
|
|
|
|
|
As cedric said, you can set the parameters to be accesed with public or leave them private and create some SetParameter () // GetParameter () , to write // read the variables. Then just including the header you should have access to them through a pointer to the dialog.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Lord Kixdemp wrote: C++ doesn't allow Client to know anything about Dialog.
Here's the clue. C++ allows Client only to know that Dialog is a Dialog, i.e the public interface of the Dialog class. This is painful because it restricts what Client knows and you have to make everything about Dialog you want accessible available as part of the public interface but it's great in the long term because Client doesn't care which Dilaog it is or even what sort of Dialog as long as it is a Dialog class the code will work. Do it in C and it'll be done in half the time and obselete and unmaintainable in months. In C++ it might take a while to do but you'll still be using bits of it when you're old and grey.
I port a lot of C code to C++ so here's a method you might be able to simulate if you find it easier to think in C.
I take each C source file and turn it into a class.
Every file static variable becomes a member variable, every function extern(ed) in any other file becomes a public member function.
Every little utility function not extern(ed) becomes a private member function.
Then I create one single file static instance of the class. This gets me a half way house between C and C++ and by the time a whole project has been tranformed like this I can see what the public interfaces need to be and how the instancing of each class should be controlled. What owns what. Eventually all the file level statics disappear and the large classes are reworked into objects that match the required instancing pattern. OOP is not so hard after all.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I deserve harsh punishment for not Googling first.
|
|
|
|
|
|
Lord Kixdemp wrote: I deserve harsh punishment for not Googling first.
And you will likely receive harsh punishment if you tightly couple a business object to a view. Your punishment will be in the form of dealing with the technical debt[^] of a poor design. OOD is a tool that can solve problems of software development like hard to maintain and inflexible code. Notice I said it "can" solve those problems, or a sub optimal design, like one that would tightly couple business classes to view classes, could result in "creating" those same problems.
There is much information available on the subject of Object Oriented Design. I strongly suggest you take some time to become familiar with things like best practices and principles of object oriented design. You might try some articles or tutorials and for sure get introduced to Software Design Patterns[^].
Good luck
|
|
|
|
|
|
Lord Kixdemp wrote: would you mind pointing out which of those is the best to start with?
It's almost impossible to know which one is better suited to your needs. Everyone is different. I will tell you that from my experience I have been a student of Object Oriented Design for years and I see no end to that on the horizon. So if your intention is continual improvement buckle up for a long ride of reading and trying to understand OOD. And if that wasn't enough there is Aspect Oriented and a new resurgence of Functional Programming that is being added to the .NET platform.
If you do spend time reading on the subject you will eventually come upon some of the leading experts in the industry. They have Wiki's, Blogs whatever that discuss OOD. A couple of them are Kent Beck and Ward Cunningham. Cunningham maybe invented the Wiki[^], not sure, where he started the Portland Pattern Repository. Anyway that site is so full of information I doubt you could ever read it all.
Hope that helps.
|
|
|
|
|
One possible solution is to send messages to the dialog. Your client needs the target Window (CWnd*) and you can use the SendMessage() , or I suggest the PostMessage() API because it is non blocking.
Another way are global objects and structures or callbacks.
Interesting and important is to use the Timer-function to execute regurarly some actions!!!
Search for WM_TIMER
Greetings from Germany
|
|
|
|
|
hi
i am working on touch screen based application,I used edit box which have vertical scroll bar.I want to increase the width of vertical scroll bar of edit box.How is this possible
malik
|
|
|
|
|
Have you looked into the articles? I remember that there were some owner drawed controls with lots of extras. Maybe one of them has what you are looking for.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi,
My project does not contain any resources file , and I need to load an ICON from a specified location.
I used the following :
m_hIcon = AfxGetApp()->LoadIcon(_T"C:\test\res\OPTIONS_ICON.ico"));
but m_hIcon is allways NULL.
Anyone?
With best regards,
Eli 
|
|
|
|
|
You need to escape backslashes inside strings, change
eli15021979 wrote: m_hIcon = AfxGetApp()->LoadIcon(_T"C:\test\res\OPTIONS_ICON.ico"));
into:
m_hIcon = AfxGetApp()->LoadIcon(_T"C:\\test\\res\\OPTIONS_ICON.ico"));
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.
|
|
|
|
|
Thanks for your quick answer...
I tried this also , but m_hIcon still NULL.
Note that I'm able to load an ICON using a resources file
by AfxGetApp()->LoadIcon(IDI_NEW_LOGGER_ICON);
Thanks again,
Eli
|
|
|
|
|
eli15021979 wrote: AfxGetApp()->LoadIcon(_T"C:\test\res\OPTIONS_ICON.ico"));
will not work. U should use the LoadImage() function to load the icon from a file.
|
|
|
|
|
Did you try with LoadImage?
|
|
|
|
|
Hi all,
I encountered something that affects the embedded attachments in converting a MAPI to MIME message, I need my mimeheader to be multipart/related for the embedded attachments and multipart/mixed for the body and the regular attachments. At the ATL mime only multipart/mixed is available, Can anyone help me constructing a new boundary correctly and making the multipart/related header too.
thanks,
Jj
|
|
|
|
|
Hello all, I am developing one application, in that have created one report file with HTML tags. I am opening that in my application it self. If the report file is big then my application is displaying a message "Cannot create unique tag name,giving up". I did not understand this message. Can you please tell me how can i avoid this ?
|
|
|
|
|
How are you opening it ? What is throwing the error ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
How did you try it and what was your code?
|
|
|
|
|
I have created a file which contains tables, text and a tree manner view also with HTML tags. No problem in opening this file if the file is small. If the file is big then my application is displaying a message "Cannot create unique tag name, giving up",
|
|
|
|
|
|
Hi everyone,
I came to the point where I would like to use virtual inheritance (don't ask why ). Although I have found several info on the web and I am pretty sure how I am going to use it, I have one problem left:
INCLUDE FILES.
All articles describe how to use virtual inheritance, but always in one file, something rarely useful in large projects. Everything I tried with #include files doesn't work. Here is my example:
-----------------------------------------------------------------------
// file Base.h
#ifndef BASE_H
#define BASE_H
class Base{
public:
Base();
virtual ~Base();
};
#include "Derive1.h"
#include "Derive2.h"
#endif
-----------------------------------------------------------------------
// file "Base.cpp"
#include "Base.h"
Base::Base(){}
Base::~Base(){}
-----------------------------------------------------------------------
// file Derive1.h
#ifndef DERIVE1_H
#define DERIVE1_H
#include "Base.h"
class Derive1 : public virtual Base{
public:
Derive1();
virtual ~Derive1();
};
#include "Join.h"
#endif
-----------------------------------------------------------------------
// file Derive1.cpp
#include "Derive1.h"
Derive1::Derive1(){}
Derive1::~Derive1(){}
-----------------------------------------------------------------------
// file Derive2.h
#ifndef DERIVE2_H
#define DERIVE2_H
#include "Base.h"
class Derive2 : public virtual Base{
public:
Derive2();
virtual ~Derive2();
};
#include "Join.h"
#endif
-----------------------------------------------------------------------
// file Derive2.cpp
#include "Derive2.h"
Derive2::Derive2(){}
Derive2::~Derive2(){}
-----------------------------------------------------------------------
// file Join.h
#ifndef JOIN_H
#define JOIN_H
#include "Derive1.h"
#include "Derive2.h"
class Join : public Derive1, public Derive2{
public:
Join();
virtual ~Join();
};
#endif
-----------------------------------------------------------------------
// file Join.cpp
#include "Join.h"
Join::Join(){}
Join::~Join(){}
-----------------------------------------------------------------------
// file main.cpp
#include "Base.h"
int main(){
Join test;
return 0;
}
-----------------------------------------------------------------------
This will not compile, probably because both Derive1.h and Derive2.h include Join.h. However, any combination I've tried didn't solve me the problem and the program still wont compile.
Any clues anyone?
Thanx,
Nik
|
|
|
|
|
First, please use the pre or code tags to format your code properly.
Now, for your question: you can remove all the includes that you put at the end of your files, you don't need them and they cause the problem. Include simply means that the compiler will replace the directive by 'pasting' the code from the included file. So, guess what happens if file1 includes file2 which in turn include file1 ? Yes, that's infinite recursion
|
|
|
|
|
Firstly, thanx for your answer.
True, but infinite recursion is avoided by the #ifndef directives. The reason I am putting them there is that I only want to include my Base class in the main program. If I remove them, then I have to include all the different files (Derive1, Derive2, Join).
In all other cases, this pattern works fine. But because in this case there is a "diamond" structure of inheritance (that's why I use virtual inheritance), this causes the problem here.
Is there any way to keep this pattern (I only want to include my "Base.h" file in "main.cpp") and still complile somehow?
|
|
|
|