I am trying to find the element(by tag) closest tot he cursor in QNX
Windows. I am using the following code, which seems to work logically, but I
am unable to get a element to show up in the buffer. num_elemens is always
0.
What am I missing?
GraphicsOpen() done elsewhere
char* GetTag(){
signed short i;
int row,col;
signed short wndID[100];
QW_RECT_AREA region;
QW_RECT_AREA view;
QW_RECT_BOX box;
char buf[65536];
int num_elem;
signed int pic;
void *p;
bool found=FALSE;
CursorPos(&row,&col);
memset(wndID,0,sizeof(wndID));
ScreenResourceInfo(wndID,sizeof(wndID),“W”);
for(i=0; wndID_!=0; i++){//for all windows
WindowCurrent(wndID);
PaneInfo(®ion,&view,&pic);
PictureCurrent(pic);
memset(buf,0,sizeof(buf));
num_elem = CopyElements(QW_ALL, buf, sizeof(buf),NULL);
Tell(“Event”,“Elements Found %d”,num_elem);
p=ElementFirst(buf);
while(p!=NULL){
ElementBox(&box);
if(‘T’==ElementType()){//this because text box is higher than a
button
if((row>= (region.row+box.row-box.height))&&
(row<= (region.row+box.row))&&
(col>= (region.col+box.col))&&
(col<= (region.col+box.col+box.width))){
found = TRUE;
break;
}
} else {//button code
if(row>= (region.row+box.row) &&
(row<= (region.row+box.row+box.height))&&
(col>= (region.col+box.col))&&
(col<= (region.col+box.col+box.width))){
found = TRUE;
break;
}
}
if(found) break;
p = ElementNext();
}//end of for loop
}
if(found){
return ElementTag();
} else {
return NULL;
}
}_
Lorenz Prem <Lorenz.Prem@guidant.com> wrote:
I am trying to find the element(by tag) closest tot he cursor in QNX
Windows. I am using the following code, which seems to work logically, but I
am unable to get a element to show up in the buffer. num_elemens is always
0.
What am I missing?
QNX Windows is, internally, a 16-bit server – that may make your choice
of size for the buffer (65536) an… unfortunate… value. Try 65535
for your buffer size. (Or, possibly, try an even smaller buffer. 32767
might be a good choice, just in case it becomes signed anywhere along the
way.) You may have to use CopyId() to work through the entire picture,
if the entire thing won’t fit into one buffer.
This might not be the problem, but it is the first thing that looked
“wrong” to me.
Note: your code doesn’t seem to find “closest”, but actually anything
that actually overlaps – have you thought about using the Hit() function?
-David
GraphicsOpen() done elsewhere
char* GetTag(){
signed short i;
int row,col;
signed short wndID[100];
QW_RECT_AREA region;
QW_RECT_AREA view;
QW_RECT_BOX box;
char buf[65536];
int num_elem;
signed int pic;
void *p;
bool found=FALSE;
CursorPos(&row,&col);
memset(wndID,0,sizeof(wndID));
ScreenResourceInfo(wndID,sizeof(wndID),“W”);
for(i=0; wndID> !=0; i++){//for all windows
WindowCurrent(wndID> );
PaneInfo(®ion,&view,&pic);
PictureCurrent(pic);
memset(buf,0,sizeof(buf));
num_elem = CopyElements(QW_ALL, buf, sizeof(buf),NULL);
Tell(“Event”,“Elements Found %d”,num_elem);
p=ElementFirst(buf);
while(p!=NULL){
ElementBox(&box);
if(‘T’==ElementType()){//this because text box is higher than a
button
if((row>= (region.row+box.row-box.height))&&
(row<= (region.row+box.row))&&
(col>= (region.col+box.col))&&
(col<= (region.col+box.col+box.width))){
found = TRUE;
break;
}
} else {//button code
if(row>= (region.row+box.row) &&
(row<= (region.row+box.row+box.height))&&
(col>= (region.col+box.col))&&
(col<= (region.col+box.col+box.width))){
found = TRUE;
break;
}
}
if(found) break;
p = ElementNext();
}//end of for loop
}
if(found){
return ElementTag();
} else {
return NULL;
}
}
–
QNX Training Services
dagibbs@qnx.com
Lorenz Prem <Lorenz.Prem@guidant.com> wrote:
I am trying to find the element(by tag) closest tot he cursor in QNX
Windows. I am using the following code, which seems to work logically, but I
am unable to get a element to show up in the buffer. num_elemens is always
0.
It would be better to use QW_TOUCH event as browsing through all windows,
but anyway it seem to me (I am not sure) that QNX windows
allow to maniputate with a window only to process which has created it,
to allow other processes to manipulate with it you have to
open the window with option ‘q’ (But I am not sure, I haven’t dealth
with QNX Windows for a long time.)
What am I missing?
GraphicsOpen() done elsewhere
char* GetTag(){
signed short i;
int row,col;
signed short wndID[100];
QW_RECT_AREA region;
QW_RECT_AREA view;
QW_RECT_BOX box;
char buf[65536];
int num_elem;
signed int pic;
void *p;
bool found=FALSE;
CursorPos(&row,&col);
memset(wndID,0,sizeof(wndID));
ScreenResourceInfo(wndID,sizeof(wndID),“W”);
for(i=0; wndID> !=0; i++){//for all windows
WindowCurrent(wndID> );
PaneInfo(®ion,&view,&pic);
PictureCurrent(pic);
memset(buf,0,sizeof(buf));
num_elem = CopyElements(QW_ALL, buf, sizeof(buf),NULL);
Tell(“Event”,“Elements Found %d”,num_elem);
p=ElementFirst(buf);
while(p!=NULL){
ElementBox(&box);
if(‘T’==ElementType()){//this because text box is higher than a
button
if((row>= (region.row+box.row-box.height))&&
(row<= (region.row+box.row))&&
(col>= (region.col+box.col))&&
(col<= (region.col+box.col+box.width))){
found = TRUE;
break;
}
} else {//button code
if(row>= (region.row+box.row) &&
(row<= (region.row+box.row+box.height))&&
(col>= (region.col+box.col))&&
(col<= (region.col+box.col+box.width))){
found = TRUE;
break;
}
}
if(found) break;
p = ElementNext();
}//end of for loop
}
if(found){
return ElementTag();
} else {
return NULL;
}
}