All of the threads/tutorials/examples on RichEdit controls are created with the CreateWindow api, and I'm having no luck using a dialog with the RichEdit20a class. If need be I'll use an actual window instead of the dialog but I hate giving up on something this simple. Does anyone know what I'm doing wrong?
Posted on 2002-05-28 14:30:05 by Will
you got a mini attempt with some source code? maybe i can spot a problem or try some testing of my own. dont worry you will have complete copyrights to it.:grin:
Posted on 2002-05-28 16:21:26 by smurf
I'm sorry. I didn't realize that I'd need to show this, but.....

Basically I don't think it's a source code issue, but a resource script one. Anyeays, here's the line in question in the resource script:


CONTROL "",101,"RichEdit20A",WS_VISIBLE,5,5,100,60


I tried using LoadLibrary with the richedit dll but it still didn't work. Is there something special that you have to do with the richedit control or did I miss something? It's not displaying the richedit control.

:) This is definitely not an issue of me being worried about showing my source! All I'm trying to do is display a richedit control.


edit:
I wasn't trying to get someone to write some complicated algo or anything, just help me display the richedit dialog. After that's done I'm sure I'll be able to figure out the richedit messages myself. :)
Posted on 2002-05-28 17:20:04 by Will
A google turned up:
#include <windows.h>

#include "resource.h"

IDD_TESTDLG DIALOG DISCARDABLE 0, 0, 283, 175
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "wdj SimpleHTML Test"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "Close",IDCANCEL,226,157,50,14
CONTROL "",IDC_RICHEDIT,"RichEdit20A",
WS_BORDER | WS_VSCROLL | WS_TABSTOP | 0x804,
7,7,269,147
END
An additional complication is that the two versions of the control have different window class names. The Rich Edit 1.0 window class is called ?RICHEDIT,? whereas the 2.0 window class is called either ?RichEdit20A? or ?RichEdit20W? depending on whether the ASCII or Unicode version is used. In a real-world program, you therefore cannot use a resource file (as I have done in this example) to create the rich edit control, but instead will need to create it at runtime using CreateWindowEx(), specifying the appropriate class name. See the Windows SDK for more information about this.
// Initialise richedit library

if (!(hInstRich=LoadLibrary("riched20.dll"))) return 0;

// Show dialog
DialogBoxParam(hInstance,MAKEINTRESOURCE( IDD_TESTDLG ),
HWND_DESKTOP,(DLGPROC)TestDlgProc,0);
Looks like it should work?
Posted on 2002-05-28 18:00:55 by bitRAKE
sorry 4oh4 it wasnt anything personal it was just kind of an inside joke. read here for more info http://www.asmcommunity.net/board/index.php?topic=5599 .

anyways looks like bitRAKE found some good info. i was just wondering about this line though: "In a real-world program, you therefore cannot use a resource file". wonder whats that all about.
Posted on 2002-05-28 21:59:22 by smurf
If the only problem(s) are richedit1 vs. newer richedits, and ansi
vs. unicode, I don't think there will be any problems in real-life
applications - you probably ;) know beforehand if you'll be using
ansi or unicode, and availability of the correct richedit can be tested
before any dialog is shown.

Or am I missing something?
Posted on 2002-05-29 04:51:49 by f0dder
i have put a richedit (v1) control in an about box. resource looks like:



BEGIN
DEFPUSHBUTTON "OK",IDOK,133,185,58,14
ICON IDI_ICON1,IDC_STATIC,7,11,20,20,0,WS_EX_CLIENTEDGE
CONTROL "",IDC_ABOUT,"RICHEDIT",ES_MULTILINE | ES_AUTOVSCROLL |
ES_WANTRETURN,33,11,275,167,
WS_EX_CLIENTEDGE | WS_EX_LEFTSCROLLBAR
END


Source code is in C++ only:



#if (_RICHEDIT_VER >= 0x0200 )
#define RICHEDIT_DLL "riched20.dll"
#else
#define RICHEDIT_DLL "riched32.dll"
#endif

...

static HMODULE hLibRichEdit = 0;
LRESULT rc = 0;

switch (LOWORD(wparam)) {
case IDM_ABOUT:
if (hLibRichEdit == 0)
hLibRichEdit = LoadLibrary(RICHEDIT_DLL);
DialogBox(GetWindowInstance(hWnd), MAKEINTRESOURCE(IDD_ABOUT), hWnd,aboutproc);
break;



To set the text of the control, use the EM_STREAMIN, not SetWindowText (which doesnt work in all cases)

japheth
Posted on 2002-05-29 08:12:12 by japheth
Thanks for all the replies. Well it looks like the resource script was fine after all. I didn't check to see which version of the richedit library my system has so that has to be the problem. That's what I get for just skimming icz's tuts eh. Sorry for asking a question that a little googling would've solved. :(

Smurf: Ouch. I'm sure that with all the different languages/nationalities/cultures of the members of this board there is bound to be confusion and misunderstanding and whatnot from time to time. I don't feel right passing judgement on the guy from that thread that you linked to because I wasn't involved, but I understand your comment now. No harm done though, as I have fairly thick skin. :) And if you want the project when I'm done you're more than welcome to it. I don't ever see myself copyrighting anything, especially something that I do in my spare time at work and home that is not part of my job contract but will make my job just a wee bit easier.
Posted on 2002-05-29 09:31:11 by Will