|
"Here i have a variable and there i assign it something and then later somewhere it doesn't work, could you fix it for me?" - would you be able to do it? Give more details (code sniplet would be great, which does NOT mean the whole program...) if you wish for any assistance, please.
> 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'm trying to create this method that erases the background of my ctreectrl by catching the WM_ERASEBKGND in the windproc function
i have this working fine, but when i start erasing the background, i start running into problems
i found out that when i receive the WM_ERASEBKGND message, it doesn't really erase the whole background, just parts of it
like if i collapsed a tree node, only the affected region would be erased, any unaffected areas will be left untouched
my question is, how do i get the rect of this "affected region" so i'd know what area to erase?
what i did before was i took the clientrect and erased everything, but this is bad since the "unaffected region" was also erased and the text on it is not repainted
thanks
|
|
|
|
|
Did you use the DC you got with wM_ERASEBKGND?
> 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. <
|
|
|
|
|
right now i'm using GetDC() on the ctreectrl but i could easily change that to use the one that came from WM_ERASEBKGND
|
|
|
|
|
Then do so (there's a HDC in either wParam or lParam, look it up), that DC probably has a clipping region selected in it which will permit any paintsings onto areas which should not be overpainted.
> 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. <
|
|
|
|
|
cool
works perfect, thanks
one last question though, is there a way to get the rect for that region that updated?
cause i'm drawing bitmaps on the background after erasing and i need to calculate like sizes and positions and stuff for this updated region
thanks
|
|
|
|
|
You could use CDC::GetClipBox[^] or CDC::GetBoundsRect[^] for that.
> 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 have a SDI app with one single view, derived from CView at the execute time. now I want to create a splitter window at run time and make a new view of different class (see CRichEdit). But as I look inside the MSDN:
"In "dynamic" splitters, the views are of the same class, In "static" splitters, the views can be of different classes."
I dislike to have a splitter window initially (that's static). What do you suggest to do?
Thank you masters!
|
|
|
|
|
|
Hello,
I would like to move something on a graph based on Left click mouse. This works fine, but How do I make it keep moving if the left Mmouse is still down, I want it to stop moving only when Left Mouse is up...as if I was dragging it... Do I need a timer to do this, or could this be done in other ways?
Thanks
sft
|
|
|
|
|
You need to move it when the mouse is moving I guess ? If yes, when you click the button, set a flag to true, and when the button is released, reset the flag to false.
Handle every move event and check if the flag is set: if that's the case, then move your object.
If that doesn't answer your question, then please provide more information.
|
|
|
|
|
Not a bad idea. I will give it a shot.
Thanks
sft
|
|
|
|
|
WM_MOUSEMOVE
WM_LBUTTONUP
WM_LBUTTONDOWN
Thank you masters!
|
|
|
|
|
Software2007 wrote: Do I need a timer to do this, or could this be done in other ways?
void CSam1Dlg::OnMouseMove(UINT nFlags, CPoint point)
{
if( MK_LBUTTON == (MK_LBUTTON&nFlags))
{
}
CDialog::OnMouseMove(nFlags, point);
}
|
|
|
|
|
Its what I wanted - works fine - thanks.
sft
modified on Thursday, March 5, 2009 12:50 PM
|
|
|
|
|
the two Different Code create the same result i want to know the
different between the operator '*' and '&'
the code is below:
first:
<br />
#include<iostream><br />
<br />
using namespace std;<br />
<br />
int Add(int &P1,int &P2)<br />
{<br />
P1=5;<br />
P2=10;<br />
return P1+P2;<br />
}<br />
<br />
int main()<br />
{<br />
int P1=2,P2=3;<br />
<br />
cout<<"As Parameter Before The P1 is:"<<P1<<" P2 is:"<<P2<<endl;<br />
<br />
int Sum=Add(P1,P2);<br />
cout<<"P1 Parameter After The P1 is: "<<P1<<" P2 is:"<<P2<<endl;<br />
}<br />
Second:
<br />
#include<iostream><br />
<br />
using namespace std;<br />
<br />
int Add(int *P1,int *P2)<br />
{<br />
*P1=5;<br />
*P2=10;<br />
return *P1+*P2;<br />
}<br />
<br />
int main()<br />
{<br />
<br />
int *P1,*P2;<br />
<br />
int PA=2,PB=3;<br />
<br />
P1=&PA;<br />
<br />
P2=&PB;<br />
<br />
cout<<"As Parameter Before The P1 is:"<<*P1<<" P2 is:"<<*P2<<endl;<br />
<br />
int Sum=Add(P1,P2);<br />
cout<<"P1 Parameter After The P1 is: "<<*P1<<" P2 is:"<<*P2<<endl;<br />
}<br />
end the variable P1 and P2 's value are all change .
could you tell me the difference between them
thank you
|
|
|
|
|
The difference is in how you will access the variable in your function: if you pass the variables by reference (using &), you can access the variables directly. If you pass the pointer to the variables (using *), then in your function you will receive the pointer.
|
|
|
|
|
It is more neat sometimes to use &.
Take this simple example of a multiply function.
Using *
double multiply(double *x, double *y)
{
return *x * *y;
}
double d = multiply(&a, &b);
Using &
double multiply(double &x, double &y)
{
return x * y;
}
double d = multiply(a, b);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
* is backward compatible with C.
Edit: I was off by one character, I meant to indicate that C doesn't support references.
modified on Thursday, March 5, 2009 9:56 AM
|
|
|
|
|
You can use pointers in C too (thus using the '*' is valid in C).
|
|
|
|
|
Ah, I'm not awake yet, coffee just finished dripping.
I must have meant it the other way around. I only dabbled in C++ a little, and not recently.
|
|
|
|
|
I can't believe there're people who know C and not C++ still!
|
|
|
|
|
C++ is all hype; it's not necessary for most real work.
|
|
|
|
|
Is all the position the '*' use can replace by '&'?
|
|
|
|
|
in a declaration ie int *X means a a pointer to x named *;
You cannot define a reference with initializing it
so
int &X //doesn't work however
---
int Y;
int &x = Y; does
Y and X now refer to the same place in memory changing the value of one will change the value of the other. When you use a & in a function prototype we are saying I want my parameter to access memory at the location of the variable the caller specified; When you declare a pointer in the prototype you are going to explicitly pass in a pointer that pointer can however be reassigned but once reassinged the caller will no longer be able to read changes to what was passed in
I wrote a little example.
<br />
<br />
#include "stdafx.h"<br />
<br />
<br />
void NoSideEffect(int *T)<br />
{<br />
<br />
int G = 5;<br />
T = &G;<br />
<br />
<br />
}<br />
<br />
void SideEffect(int &T)<br />
{<br />
int G = 5;<br />
T = G;<br />
}<br />
<br />
void PointerSideEffect(int *T)<br />
{<br />
int G = 10;<br />
*T = G;<br />
}<br />
<br />
<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
char buffer[2];<br />
int X = 2;<br />
NoSideEffect(&X);<br />
printf("X is Now %d \n",X);<br />
SideEffect(X);<br />
printf("X is Now %d \n",X);<br />
PointerSideEffect(&X);<br />
printf("X is Now %d \n",X);<br />
gets(buffer);<br />
}<br />
<br />
this will print out
X is Now 2
X is Now 5
X is Now 10
a programmer traped in a thugs body
|
|
|
|