|
No. The CRectTracker does all that for you. Here's all I added to a dialog's LBUTTONDOWN handler:
void CRectTrackerDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect re(point, point);
CRectTracker rt(re, CRectTracker::solidLine | CRectTracker::resizeOutside);
rt.TrackRubberBand(this, point, TRUE);
CDialog::OnLButtonDown(nFlags, point);
}
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
It's not works yet.
This is my code:
PreTranslate(MSG *pMsg)
{
switch(pMsg->message)
Case WM_LBUTTONDOWN:
CPoint pt;
pt.x = GET_X_LPARAM(pMsg->lParam);
pt.y = GET_Y_LPARAM(pMsg->lParam);
CRect re;
CRectTracker rt(re, CRectTracker::solidLine | CRectTracker::resizeOutside);
if(rt.TrackRubberBand(&m_viewc, pt, TURE))
{
do something;
}
}
xyz
|
|
|
|
|
The code I sent you definitely works if you put it in an LBUTTONDOWN handler. However, even if you're using PreTranslateMsg (why?) the following will work as well:
switch (pMsg->message)
{
case WM_LBUTTONDOWN:
{
CPoint pt;
pt.x = GET_X_LPARAM(pMsg->lParam);
pt.y = GET_Y_LPARAM(pMsg->lParam);
CRect re(pt, pt);
CRectTracker rt(re, CRectTracker::solidLine | CRectTracker::resizeOutside);
rt.TrackRubberBand(this, pt, TRUE);
}
break;
default: break;
}
return CDialog::PreTranslateMessage(pMsg);
}
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Thanks a lot!
Please send me the Demo project.
xyz
|
|
|
|
|
It's on the way.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
By the way, you'll notice some weirdness in the demo when you try and click the OK or Cancel buttons. That's because the tracker code is in the PreTranslateMessage function and if you want to use that function you'll need to add code to verify that the user is clicking on the dialog's client area - and not child control. To do this, simply bracket the tracker code with the following check:
if (pMsg->hwnd == GetSafeHwnd())
{
}
If you add an handler for the LBUTTONDOWN message, you won't need to do this as the handler will only be called for left mouse button clicks on the client area.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
I have no idea why you're not getting this file via email. I put it up on my server.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
If you're still having problems. Let me know and I'll send you the demo I just did.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Hi,
Is there any api for win 32 appliction to get the default printer name(without using any EnumPrinter call)?
Thanks
Neha
|
|
|
|
|
It depends on the OS you're using. If you're using 95 or 98, you must call EnumPrinters. Windows NT/2000/XP have a function called GetDefaultPrinter that must by dynamically accessed from the winspool dll. Here's a link to the kb article that explains all this and has the code that does it.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Hi,
call back function is said to be called by Operation system only. I want to make a call back funtion myself and control the time and place it is called. Can I make it?
Would you please append an example ?
Thank you.
Best regard.
One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
Are you saying you want to implement a callback between one piece of your code and another?
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Once is enough, asking over and over only annoys people, especially when the first ask is only two posts down.
You want to look at function pointers, that is how callbacks work and it's just as easy to impliment your own if you want to.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Hi,
I have to take a shot from a small Web Camera.
What should i use.
- Video for Windows
- Can i use DirectX
- or something else
Regards
Sameer
|
|
|
|
|
DirectShow, in DirectX
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Hi,
call back function is said to be called by Operation system only. I want to make a call back funtion and control the time and place it is called. Can I make it?
Would you please append an example ?
Thank you.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
Ok... Ive bean experimenting with classes "saying that i do not know anything (at all) about classes, its bean a confusing process"
When i try to learn somthing I usually pinpoint the thing that i need to learn and start experimenting with it... "i do look through the MSDN a bunch and the help tutorial that VC++ 6.0 came with but if your unsuccesfull try the forums ."
My question is... to be responded by tutorial link or whatever...
How do you use a class... why do you use them... What does Publuc do... What does private do... Do classes require any header files?
Right now im doing somthing like:
class monster;
{
//somthing here
}
my idealistic ideal is that i could use classes "which i think i read that they are, basically a single block of info that you make, that you can duplicate and use kindof however you want" To make all the monsters in my text game "just to learn how to use the class function" and then just recal certain things from the class...
But as you know,... thats an ideal and i still dont know exactly why you use classes "i think i might be totally off" but thats the path of learning.
Thanks for the help
~SilverShalkin
ps... this in win32 app con. "last forum asked me to specify what i was working in... there you go"
|
|
|
|
|
SilverShalkin wrote:
Ok... Ive bean experimenting with classes "saying that i do not know anything (at all) about classes, its bean a confusing process"
I'm eating jelly beans right now - Harry Potter ones.
SilverShalkin wrote:
How do you use a class...
A class is an encapsulation of an idea. For example, a CString, a std::string, a std::vector, a CWnd are all classes, and they all encapsulate a concept. I'll pick on CString for the sake of the rest of this reply. CString is a collection of data members and functions that together give me a string as an object, and allow me to pass it around and operate on/with it.
SilverShalkin wrote:
why do you use them...
One major thing C++ has over C is that C++ does not turn a project into a million functions all visible to one another. A class is used so that publically an interface is provided to do what the class is designed for, and the messy details are hidden and dealt with by the class.
SilverShalkin wrote:
What does Publuc do...
It means when I go CString s; the function or variable in question can be called, for example, s.Format("%d", 6);
SilverShalkin wrote:
What does private do...
It means I can't call/access the method/variable. Typically this means a function does something internal, and variables are generally private so they can be exposed through methods that filter what a person is trying to set a value to, if they are allowed to at all.
SilverShalkin wrote:
Do classes require any header files?
A class consists of a header file, and optionally a cpp file ( because it can all go in the header ). If you're using precompiled headers ( and with VC you usually are ) then std.afx needs to be the first file included in the .cpp file, followed by the .h file. So if I have a class called MyClass, the first two lines in the .cpp file are likely to be
#include "stdafx.h"
#include "myclass.h"
SilverShalkin wrote:
my idealistic ideal is that i could use classes "which i think i read that they are, basically a single block of info that you make, that you can duplicate and use kindof however you want"
If it's a representation of a block of data, you should use a struct. The only difference is that a struct has public members by default, a class has private, but a struct says to me a block of data, a class says implimentation of an idea.
SilverShalkin wrote:
To make all the monsters in my text game "just to learn how to use the class function" and then just recal certain things from the class...
One possible design is that am onster has methods that move it, and make it do certain things. Then a monster is an object that knows how to behave.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Can I just say again that it scares the hell out of me that someone who doesn't know ( in this case ) what a class is, is talking about writing a game engine ? You're setting yourself up to fail, or in the least write something truly awful, when you set out to write something well and truly beyond your skills. You need to forget about windows, forget about games and sit down and learn these total basics which you lack. Write console programs until you understand C++ to the point of being able to write classes, a class structure that uses inheritance, and the standard iostreams and STL to at least a basic degree before you even think about windows or game programming.
That is not to say you suck, it's more that like a lot of people, you're so eager to get the end result that you're not putting the time you need into the basics. I keep hoping for your sake that this particular light will come on, but the number of failed game engines in existance proves to me that this is not guarenteed to happen. Whatever happens, I'm always happy to answer your questions, but this is the best piece of advice you've got to date ( although I don't think it's the first time I have given it ).
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
That is not to say you suck
ROTFLMAO!!!
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Well, I'm trying hard to get him to take the point - he is out of his league and should take the time to learn this stuff before thinking he can design and write a game engine.
But it *is* kinda funny.....
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Oh... If you've got a couple of spare minutes, I'd love it if you could explain to me what a class is.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Jon Hulatt wrote:
Oh... If you've got a couple of spare minutes, I'd love it if you could explain to me what a class is.
Apparently something you should have attended more regularly if you went to Uni, otherwise something you should take up in the evening to help you understand how to program....
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Wow. That helps. Now, tell me what is a pointer? how can i use them in my program?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Jon Hulatt wrote:
Wow. That helps. Now, tell me what is a pointer? how can i use them in my program?
Here's a pointer - move to VB.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|