|
-
Dec 15th, 2003, 07:56 AM
#1
Thread Starter
Fanatic Member
Commands in edit box
Hi,
I'm making a program with an edit box. It's kind of like notepad, but it will not have any menus or buttons, you will control the program by entering commands in the edit box. If I want to save the text that's in the edit box I would go /s C:\file.txt <enter>
To do this I have subclassed the edit box. As soon as the user types a slash (/) I set bSlash = true and when I press enter i set bSlash = false again. While bSlash is equal true I copy every character that I type to a string, but somewhere along the path things messes up...
Code:
LRESULT CALLBACK EditProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_KEYUP:
{
int iLen;
iLen = GetWindowTextLength(hwndEdit);
char *szText;
szText = new char[iLen + 1];
GetWindowText(hwndEdit, szText, iLen + 1);
if(wParam == VK_RETURN)
{
bShift = false;
ParseCommand();
}
if(bShift == true && wParam >= 32)
{
sCommand += szText[iLen - 1];
}
if(szText[iLen - 1] == '/')
{
bShift = true;
}
delete [] szText;
break;
}
default:
{
break;
}
}
return CallWindowProc(wndProcOld, hWnd, uMsg, wParam, lParam);
}
void ParseCommand()
{
MessageBox(NULL, sCommand.c_str(), "sCommand", MB_OK);
sCommand = "";
}
Input in the edit box: abc /s "This is a test"
Output in the MessageBox: s "Tiis s eett"
The number of characters are right but not the caracters them selves... What is wrong?
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|