|
I'm not sure what you mean but...getting the colorref from the RGB components isn't done by multiplying the components. COLORREF is a 4 byte value (a long is a 8 byte value if i recall correctly), the first byte of this value (the least significant i believe) represents the red component, the second one represents green and the trird one represents blue. (It might be the other way around, am not sure but the idea is basicly the same) So:
[1 Byre Red][1 Byte Green][1 Byte Blue][1 Byte unused]
If you have the 3 components, 1 byte each you can make a colorref of them like this:
Red | (Green << 8) | (Blue << 16)
You can read about this here[^] too, it probably explains it better than i do.
> 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. <
|
|
|
|
|
Nice link to explain on the RGB and GDI. Looks like we are on the same page as to what we thinking multiplying the integer from the byte for all three will give us the long decimal value. However, can you or someone tell me if there is anything wrong with the code i have posted in my previous message.
If there isn't I could try and get the Red, Blue and Green from the Visual Basic application. I am trying to migrate an application into c++ from Visual Basic.
after reading a couple of books and some articles. I thought it would be nice to migrate and learn from my own application.
Thanks a Million for all the help. I really appreciate it.
|
|
|
|
|
I'd like to help but i still don't understand what you mean by "long value should be"... Just note that DCs you get for windows should be released using ReleaseDC[^] and memory DCs you create with CreateCompatibleDc should be destroyed with DeleteDC[^].
Note: i do not know Visual Basic, i used it with some small projects but that was ages ago...
> 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. <
|
|
|
|
|
Thanks again. Short of missing the ReleaseDC() and DeleteDC(). There is nothing wrong with that small portion of the function?
Thanks Again.
|
|
|
|
|
Well, first of all, am not sure you can actually query and fiddle with a DC of a window belonging to a different thread than yours, but you probably should not anyways... (WindowFromPoint may return a window handle which does not belong to your process)
Now, you create a memory DC there and blit "onto it", but...by default, a memory DC has a 1 pixel by 1 pixel sized, 1 bits per pixel colordepth bitmap selected into it, so when you call Bitblt, you will blit onto that bitmap which is most likely not what you want. You can use GetPixel on the window DC too, you don't need to BitBlt it to some memory DC. If you DO want to create a copy, you have to use -for example- CreateCompatiblebitmap[^], create a bitmap you want to blit onto with it, select this into your memory DC using SelectObject[^], storing the original bitmap handle SelectObject returns, perform the blitting and whatever you wish to do, then select the original bitmap handle into the memory DC before you destroy it, and then also destroy the buffer if you no longer need it using DeleteObject[^].
> 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. I think you have hit me with something. I can see where my problem is. Yes I want the window belonging to a different thread. The WindowFromPoint is the handle i am looking for.
However some of the things you have mentioned, I beleive is what Visual Basic is all about handling the internal process.
I guess I will have to read more before i carry on and use up space here.
Any sugetions on good reading articles for GDI's or any of the functions I an using? Please advice.
Thanks A million.
|
|
|
|
|
MSDN[^]
> 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. <
|
|
|
|
|
How about this:
COLORREF Color6;
Color6 = GetPixel(MemDC,Point.x,Point.y);
CString str;
str.Format(_T("Color6: %x"),Color6);
::AfxMessageBox(str);
Greetings,
Jonnie
|
|
|
|
|
I am unable to get the Window Client Area Coordinates in Mouse LbuttonDown.
Here I am Converting the Coordinates to String Format.
Problem is arised at Runtime in String varible.
Can u pls Solve the Problem
|
|
|
|
|
"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
|
|
|
|