why i cant use richedit 4.1

This is a discussion on why i cant use richedit 4.1 within the Windows Programming forums, part of the Platform Specific Boards category; Hi i am tryng to change a program i wrote to use richedit 4.1. It compiles but doesnt work...The library ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    133

    why i cant use richedit 4.1

    Hi i am tryng to change a program i wrote to use richedit 4.1. It compiles but doesnt work...The library was loaded successfully. Yet, the rich edit window just cant be created.

    Code:
    // rich edit control
    	InitCommonControls();
    	if(!LoadLibrary("Msftedit.dll"))
    	return 0;
    
    	GetClientRect(hwnd,&r);
    	hEditCntl = CreateWindowEx(0,
    								TEXT("RICHEDIT_CLASS"),
    								NULL,
    								WS_CHILD |WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
    								ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE,
    								0,
    								0,
    								r.right-r.left,
    								r.bottom-r.top,
    								hwnd,
    								(HMENU)ID_EDIT,
    								hinst,
    								NULL);
    
    			if(!hEditCntl)
    		MessageBox(hwnd,"Not working","Not working",MB_ICONEXCLAMATION );

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The class name for that version should be MSFTEDIT_CLASS [edit](#defined as L"RICHEDIT50W")[/edit] but you should also note that v4.1 of the richedit control is only available to UNICODE applications running on a mininum of winxp with service pack 1 installed.
    Last edited by Ken Fitlike; 07-08-2004 at 04:42 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    oops i wasnt aware it was for unicode application. What about rich edit 3.0? I tried loading the riched20.dll library and register with the classname "RICHEDIT_CLASS". It didnt work either.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    RICHEDIT_CLASS is a macro placeholder for the classname so use it as is and not as TEXT("RICHEDIT_CLASS"). Don't worry about UNICODE either, the macro takes care of that, too, ie. substitutes the wide char or char classname according to whether or not UNICODE is defined.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    Oh yes it finally work. Now i can start to the functions of rich edit. Thanks alot.

    But just one more question. I have a menu for the parent window of the rich edit control. Each time i selects the undo function from the menu, it does not execute the undo action on the control if i use the window handle from the WM_COMMAND message handler, i.e hwndCtl. I have to use the window handle i store in my mainFrame class when i first create the control for the undo action to work. Is there something wrong with my HANDLE_WM_COMMAND message handle?

    HANDLE_WM_COMMAND calls this function:
    Code:
    void mainFrame::mainWindow_onCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
    {
    	switch(id)
    	{case ID_FILE_EXIT:	DestroyWindow(hwnd);
    						break;
    
    	case ID_FILE_NEW: Edit_SetText(hEditCntl,NULL);
    		              break; 
    
        // function to handle notify message from rich edit control
    	case ID_EDIT: edit_onCommand(hwnd,id,hwndCtl,codeNotify);
    		                 break;
    
    // I CANT USE hwndCtl FOR THIS CASE
    	case ID_EDIT_UNDO: Edit_Undo(hEditCntl);
    					   break;
    
    	default: FORWARD_WM_COMMAND(hwnd,id,hwndCtl,codeNotify,DefWindowProc);
    	}
    
    }

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    That's normal behaviour: if the WM_COMMAND is issued in response to a menu selection then the message lParam - hwndCtl in your handler - is NULL.

    You may also want to consider checking that HIWORD(wParam) - codeNotify in your handler - is NULL when checking for menu items. This avoids the possibility, however remote, of your menu selection code misfiring should the menu item share an id value with some other resource.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    ah yes...I realised my mistake. Thanks for saving my day again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. RichEdit 4.1 problem
    By bradic in forum Windows Programming
    Replies: 4
    Last Post: 07-20-2005, 09:14 AM
  2. RichEdit need help!!!
    By lucas4ce in forum Windows Programming
    Replies: 1
    Last Post: 08-21-2004, 03:27 PM
  3. Drawing on a RichEdit?
    By Sea Monster in forum Windows Programming
    Replies: 5
    Last Post: 12-30-2003, 02:17 PM
  4. Problems with my richedit...
    By tyouk in forum Windows Programming
    Replies: 2
    Last Post: 11-02-2003, 04:57 AM
  5. RichEdit Problem
    By dirkduck in forum Windows Programming
    Replies: 0
    Last Post: 07-24-2003, 06:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21