|
-
February 24th, 2010, 02:42 AM
#1
Peek Message help
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
-
February 24th, 2010, 08:34 AM
#2
Re: Peek Message help
Why PeekMessage? Can't you just check for EN_CHANGE or EN_UPDATE notification to the parent?
-
February 24th, 2010, 11:52 AM
#3
Re: Peek Message help
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.
-
February 24th, 2010, 01:56 PM
#4
Re: Peek Message help
OK, I assume your not using MFC (because of the comment in the OP), so what are you using? The above makes little sense.
-
February 24th, 2010, 06:46 PM
#5
Re: Peek Message help
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.
-
February 24th, 2010, 10:11 PM
#6
Re: Peek Message help
I still don't get it. Do you have a message loop? Just handle WM_NOTIFY and check for EN_CHANGE.
-
February 24th, 2010, 10:47 PM
#7
Re: Peek Message help
 Originally Posted by hoxsiew
I still don't get it. Do you have a message loop? Just handle WM_NOTIFY and check for EN_CHANGE.
well I tried that and it didn't work
this is what I have:
Code:
/*--*/LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){// Gets the Application Procedure
/*|-*/
/*|-*//*--*/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;
/*|-*//*|-*/ /*|-*/ //break;
/*|-*//*|-*/ /*--*/}
/*|-*//*|-*/
/*|-*//*|-*/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;
/*|-*/}
Last edited by Senith; February 24th, 2010 at 10:51 PM.
-
February 25th, 2010, 09:25 AM
#8
Re: Peek Message help
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:
Code:
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;
}
-
February 25th, 2010, 12:16 PM
#9
Re: Peek Message help
ok that works for the edit box control that you have included with your code.
but it won't work for the richedit control though
Code:
rtfctl = CreateWindow("RICHEDIT","text",WS_BORDER|WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL|WS_GROUP,40,30,300,300,MAINSS,(HMENU)ID_EDIT1,hInstance,0);
I think richedit hates me or something lol.
Thanks for posting that code btw. It will help me out with other controls too
-
February 25th, 2010, 01:42 PM
#10
Re: Peek Message help
Rich edit has an event mask that you have to enable for events.
Add these lines:
Code:
rtfctl = CreateWindow("RICHEDIT","text",WS_BORDER|WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL|WS_GROUP,40,30,300,300,MAINSS,(HMENU)ID_EDIT1,hInstance,0);
LRESULT mask=SendMessage(rtfctl,EM_GETEVENTMASK,0,0);
mask|=ENM_CHANGE;
SendMessage(rtfctl,EM_SETEVENTMASK,0,(LPARAM)mask);
There's a bunch of other ENM_xxx mask values too. See:
http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
-
February 25th, 2010, 03:58 PM
#11
Re: Peek Message help
Thank you that works! 
Thanks I appreciate it.
also what does the "crosses initialization of `int whileline' " mean in DEV?
-
February 25th, 2010, 04:02 PM
#12
Re: Peek Message help
I don't know. WHat do you mean by "DEV"?
-
February 25th, 2010, 04:20 PM
#13
Re: Peek Message help
Dev C++ by Bloodshed I believe.
I keep getting a lot of these in my projects once in a while.
-
February 25th, 2010, 05:02 PM
#14
Re: Peek Message help
I've never used DevC++ nor have I seen a warning like that.
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
|