ok so I have a text box that I need to detect if any characters inside it has been changed.
I keep reading into it and everything I see has to do with PeekMessage.
I tried some eaxmples and is having no luck.
How can I get the messages from another control within my app like a edit box or a listbox
thanks
I know I ask for alot. but there is barely anything out there for API's. I keep finding MFC examples v_v
thanks again
hoxsiew
February 24th, 2010, 07:34 AM
Why PeekMessage? Can't you just check for EN_CHANGE or EN_UPDATE notification to the parent?
Senith
February 24th, 2010, 10:52 AM
How would I be able to do that?
I have a command open with my app to debug it and stuff and my text box when I do something other then giving it focus, it doesn't show up under my main form procedures.
hoxsiew
February 24th, 2010, 12:56 PM
OK, I assume your not using MFC (because of the comment in the OP), so what are you using? The above makes little sense.
Senith
February 24th, 2010, 05:46 PM
Just the basics. Like the getmessage dispatch message,etc.
I have a function called Procedures that gets the messages of the main window and what ever it is such as menu clicks,button clicks, takes care of that. I just need to get the messages for other controls such as a edit box.
I can't find anything on it besides PeekMessage or MFC.
hoxsiew
February 24th, 2010, 09:11 PM
I still don't get it. Do you have a message loop? Just handle WM_NOTIFY and check for EN_CHANGE.
Senith
February 24th, 2010, 09:47 PM
I still don't get it. Do you have a message loop? Just handle WM_NOTIFY and check for EN_CHANGE.
/*|-*//*--*/switch(msg){// Switch Message base on Application Message
/*|-*//*|-*/
case WM_MOUSEMOVE:
//if(lParam==(int)rtfctl){
// }
break;
/*|-*//*|-*/case WM_COMMAND:// Gets which command is in use
/*|-*//*|-*/ /*--*/switch(wParam){// Gets the sub command is in use
/*|-*//*|-*/ /*|-*/case ID_FILE_NEW: // File New command activated
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_OPEN:// File Open command activated
/*|-*//*|-*/ /*|-*/ DestroyWindow(hwnd);// This was here for a test/debug. Remove when this control gets used
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_SAVE: // This was here for a test/debug. Remove when this control gets used
/*|-*//*|-*/ /*|-*/
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_SAVEAS:// Save As command activated
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_PRINT:// File Print command activated
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_PRINTPREVIEW:// File Print Preview command activated
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_IMPORT://File Import command activated
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_RECENT://command activated
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_FILE_EXIT:// Exit command activated
/*|-*//*|-*/ /*|-*/DestroyWindow(hwnd);// Exits the main program
/*|-*//*|-*/ /*|-*/break;
/*|-*//*|-*/ /*|-*/case ID_INSERT_NEWFORM://command activated
/*|-*//*|-*/break;
/*|-*//*|-*/case WM_SIZE:// Resize Message
#include "sizectrls.h"
break;
case WM_NOTIFY:
switch(lParam){
case EN_CHANGE:
MessageBox(0,"test","test",MB_OK);
break;
}
/*|-*//*|-*/break;
/*|-*//*|-*/case WM_CLOSE:// Close message
/*|-*//*|-*/DestroyWindow(hwnd);// Exits the main program
/*|-*//*|-*/break;
/*|-*//*|-*/case WM_DESTROY:// Terminate Message
/*|-*//*|-*/PostQuitMessage(0);// Terminates the main program
/*|-*//*|-*/default:
/*|-*//*|-*/return DefWindowProc(hwnd, msg, wParam, lParam);//Returns the defualt Messages to the main program
/*|-*//*--*/}
/*|-*/return 0;
/*|-*/}
hoxsiew
February 25th, 2010, 08:25 AM
Sorry, it's been a while since I worked with windows at the API level. The correct method is to handle WM_COMMAND and check for your control ID, then handle its notifications there. Something like this:
HWND m_hEdit;
#define ID_EDIT1 1001
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
int i;
switch (message)
{
case WM_CREATE:
m_hEdit=CreateWindow(L"EDIT",L"Test",WS_BORDER|WS_VISIBLE|WS_CHILD|WS_TABSTOP|WS_GROUP,10,10,100,15,hWnd,(HMENU)ID_EDIT1,hInst,0);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case ID_EDIT1:
switch(wmEvent){
case EN_CHANGE:
//handle change here
break;
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Senith
February 25th, 2010, 11:16 AM
ok that works for the edit box control that you have included with your code.