|
It seems that if the VK_CONTROL key is down, I cant receive any other WM_KEYDOWN messages except for the first key pressed.. I have a function to see if the VK_CONTROL is pressed down but it still seems to block all other msg's.. I have tried to catch the combos in WM_KEYDOWN and in WindowProc. Do I need to catch the WM_KEYDOWN for the control key and catch a WM_KEYUP message for the 'A'? If I use the GetAsyncKeyState where should I call it?
|
|
|
|
|
I'm sure I've done it in WM_CHAR with something like this
switch(nChar) // I can't recall where I'd get this from
{
case 'A':
case 'a':
GetAsyncKeyState(VK_CONTROL);
if (GetAsyncKeyState(VK_CONTROL))
{
// Control is down
}
else
{
}
}
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hi,
I am creating a program that will make a graphic of a math function, but I have a problem with the LineTo function, I have to remake it, but not as:
LineTo(int x, int y) { dc.LineTo(x,y); }
but as a cycle of SetPixel.
The reason of this is because for finding the roots of the math function I need to know where the line I draw passes through the X Axis, or where y = 0.
My question is how do I write a variant of LineTo where I use SetPixel, instead of LineTo???
Thank you very much.
you can contact me on e-mail blackkattle@abv.bg
|
|
|
|
|
If I understood it right, you want to determine, prior to drawing it, at which x does a segment intersect the x axis (if it does): this can be done with a little of trivial algebra, no need to draw the line pixel by pixel. So, this function determines whether a given segment crosses the x axis, and, if so, changes its end point so that the segment ends precisely on the intersection:
bool adjust_to_x_axis(int x0,int y0,&int x1,&int y1)
{
if(x0==x1){
if(y0<=0){
if(y1>=0){
y1=0;
return true;
}
else return false;
}
else if(y1<=0){
if(y0>=0){
y1=0;
return true;
}
else return false;
}
}
int x_int=x0-y0*(x1-x0)/(y1-y0);
if(x0<x1){
if(x0<=x_int&&x_int<=x1){
x1=x_int;
y1=0;
return true;
}
else return false;
}
else if(x0>=x_int&&x_int>=x1){
x1=x_int;
y1=0;
return true;
}
else return false;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
if (y1==y0) then the line never cross the x-axis, otherwise x = x1 - y1*(x1-x0)/(y1-y0).
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
The solution is x=x0-y0*(x1-x0)/(y1-y0), not exactly what you wrote. Also, the code considers whether the given segment (not the whole line) intersects the x axis.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Actually x0-y0*(x1-x0)/(y1-y0) = x1-y1*(x1-x0)/(y1-y0) = (x0y1-x1y0)/(y1-y0).
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
BlackKattle wrote:
how do I write a variant of LineTo where I use SetPixel, instead of LineTo???
You don't have to. Just plug in your drawing (SetPixel) backend callback to LineDDA .
|
|
|
|
|
hello,
i need a matrix!!! but i have no const int values. my values are all int (because the values changed inside the programm). is there a possibility to make a two dimensional array (int array[n][m]) without const int values????
MFC
|
|
|
|
|
You must have one of the dimentions fixed, i bealive
use the operator "new"
Casa.Sapo.pt
|
|
|
|
|
You can possibly try a vector inside a vector, or a list of vectors, but your going to need VC++ 7, as I think templated templates are new to VC++.
Then again you could try Perl. It lets you do it.
|
|
|
|
|
No, you can do a vector of vectors in VC6.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Didn't know that. For some reason, I though template templates where new to VC7.
Thanks.;)
Giles
|
|
|
|
|
in VC++ 6 I've used vector of vectors (and even more!), like this:
#typedef std::vector<string> StringVector;
#typedef std::vector<stringvector> StringMatrix;
and it works
nobody is perfect
|
|
|
|
|
What makes you think they need to be constant values ? Or do you mean for the dimensions ?
Do this:
int ** ppInt = new int[nRows];
for (int i = 0; i < nRows; ++i)
ppInt[i] = new int[nCols];
Now you can reference each element as ppInt[x][y] ( unless I got rows and columns the wrong way around, which I am want to do ).
As has been said, a vector of vectors is a better solution in terms of memory management, but if it were me, I'd probaby write a matrix class which wraps a int ** and does common matrix manipulations for me. Or search the web for one.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thanks for reply.
yes, you are right, i mean the dimensions as constant values.
my compiler has problems with int ** ppInt = new int[nRows]; .
error: int* cannot convert in int**
and with ppInt[i] = new int[nCols]; .
error: int* cannot convert in int
what´s wrong?
nRows and nCols are integers in my program.
MFC
|
|
|
|
|
MFC is the Best wrote:
ppInt[i] = new int[nCols];.
try
ppInt[i] = new int*[ncols];
-c
No matter how fast light travels it finds the darkness has always got there first, and is waiting for it.
-- Terry Pratchett,
|
|
|
|
|
I need to display XML ( heirarchical view ) like in IE in a Edit box .
I am using the XML DOM mechanism to extract XML from the xml file .
the XMLnode->xml returns the XML string to me .
When i display it now I get text which doesnt look pretty .
as for eg I should get
<parent>
<child1>hello
<child2>hello2
all i get now is
<parent><child1>hello<child2>hello2
Please if anyone knows a better Control or Method of displaying this lemme know !
|
|
|
|
|
The .NET framework contains methods to return XML nicely formatted, if that's not available to you, I don't know if there is anything else, or if you'll need to parse it yourself. It's not hard though, just keep track of how many tabs in you are, and put returns after a >.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
In the code below IDC_EDIT1 is a dynamically created control. Does the MSG structure identify what control had focus when the message was sent? The outer IF statement works just fine, how do I write the inner IF statement?
Thanks
BOOL CTestDlgDlg::PreTranslateMessage(MSG* pMsg)
{
static int iCount=0;
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_CHAR)
{
//if(dynamically created edit control IDC_EDIT1 has focus)
//{
TRACE("got %d\n", iCount++);
// }
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
an MSG struct has an hwnd member.
if (pMsg->hwnd = GetDlgItem(ID_...)) ...
-c
No matter how fast light travels it finds the darkness has always got there first, and is waiting for it.
-- Terry Pratchett,
|
|
|
|
|
Do I feel silly or what...
thank you Chris
|
|
|
|
|
Hi,
After trying my VC+ 6.0 with different things wihout any
success, can any one help me just to set my ListBox (as a ListCtrl)
BackGround becomes Black & the Text color becomes White?
Many thanks,
|
|
|
|
|
Does not CListCtrl::SetBkColor work?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|