|
I needed these recently myself. Searched through all files in VS distribution and couldn't find them.
Here is what I'm using:
#ifndef _QWORD_DEFINED
#define _QWORD_DEFINED
typedef __int64 QWORD, *LPQWORD;
#endif
#ifndef MAKEQWORD
#define MAKEQWORD(a, b) \
((QWORD)( ((QWORD) ((DWORD) (a))) << 32 | ((DWORD) (b))))
#define LODWORD(l) \
((DWORD)(l))
#define HIDWORD(l) \
((DWORD)(((QWORD)(l) >> 32) & 0xFFFFFFFF))
#endif
|
|
|
|
|
You can use the LARGE_INTEGER union and a little casting to accomplish everything those macros would do. There is also a ULARGE_INTEGER for unsigned use.
|
|
|
|
|
Hi,
I have following problem:
Suppose I have such class:
class NiceRectangle{
private:
Display dispHnd; //display handle
void DisplayRectangle(); // displays rectangle on screen
public:
unsigned int width; // dimensions
unsigned int height;
COLOR color; // interior color
unsigned int GetArea(); // return area
};
Is to it possible to perform some operations when I assign value to the width or height member.
Let`s say I write:
NiceRectangle nRect;
nRect.width = 100;
And when I assign 100 to nRect.width I want to perform instructions:
width = 100;
ShowDisplay(dispHand);
DrawFrame(width, height, Black);
...
and with
nect.height = 9;
I want to play a sound, open the fridge and finally assign 9 to height.
Another words, I want assigment operator = to act like function, but I want to be able to use it for any public member(variable).
I know it is possible to overload operator for a class, but I don`t want to overload an operator for a whole class, but only for its particular member.
I`ve heard about MFC which, I believe, performs similar tasks, but I want a more general solution, for example for linux.
Can this be done? How?
Thank You
|
|
|
|
|
In general, it is not good practice to make the members of your class public. In your specific case, it makes even more sense to make them private and provide getter and setter functions. In the setter function, you can them simply put any code you would like:
void NiceRectangle::SetWidth(unsigned newWidth)
{
width = newWidth;
}
On the other hand, I doubt that you would be able to open your fridge, I see some technical limitations here
|
|
|
|
|
It is a solution, but it os not very convenient.
I prefer the way it works in DELPHI. You change value of a property and change is instantly displayed.
|
|
|
|
|
Acutura wrote: It is a solution, but it os not very convenient.
Why ? This is how it should be done in C++.
Acutura wrote: You change value of a property and change is instantly displayed.
You have to make a separation between your "model" and your "view". In this case, it is much better to leave anything of refreshing or drawing out of your setter. Instead, you should refresh your "view" (which will probably in turn ask the figure to redraw itself).
I guess you are making a kind of drawing application in which you can draw rectangles ?
|
|
|
|
|
Acutura wrote: It is a solution, but it os not very convenient.
Why is it not convenient? Do you mean "I don't like it"?
Acutura wrote: I prefer the way it works in DELPHI. You change value of a property and change is instantly displayed.
Why bother?
Anyway, with a bit of extra work you may implement it in C++ , for instance (doggy details & error checking left as exercise )
class NiceRectangle;
class RectWidth
{
NiceRectangle * _pParent;
int _iWidth;
public:
RectWidth():_iWidth(0), _pParent(NULL){}
RectWidth (NiceRectangle * pParent):_pParent(pParent),_iWidth(0){}
RectWidth & operator = (int i);
operator int(){ return _iWidth;}
};
class NiceRectangle
{
public:
NiceRectangle():width(this){}
RectWidth width;
void OnWidthChange(){printf("new width is %d\n", (int) width);}
};
RectWidth & RectWidth::operator = (int i)
{
_iWidth = i;
_pParent->OnWidthChange();
return *this;
}
void main()
{
NiceRectangle nr;
nr.width = 100;
}
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
That`s exactly what i needed!
But I don`t think I`ll use it. Just, too much writing. I`ll have to think about something else(it means, I won`t be using assigment operator).
Nevertheless, thanks
|
|
|
|
|
Acutura wrote: That`s exactly what i needed!
But I don`t think I`ll use it. Just, too much writing.
Well, some things built-in of other languages, must be coded in C++ (maybe amusing). I would go on the path suggested by Cédric.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Acutura wrote: And when I assign 100 to nRect.width I want to perform instructions:
width = 100;
ShowDisplay(dispHand);
DrawFrame(width, height, Black);
Why do you want to fool your class consumer (maybe yourself)? Just make a method called:
NiceRectangle::UpdateTheGUIOnRectWidthChange(int iNewWidth)
{
}
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi, I have programmed a simple directshow audio player, a GUI application. I want it to select multiple files and play the subsequent files. But I am having problems using the functions FindFirstFile, FindFirstFile to search for the subsequent files. I have tried the way MSDN describes but it doesn't work (or I don't get it well). I have already included the flag that allows multiple file selection and I am able to select multiple files, but I find it difficult to use these functions to get subsequent files. I need help on how to use them, and if I can also get tutorials describing how to use these functions. Please help
|
|
|
|
|
Why do you need to post it again and again?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Helo,
If i have a string" 21/jack", how can i let the program to distinguish numeric as age, and String as Name? :
for example , from name = jack , age = 21, how can do this ? if possible plz provide more usage of how to split String .
thx!
Thanks !
modified on Monday, September 28, 2009 8:52 AM
|
|
|
|
|
Since your request looks far from clear, could you please provide an input example (and the expected output)?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You use CString::Tokenize[^] to split the string.
After you have split the string, convert each one into what you expect them to be (i.e. first one is the age, second is the name, ... )
M.
This signature was proudly tested on animals.
|
|
|
|
|
You may use CString::Tokenize [^] (or _tcstok [^] if you're not using MFC ) to split the string and then, for instance, _tcstol [^] to discover the actual type of the obtained strings.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi, I have programmed a simple directshow audio player, a GUI application. I want it to select multiple files and play the subsequent files. But I am having problems using the functions FindFirstFile, FindFirstFile to search for the subsequent files. I have tried the way MSDN describes but it doesn't work (or I don't get it well). I have already included the flag that allows multiple file selection and I am able to select multiple files, but I find it difficult to use these functions to get subsequent files. I need help on how to use them, and if I can also get tutorials describing how to use these functions. Please help
|
|
|
|
|
What about documentation [^]?
Could you please post the failing code?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
i m developing an application for Pocket PC.
now i want to execute on pocket pc.
Please tell me how can make setup of my application and produce cab file.
please expalin me with any example if possible.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
|
whats the advantage of inheritence over template...
vikas da
|
|
|
|
|
tasumisra wrote: whats the advantage of inheritence over template...
That you haven't to use a template.
On the serious side: They are quite different language constructs, with different purposes, usually you cannot use template instead of inheritance or viceversa.
Final note: a good OOP book may help.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It's a bit like asking what's the advantage of micro-wave over televsion
It's two different things used for two different purposes, there's no advantage of one over the other one (otherwise, why keep both of them? )
|
|
|
|
|
Thanks guys .. i let the guy know who asked me the question .. actually i thouht there might be some relation beyond my knowledge .. that why i asked here ..
actually he was more concerned about reusability of a function to use either from template or from inheritemce...?
vikas da
|
|
|
|
|
googling around i found some extension to the default datetimepicker to make backcolor suitable...what i have till now is:
namespace primoAlpha {
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Security::Permissions;
public ref class extendedDateTimePicker : DateTimePicker
{
private:
Color _BackColor;
public:
property Color BackColor
{
virtual Color get() override {
return _BackColor;
}
virtual void set(Color value) override {
_BackColor = value;
Invalidate();
}
}
protected:
[SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)]
virtual void WndProc( Message% m ) override
{
if ( m.Msg == (int) 0x0014 ) {
Graphics ^g = Graphics::FromHdc(m.WParam);
g->FillRectangle(gcnew SolidBrush(_BackColor),
ClientRectangle);
g->ReleaseHdc();
return;
}
WndProc(m);
}
};
}
the code compile with no error but when i run it gives me an
"An unhandled exception of type 'System.StackOverflowException' occurred in primoAlpha.exe"
any help is really apprecieted, i'm a noob in c++
modified on Monday, September 28, 2009 4:12 AM
|
|
|
|