|
Thanks!! That worked and was just what I needed!
As to why I'm doing it this way - I basically don't know any better. I am rather new to windows programming (lets just say that I learned FORTRAN using punch cards). The application I am writing is controlling some hardware so until today I was more focused on just getting the code to talk to serial ports and didn't want to try learning anything else at the same time. As long as we are on that topic, though, can you recommend a good book (or other resource) for someone starting out with MFC or WTL - something with decent examples that an old fart used to programming in vanilla C can understand
|
|
|
|
|
Mats Selen wrote: As to why I'm doing it this way - I basically don't know any better. I am rather new to windows programming
Fair enough
Mats Selen wrote: can you recommend a good book (or other resource) for someone starting out with MFC or WTL - something with decent examples that an old fart used to programming in vanilla C can understand
For WTL - Michael Dunn's article series on this site[^] is good.
For MFC - mmmmm, not sure. I started MFC programming over 10 years ago, when there were still MFC books around. I think it was an earlier version of this book[^]. If you have a Safari[^] subscription, that's on there.
Apart from that, best I can suggest is Google and possibly this[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Thanks - you guys make this a great forum!
|
|
|
|
|
Hi
I want to use vector to save following struct. It it possible?
template <class t="">
struct Cell
{
T Val;
};
vector <<cell>> vname ?????
What is the best solution for it?
Thanks,
modified on Sunday, March 1, 2009 1:49 PM
|
|
|
|
|
For example:
template <typename T>
struct Cell
{
T Val;
};
#define CELL_TEMPLATE(type) Cell<type>
std::vector<CELL_TEMPLATE(int)> my_cell_vector;
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thank you very much for your reply. I want to use one vector to save different data type of data. How can I do it?
Best,
|
|
|
|
|
What exactly do you mean by "save"?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
like following:
Cell<int> typeint;
typeint.Val = 1;
recVec.push_back (typeint);
Cell<float> typefloat;
typefloat.Val = (float) 1.111;
recVec.push_back (typefloat);
|
|
|
|
|
Well, if the structure isn't too complex, you could simply use a union and some way to signal what type your struct is actually holding. Something like:
#define STRUCT_TYPE_FLOAT 1
#define STRUCT_TYPE_DOUBLE 2
#define STRUCT_TYPE_INT 3
...
struct Cell
{
public:
short typeFlag;
union {
float valFloat;
double valDouble;
int valInt;
...
};
};
...
std::vector<Cell> my_vector;
Cell cell_double;
cell_double.valDouble = 1.23;
cell_double.typeFlag = STRUCT_TYPE_DOUBLE;
my_vector.push_back(cell_double);
Cell cell_int;
cell_int.valInt = 123;
cell_int.typeFlag = STRUCT_TYPE_INT;
my_vector.push_back(cell_int);
...
If it's a bit more complex than that then you should rather use pointers, something like this:
class CellBase
{
virtual ~CellBase()
};
template<typename TType>
class Cell: public CellBase
{
...
};
std::vector<cellbase> my_vector;
my_vector.push_back(new Cell<int>(123));
These are far from complete implementations of anything, just "skeletons"...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
Hmm, this is strange, i got a new notification of you posting something here, i click the link in the email, it brings me to this page but your message does not appear. I already got one of these once, maybe it is some caching problem, or something i don't yet know about the forums. Anyways, the email itself contains your post so here's an answer to that: in your CCellBase, make the destructor public.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I found the problem. Your solution is perfect.
Best,
|
|
|
|
|
One alternative to Code-o-mat's is to use a 'proper' type-safe variant class like Boost.Variant[^].
typedef boost::variant<int, float> Cell;
std::vector<Cell> cells;
cells.push_back(10);
cells.push_back(12.0);
for (int i=0;i<cells.size();++i)
{
if ( int* pi = boost::get<int>( cells[i] ) )
std::cout << "cells[" << i << "] = " << *pi << std::endl;
else if ( float* pf = boost::get<float>( cells[i] ) )
std::cout << "cells[" << i << "] = " << *pf << std::endl;
}
One design feature of the Boost.Variant is that you need to know what types you want to store when you build the program. Alternatively, you could use a Boost.Any[^], which allows you to store values of any type within it without pre-declaring them.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Can a ellipsis (Variadic) function i.e Func(...) be exported from a DLL.
The function takes variable number of arguments. Can this be exported through a dll?
|
|
|
|
|
Don't see why not - the C run time DLL manages it for printf, sprintf etc which are variadic.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
thanks for the reply, since standard functions are exported so the user defined must also be exported.
|
|
|
|
|
well i want image of any extension to be converted into binary and save it into some file. then read it back to generate image can any one help me plz
|
|
|
|
|
Well, ANY extension (i assume you mean format by extension, since extension is just some characters after the name of the image, which basicly means nothing, i can rename my Whatever.bmp to Whatever.jpg, that won't actually make it a JPEG image...) is a bit broad, but you can use CxImage[^] to load many kinds of formats, then you can create a DIB section using CreateDIBSection[^] and then blit the image onto it. Since CreateDIBSection gives you a pointer at the pixel data, you can do with it whatever you like, like save it as it is. Doing this the other way should be quite straightforward too. Hope that helps.
p.s: Could be that CxImage itself gives you a way to access the "raw" pixel data (or even save it as raw format), am not sure about that, but you can find that out yourself.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
They are already binary. May be you want to encrypt/decrypt them.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I'm busy following a tutorial where the author uses DUMPBIN to list exports, and OllyDbg to get the assembly code for an exported function. How would I find the functions code in the complete disassemly, given that the export tables RVA's don't correspond to real addresses in the disassembly.
The conceptual Reversing process occurs every time someone looks at someone else’s code. But, it also occurs when a developer looks at his or her own code several days after it was written.
- Elliot Chikofsky, Executive Secretary, IEEE Technical Council on Software Engineering
|
|
|
|
|
I have not used OllyDbg, but using Windbg you can get the unassembly of a function using the u command.
u myexecutable!myfunction
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I can't load a DLL in WindDbg, or if I can, I don't know how to, so I can't try this, but thanks anyway, I've come right with OllyDbg.
The conceptual Reversing process occurs every time someone looks at someone else’s code. But, it also occurs when a developer looks at his or her own code several days after it was written.
- Elliot Chikofsky, Executive Secretary, IEEE Technical Council on Software Engineering
|
|
|
|
|
Doesn't the disassembly include function names? That's the way I tend to read assembly language files, although I'll grant that it's usually (but not always) assembly language generated by the C++ compiler.
If the export is in a DLL, then you can get OllyDbg to a) debug the DLL, and b) call a selected export (by name). The 'call selected export' dialog has a 'Follow in Disassembler' button, which will place the disassembler at the start of that export.
Oh - and if (reading between the lines of some of your other posts) it's a system file you're disassembling, for which you don't have debug symbol information - you can get the debug symbol information from Microsoft[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote:
Doesn't the disassembly include function names?
Not dumpbin's disassembly. I know it's rough, but the author insists on offline analysis, which I agree with, to learn how to read asm code properly. I have IDA Pro Free, which gives me everything, but I don't want everything for the same reason that the author doesn't.
Stuart Dootson wrote: If the export is in a DLL, then you can get OllyDbg to a) debug the DLL, and b) call a selected export (by name). The 'call selected export' dialog has a 'Follow in Disassembler' button, which will place the disassembler at the start of that export.
Cool, thanks!
The conceptual Reversing process occurs every time someone looks at someone else’s code. But, it also occurs when a developer looks at his or her own code several days after it was written.
- Elliot Chikofsky, Executive Secretary, IEEE Technical Council on Software Engineering
|
|
|
|