Recently, I released a DLL
http://www.mircscripts.org/comments.php?id=2357
that takes advantage of the rich editbox feature of mIRC 6.14. At the point of my release, I was having trouble with a subclass issue, so a certain feature wasnt included. This feature was when someone presses 'control+b' the text turns bold, and 'control+u', the text becomes underlined. Tonite, I completed that feature in my proc, finally, heh. Except for a few minor issues.

1. When the control code is pressed, the following text becomes bold or underlined like it should, however, when the closing control code is pressed, for some reason 2-3 characters afterward are bold(if control+b is pressed), when they shouldnt be. I cant figure out why.

2. The backspace and arrow keys dont work in the richedit under the Proc. I cant figure out why either.

Any assistance will help, here is the full proc:
Code:
LRESULT CALLBACK RichProc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
{
   switch(msg)
   {
     {
      case WM_KEYDOWN:
		  if(wp == VK_CONTROL) {
			  cd++;
		  }
	 break;
   case WM_KEYUP:
	   if(wp == 0x42 && cd !=0) {
		   if(!bc) {
		         CHARFORMAT2 cfm;
                    cfm.cbSize = sizeof(cfm);
                                                          SendMessage( hwnd, EM_GETCHARFORMAT,
                    (WPARAM)SCF_SELECTION, (LPARAM)&cfm );
                     cfm.dwMask = CFM_PROTECTED | CFM_BOLD;
                     cfm.dwEffects = CFE_BOLD;

                                                          SendMessage( hwnd, EM_SETCHARFORMAT,
                   (WPARAM)SCF_SELECTION, (LPARAM)&cfm );
					bc++;
					cd--;
			  }
		   else if(bc != 0) {
		      	  CHARFORMAT2 cfm;
                    cfm.cbSize = sizeof(cfm);
                     cfm.dwMask = CFM_PROTECTED;
                                                          SendMessage( hwnd, EM_SETCHARFORMAT,
                   (WPARAM)SCF_SELECTION, (LPARAM)&cfm );
					bc--;
					cd--;
			  }
	   }
	  else if(wp == 0x55 && cd !=0) {
		  if(!uc) {
	               CHARFORMAT2 cfm;
                    cfm.cbSize = sizeof(cfm);
                                                          SendMessage( hwnd, EM_GETCHARFORMAT,
                    (WPARAM)SCF_SELECTION, (LPARAM)&cfm );
                     cfm.dwMask = CFM_UNDERLINE;
                     cfm.dwEffects = CFE_UNDERLINE;

                                                          SendMessage( hwnd, EM_SETCHARFORMAT,
                   (WPARAM)SCF_SELECTION, (LPARAM)&cfm );
					uc++;
					cd--;
			   }
		   else if(uc != 0) {
		      	  CHARFORMAT2 cfm;
                    cfm.cbSize = sizeof(cfm);
                     cfm.dwMask = CFM_PROTECTED;
                                                          SendMessage( hwnd, EM_SETCHARFORMAT,
                   (WPARAM)SCF_SELECTION, (LPARAM)&cfm );
					uc--;
					cd--;
			  }
	  }
         break;
	  case WM_DESTROY:
          SubclassWindow(hwnd,NULL);
		  PostMessage(hwnd,WM_DESTROY,0,0);
		  break;
      default:
		   int blah = Search(hwnd);
           CallWindowProc(AllProcs[blah].procold,hwnd,msg,wp,lp);
                break;
			}
			int blah = Search(hwnd);
           return CallWindowProc(AllProcs[blah].procold,hwnd,msg,wp,lp);
	 }
    return 0L;

}

EDIT: Added [[/b]code] [[/b]/code] tags.

Last edited by Hammer; 26/03/04 08:11 AM.