Overclockers Australia Forums

OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Software Topics > Programming & Software Development

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Reply
 
Thread Tools
Old 15th January 2008, 11:21 PM   #1
bojo Thread Starter
Member
 
Join Date: Mar 2007
Posts: 1,880
Default Getting info from a window/textbox

Code:
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_SENDBOX));
LPSTR buffer=(LPSTR)GlobalAlloc(GPTR, len + 1);

SendMessage(GetDlgItem(hwnd, IDC_SENDBOX),WM_GETTEXT,(WPARAM)len+1,(LPARAM)buffer);

MessageBoxA(hwnd,buffer,"you typed",0);

comPort->txString(buffer);
comPort->txChar(0);
return true;
}
gives me a empty buffer.

The problem seems to lie in The SendMessage line, but i don't understand where i went wrong.
bojo is offline   Reply With Quote

Join OCAU to remove this ad!
Old 24th January 2008, 11:01 PM   #2
bojo Thread Starter
Member
 
Join Date: Mar 2007
Posts: 1,880
Default

not many winapi programmer's out there huh? lol.

Dayum i really wish i could figure this out, it would be so helpful in debugging.

(figured out my debugging stuff for my uP. though i still want to finish this project).

It's going to be a lightweight serial-only, communicator. I've already got port selection and TX'ing down, i just need to get input from the user (into that buffer), and recieve it.

Then i'll add baud/parity etc etc. Anyone on OCAU is free to use the program. (i'm making it cause hyperterminal is buggy, and now hard-locks my pc).

Last edited by bojo; 24th January 2008 at 11:06 PM.
bojo is offline   Reply With Quote
Old 24th January 2008, 11:39 PM   #3
bojo Thread Starter
Member
 
Join Date: Mar 2007
Posts: 1,880
Default

well by using malloc instead of globalalloc, it kinda works.

Though i have jibberish like hell.
bojo is offline   Reply With Quote
Old 24th January 2008, 11:40 PM   #4
CRFD213
Member
 
Join Date: Nov 2005
Location: Bankstown, NSW
Posts: 29
Default

Quote:
Originally Posted by bojo View Post
Code:
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_SENDBOX));
LPSTR buffer=(LPSTR)GlobalAlloc(GPTR, len + 1);

SendMessage(GetDlgItem(hwnd, IDC_SENDBOX),WM_GETTEXT,(WPARAM)len+1,(LPARAM)buffer);

MessageBoxA(hwnd,buffer,"you typed",0);

comPort->txString(buffer);
comPort->txChar(0);
return true;
}
gives me a empty buffer.

The problem seems to lie in The SendMessage line, but i don't understand where i went wrong.
are you using MFC?

try getting the result of your SendMessage()
e.g. LRESULT lRes = SendMessage(blah);

what does that return?

can't pin point any obvious problems based on what you've posted. what's "hwnd"? is that a valid window handle? is that the handle to the dialog that contains your text box??

its a bit hard to debug looking at a few lines of code...so many things could go wrong..

i'm happy to have a look at it if you want to post/PM the source code/project.

anyway, good luck.
CRFD213 is offline   Reply With Quote
Old 24th January 2008, 11:50 PM   #5
bojo Thread Starter
Member
 
Join Date: Mar 2007
Posts: 1,880
Default

Killer i perservered. figured out the example i chose to base it off was for a dialog.

Slightly modified the commands and now we are golden.

Rx'ing to come and then i'll release an alpha, for the one person who-ever reads this
bojo is offline   Reply With Quote
Old 24th January 2008, 11:50 PM   #6
scruff
RIP
 
scruff's Avatar
 
Join Date: Jun 2003
Location: Melbourne
Posts: 3,452
Default

Are you trying to read a password field?

I'm not sure that you can read password fields with a program like this.
scruff is offline   Reply With Quote
Old 25th January 2008, 1:58 AM   #7
bojo Thread Starter
Member
 
Join Date: Mar 2007
Posts: 1,880
Default

I was just trying to read the data from a control/window. (editbox).

Figured it out, for some reason i was treating it as a dialog when it wasn't. Nutted it all out but.

The only problem i'm having is when i "capture" VK_RETURN, i get a terminal bell (beep).

Freaking annoying, i know it's being cause by the box being 1 line/ 2 end of line if multiline. But i have no idea how to remove it. It seems that the VK_RETURN is always passed through, even if i "capture" it and do nothing about it.

Even if i change the behaviour to a button for "SEND", i'm still going to have this problem, VK_RETURN at end of textbox = terminal beep.

Anyone have any creative ideas?. I thought it might exist in the callback function, but changing it's return values hasn't had much effect. Things i've tried are, return 0, return true, return false, return default behaviour. All things beep damnit!!!
bojo is offline   Reply With Quote
Reply

Bookmarks

Sign up for a free OCAU account and this ad will go away!

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time now is 1:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. -
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!