Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   WIN32 API - Appending text in an EDIT box (http://www.programmingforums.org/showthread.php?t=13233)

Brent May 29th, 2007 6:33 PM

WIN32 API - Appending text in an EDIT box
 
I was wondering if there is a WINAPI function that allows you to append text to text that is already in an EDIT box, or would I have to create my own function to do this? thanks for any help.

Im using Dev C++ on Win XP.


brent

The Dark May 29th, 2007 6:44 PM

You can use the EM_REPLACESEL message after setting the caret to the end of the edit control using EM_SETSEL (I think start of -1 and end of 0 does it, but I can't remember for sure).

Brent May 31st, 2007 9:50 PM

Alright, thanks i'll try that and see how it works out.

Brent Jun 1st, 2007 8:21 PM

The Dark, your idea worked great, but another problem popped up. Whenever I click the Edit box, the program exits. What could be causing this.

The Dark Jun 1st, 2007 8:31 PM

Without looking at your code, I have no idea, sorry.

Brent Jun 1st, 2007 10:12 PM

Yea, my bad, I dont have the code with me at the moment but I will post it.

Eoin Jun 2nd, 2007 6:55 AM

Completely random stab in the dark... Might you be missing a break statement such that the code which handles a left click runs on into a block for handling close messages or something similar?

Brent Jun 2nd, 2007 10:37 PM

Hmmm, thats interesting, i'll take a look at my code.

Brent Jun 3rd, 2007 12:46 PM

1 Attachment(s)
Ok, I have checked the code over and I didnt see any missing breaks, and I have attached the source for anyone who wants to take a look.

The Dark Jun 3rd, 2007 9:11 PM

I can't run through your code without the resource.h file (and the other resource files), but here are a few suspicious items:
1.
:

    SendDlgItemMessage(hwnd,IDC_ALL_MSG_BOX,EM_SETSEL,-1,(LPARAM)-1);
You are sending this dialog message in the "default" case when you receive a dialog message. Possibly this would end up causing an infinite recursion, as you might receive a dialog message in response to this dialog item message.

2.
:

          return NOT;
The documentation I read says either return TRUE or FALSE to a dialog message, I'm not sure why you are returning 2 (which would probably be the same as returning TRUE)

3.
:

          for(a=0;a<=sizeof(new_name);a++)
sizeof(new_name) returns exactly 4 in a 32 bit environment. You need to use strlen to find the length of a string.


Other than that, I can only suggest running the program through a debugger, setting a breakpoint on the EM_REPLACESEL lines and stepping through from there.


All times are GMT -5. The time now is 2:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC