Valhalla Legends Forums Archive | C/C++ Programming | Help Subclassing

AuthorMessageTime
Spilled[DW]
How would I catch when the user presses Enter in my RichTextBox? Would I use a subclass? because this is what im attempting to do but it is not working.

Heres my declare:
[code]
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK MyProc(HWND, UINT, WPARAM, LPARAM);
WNDPROC wndProc = (WNDPROC)SetWindowLong( rtbSend, GWL_WNDPROC, (LPARAM)MyProc);
[/code]

rtbSend is the sendbar hWnd and "MyProc" is the Proc is should Subclass to.

Here is my default WNDPROC and my attempted SubClass:
[code]LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)                  /* handle the messages */
   {
       case WM_CREATE:

            break;
       case TRAY_ID:
            switch(lParam)
            {
                case WM_LBUTTONDBLCLK:
                     ShowWindow(hwnd,SW_SHOW);
                     Shell_NotifyIcon(NIM_DELETE,&info);
                     break;
                case WM_RBUTTONDOWN: //Right Button Clicked
                     break;
            }
            break;
       case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case FILE_CONNECT: //CONNECT EVENT
                {
                       Addchat("Attempting to Connect to Battle.net");
                       threadHwnd = CreateThread(NULL,0,&ThreadProc,(LPVOID)SOCKET_RECIEVE,0,NULL);
                }
                     break;
                case FILE_DISCONNECT: //DISCONNECT EVENT
                        closesocket(wSock);
                     break;
                case FILE_EXIT: //EXIT EVENT
                        Shell_NotifyIcon(NIM_DELETE,&info);
                        PostQuitMessage (0);
                     break;
                case OPTION_CONFIG:
                     WinExec("notepad.exe Config.ini",1);
                     break;
                case OPTION_TRAY:
                     TrayProgram("C++ Bot!", LoadIcon(NULL, IDI_APPLICATION));;
                     break;
            }
            break;
       case WM_DESTROY:
           Shell_NotifyIcon(NIM_DELETE,&info);
           PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
           break;
       default:                      /* for messages that we don't deal with */
           return DefWindowProc (hwnd, message, wParam, lParam);
   }

   return 0;
}
[/code]

How im creating MyProc:
[code]
LRESULT CALLBACK MyProc(HWND hDialog, UINT wMessage, WPARAM wParam, LPARAM lParam)
{
     switch(wMessage)
     {
          case WM_KEYDOWN:
                 MessageBox(hwnd,"HI","HI",MB_OK);
               break;  
     }
}
[/code]

For now im just trying to catch the KEYDOWN event because if i got this working I know how to detect if its VK_RETURN, but for now im not getting anything, Any Ideas?
February 8, 2006, 10:04 PM

Search