|
hi all,
i am looking for a complete sample for Zlib compression/decompression.Anyone knows the source of sample?
Thanks in advance
Abhishake
|
|
|
|
|
Try here http://www.winimage.com/zLibDll[^]
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Recently,I see the program written by other people.
At his program,there is a function WinMain which has a parameter lpCmdLine.And it use this parameter at his program.
I want to use the lpCmdLine parameter at my dialog based program. But I don't know how I can get the value of this parameter at my dialog based program.
Could you tell me how?
Which function provides the function ?
Thanks!
The WinMain function at his program is as follows:
int PASCAL WinMain(HINSTANCE hInstC, HINSTANCE hInstP, LPTSTR lpCmdLine, int nCmdShow)
{................}
free like a bird
|
|
|
|
|
GetCommandLine()
There is no spoon.
mail
|
|
|
|
|
CWinApp::m_lpCmdLine points to the same TCHAR * as the one provided by the WinMain function in the lpCmdLine argument.
There is also a helper member function to ease the argument parsing: CWinApp::ParseCommandLine.
Guoguor wrote:
The WinMain function at his program is as follows:
int PASCAL WinMain(HINSTANCE hInstC, HINSTANCE hInstP, LPTSTR lpCmdLine, int nCmdShow)
Amazing
Actually, this is required signature for the entry point for a windows program. Your dialog based program also defines such a function, but MFC hides all the dirty details, so that you can only see the dirty details of MFC...
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi,
when the check box is checked,by clicking the control button, it should be in the pushed mode.
When i uncheck the check box, the control button should return to the normal mode.
How is it possible?
Pls help.
Mithuna
|
|
|
|
|
Use a toggle button for this. It nothing but a check box with style "push like = true".
If you want to set this at run-time then use BS_PUSHLIKE.
There is no spoon.
mail
|
|
|
|
|
Hi,
I have written a program in which I have included another file in which my whole class declaration is defined. It is compiling without any errors but givin linking errors. I did reffered to Microsofts reference over net for tht error.. but didn't get anything from it...here is my code...
Main program (heel.cpp)...
#include <fstream.h>
#include <iostream.h>
#include <math.h>
#include <conio.h>
#define phi 3.1412
#include "geom.cpp"
void main()
{.......
....
Cube *C = new Cube[50];
....
for(...)
C[i].set_values(dis,dim,res1);
...
..
}
Another program (geom.cpp) in which the class is defined, where all the methods are defined in this file only....(here i haven't included any header files)
class Cube
{
public:
--data members declaration.....
public:
Cube();
void set_values(double x, double y, int z);
void set();
void process();
int check(int i, int j);
};
this is the error tht i am getting...
Linking...
heel.obj : error LNK2001: unresolved external symbol "public: static int (* Cube::bound1)[2]" (?bound1@Cube@@2PAY01HA)
Debug/heel.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
any help is appreciated....
thanks in advance,
Suman
|
|
|
|
|
suman if i am getting it correctly, you have a file named heel.cpp (main file) and a file named geom.cpp which contains your class declaration. if this is the case then the linker error is due to the fact that you have declared member functions in your class but havn't defined them any where
to remove the linker error either write you geom.ccp file as
class Cube
{
public:
--data members declaration.....
public:
Cube()
{
}
void set_values(double x, double y, int z)
{
}
void set()
{
}
void process()
{
}
int check(int i, int j)
{
}
};
or define you members in a separet file e.g
file:geom.h
class Cube
{
public:
--data members declaration.....
public:
Cube();
void set_values(double x, double y, int z);
void set();
void process();
int check(int i, int j);
};
file: geom.cpp
#include "geom.h"
Cube::Cube()
{
}
void Cube::set_values(double x, double y, int z)
{
}
void Cube::set()
{
}
void Cube::process()
{
}
int Cube::check(int i, int j)
{
}
and in you heel.cpp file just include geom.h like this:
#include "geom.h"
Hope this will remove the linker error . plz inform me if this works or still you are getting same error
regards
Muhammad Azam
ned_azam@yahoo.com
muhammadazam_cis08@hotmail.com
|
|
|
|
|
also if you have an static data member in your class, like it seems that you have declared static int bound; or something like this then out side your class write int cube::bound=0; like
class cube
{
static int bound;
.
.
.
}
int cube::bound=0;
this may also be the couse of your linker error
regards
Muhammad Azam
ned_azam@yahoo.com
muhammadazam_cis08@hotmail.com
|
|
|
|
|
Hi Azam,
thanks for ur valuable reply. Actually the second reply worked out. Its due to the static declaration in the class. Anyway now I am using direct declaration witout static.
but i want to know how to declare a static type in a class. I have tried the way u specified but then the compiler is giving me error. My bound variable is a 2D array.
once again thanks,
Suman
|
|
|
|
|
Hi suman
i think you are trying to declare a 2D static array of integers like this
static int bound1[10][10] in your class.
Suman, static members are basically class members and they must be defined expilicitly after your class definition. like i have declared something like static int bound1[10][10] in my geom.h file and when i compiled the program i got the same linker error as you stated, then i defined int Cube::bound1[2][2]={0}; in my geom.cpp file before defining constructor or any other member then there was no linker error ( notice class declaration in .h file and definition in .cpp file.
suman, in C++ we say static members are like 'metadata' (data about data). e.g if you want to know at some time how many objects of your class are there in memory then static member is used for this purpose like
file: test.h
class ABC
{
public:
static int counter;
private:
[some members]
public
ABC();
~ABC();
[some methods]
};
file: test.cpp
int ABC::counter = 0;
ABC::ABC
{
counter++;
}
ABC::~ABC
{
counter--;
}
and in main progeam
file: Main.cpp
#include "test.h"
void main (void)
{
ABC obj1,obj2,obj3;
cout<<ABC::counter;
}
output: 3
|
|
|
|
|
Hi Azam,
thanks for ur advice and suggestion and explaining in such a detail. I got ur point and defined in the same way tht u have explained.
cheers,
pavan.
Suman
|
|
|
|
|
you are welcome
its my pleasure if i could be of any help for you in this regard.
Azam
|
|
|
|
|
|
How can I disable [X] button on right-top corner of the sub-window? What I mean here is a MDI application. I want to disable [X] button of childwindow. However I'm not sure whether the [X] button belongs to childwindow or not.
I like show my knowledge with others
|
|
|
|
|
Try using this code
UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
CMenu* pSM = GetSystemMenu(FALSE);
if(pSM)
{
pSM->EnableMenuItem(SC_CLOSE, menuf);
}
This will work
|
|
|
|
|
> CMenu* pSM = GetSystemMenu(FALSE);
Thank you for you reply. But I have a question, how can you confirm its ChildWindow's menu or something else?
I have try the following method, but it doesn't take effect:
CMDIChildWnd *pCMDIChildWnd = MDIGetActive();
CMenu *pMenu = pCMDIChildWnd->GetSystemMenu(FALSE);
pMenu->EnableMenuItem(ID_xxx, MF_BYCOMMAND | MF_GRAYED);
|
|
|
|
|
Use GetActiveView / GetParentFrame to get the address and use it along with GetSystemMenu.
|
|
|
|
|
I want to open a pipe to the usb port and write some data. Can someone point me in the right direction?
Thanks,
Jill
|
|
|
|
|
Hi,
i'd like to put some objects to a std::vector. These objects contain different data but are derived from one abstract base class. To keep them in one vector this vector is instantiated with a pointer to the baseclass and therefore the derived objects could be put in... This seems to be kinda problematic since the implicite cast to the baseclass obviously destroys some information?! Is there a conveniant workaround?
best regards
|
|
|
|
|
yahp wrote:
Is there a conveniant workaround?
Not really.
This is a general design issue which isn't generally a hassle to get around, but it depends on the size of the inheritance heirarchy. It's generally caused by the abstract base class not being truly representative of the contract that the subclasses should fulfill.
1. Change the abstract base class. Changes should allow any operations of the subclasses to be called through the base class. Although this is a hassle it promotes the best design and IMHO provides the best support for maintainability
2. Store pointers to the base class and the objects themselves in separate collections. This works well if the problem is fairly small - but it gets ugly because you need to keep many collections in sync (problematic for objects on the stack).
3. Use a type field. Supposedly an OO No-No - keep track of which type the object is inside a value within each object. You can then cast to the appropriate object. Probably not a good idea unless you know that this part of your design won't get much larger.
4. Use a dynamic_cast. Similar idea to 3, but the compiler keeps track of the information for you. If the dynamic_cast fails you get a null pointer back.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi,
of course can the baseclass not fulfill the contract to the subclasses, if it could what would be the use of inherited classes
1) I don't see how this could work. The baseclass cannot know about the features of the children?! So how can it allow access to unknown members?
2) Huu. The whole inheritance-thing was just about to avoid such an situation.
3/4) Mmmh. I'm not sure what this "no-no" would be
The problem I see is the fact, that when you drop an item of the inherited class in the vector of the baseclass there will be an implicite upcast which will eventually destroy any information about the objects. BTW there was no warning from the compiler while doing so...
Thanx for your help and please don't be upset: I simply do not understand how your ideas could work... (well I understand (2))
|
|
|
|
|
I should have explained more carefully and read your post a second time
Polymorphism isn't about extending a class so you can add extra fields in the subclasses, it's about refining the operations that the class can perform.
When you hold a pointer to an abstract base class you are throwing information away. The trick is to make sure that the base class defines all the operations that you could ever need to call on any of the subclasses, via the base class pointer. 'All the operations you could need to call' is very vague, thus what I implied in item 1 of my previous post - sometimes it's a matter of tweaking the base class if you can see operations missing.
The key concept here is that two subclasses of a common base class should be fully substitutable for one another - they fulfill a common 'contract', which is defined by the operations of the base class. There are lots of things you can do with inheritance, but this is the only thing which correctly models the inheritance IS-A relationship.
I Strongly recommend you do some research on the Liskov Substitution Principle which I've tried to explain (very briefly and not very well). For me this material was a real revalation - it shed light on almost 18 months of lectures.
The Liskov Substitution Principle
Don't just believe me about this though, the current C++ standards committee and many influential people working with them are using LSP as the starting point for all teaching. Herb Sutter, Scott Meyers, Andrei Alexandrescu, Bjarne Stroustrup just to name a few are all advocates of this principle.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi,
mmh, I see, but this LSP seems to me just *one* approach to inheritance or to speak with Bruce Eckel's tounge: "it is nice if your design works out that way". Allmost every classical example on inheritance will be a set of classes with derived subclasses that extend the interface of the baseclass and do not only override base-class functions. This is exactly what the c++ RTTI is about. Ok, in a sense this breaks the IS-A relationship to an IS-LIKE-A.
I will have a deeper look to this article and hopefully I will understand the whole truth I just don't understand why they did not enforce this rule in cpp if it is that important.
But for now I need to think of an easy and shortterm solution of my problem.
|
|
|
|