Help with Rich Edit in MFC DLL based project
I need to use Rich Edit text field in a dialog box that's a part of MFC App Wizard(DLL based) project. I am using VC++ 6.0.
Now I went through google and found out about using AfxInitRichEdit() in the InitInstance() method and using wWinMainCRTStartup in EntryPointSymbol in the Link->Output setting. But since it is a DLL based project,so I did not find any InitInstance() method.
But at one point of code, it does have a WM_INITDIALOG, where I tried to use AfxInitRichEdit().It cribbed stating error "error C2065: 'AfxInitRichEdit' : undeclared identifier". Now I cannot use "stdafx.h" coz we are already using "windows.h".
Next I found out that we can use LoadLibrary(TEXT("RICHED20.DLL")). I put that in place of AfxInitRichEdit().It built fine,but then when I tried to reproduce the dialog box, it cribbed again.
So now I am in a fix, as to how can I use RichEdit in my DLL based project.Can anyone help me out in solving this issue?
Adding up, actually I need to type Japanese characters in a text field in that dialog box.Currently it uses a normal edit box, which has been tuned to accept CString.May be because of that when I try to do so,the characters appear garbled. So I am replacing that normal text/edit field with a Rich Edit control. Is there any other way I can display Japanese characters properly in the text field without using Rich Edit ? Again I would like to repeat that its a DLL based project.
first, stdafx is not "real". If you turn off pre-compiled headers (and you should, they make your project compile wrong sometimes and cause problems, all it saves is a couple of nanoseconds of compile time at great cost) then you do not need stdafx. You may need some of the includs from stdafx.h (afxwin.h, etc and maybe windows.h). You can remove it and include the actual windows headers and probably make your project much easier to manage.
Second, you are correct you have no initinstance. You may have a dllmain (I do not know, I always made my dll's from scratch by using export commands, the "project" dlls make a lot of do-nothing gibberish in your code). Look for it though, there should be a dll "entry point" or main function of some sort. If not, you can put your rich edit init into the window frame class's constructor, and that should be ok.
Just to clarify, you are making a dll that another program will use, which creates a window at the demand of the user-program?
Thanx for ur help. I do have a DLLMain() in my code. I tried putting AfxInitRichEdit() in it, and successively used stdafx.h,afxwin.h and afxcmn.h, but in all cases ended up with the following error:
C:\Program Files\Microsoft Visual Studio\VC98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include<windows.h>
Now its just that since there are many files which call windows.h, I simply can't go ahead removing all those references. This would lead to some other string of issues.
And yes I am making a dll that another program will use, which creates a window at the demand of the user-program.
Can I use the normal edit box instead of Rich edit, and still be able to view Japanese characters properly when I type them?
The windows.h error is a hard one to fix. You do not actually have to remove the include, often simply putting it first or last (via trial and error) one file at a time will stumble over the problem and clear it up. I have never found a pattern to what trips the error, but it is definately worded wrong (you absolutely can include it, if you get the order correct). You may try this path.
I see no reason why a standard edit box cannot display your text. Rich edit adds the ability to have mixed font styles in a single document (bold, colors, various fonts all in one document as word etc. allow). Normal edit have global controls so all the text is the same (can still be bold, or any font, etc. just all has to be the same style). I am fairly sure that if you set the edit box to unicode (or, it may be always this way internally, again I do not know) and pick a font for your language, it "should" work. I have not had to use unicode much, however, so I cannot say 100% for sure, I am just making a solid guess based on the main difference between the two controls.
Note that if you edit a rich text document in a plain text one, all you get is XML tags around the text that change its font etc, the rest of it is the same.
Last Post: 07-02-2007, 07:12 PM
By mmingfeilam in forum C++
Last Post: 07-06-2006, 08:50 AM
By Tom Staresinic in forum ASP.NET
Last Post: 07-20-2001, 03:25 PM
By Craig McLellen in forum ASP.NET
Last Post: 10-23-2000, 03:00 AM
By Brian Patrick in forum VB Classic
Last Post: 08-08-2000, 12:43 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL