Valhalla Legends Forums Archive | C/C++ Programming | RichTextBox

AuthorMessageTime
FrOzeN
[code]hWndEditBox = CreateWindow("EDIT",
                          "Edit Boxes",
                          WS_VISIBLE | WS_CHILD,
                          10,
                          10,
                          100,
                          50,
                          hWnd,
                          (HMENU)IDC_EDITBOX_TEXT,
                          (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
                          NULL);[/code]
The above code creates a Edit Box (Textbox) in C++. Does anyone have similar (or even an entire class) code to create a RichTextBox (and possibly post their AddChat procedure too). I need to add a RichTextBox to a program I'm making in VB6 and cannot use the .ocx control due to restrictions on how I'm doing the rest of the program. So I'll just convert the C++ code over, and modify it accordingly. Thanks.
May 28, 2007, 8:45 AM
Barabajagal
Just figure out how to use the RichEd32 or RichEd20 dlls? It's not that hard, and more powerful than the ocx anyway.
May 28, 2007, 8:58 AM
FrOzeN
Basicly, in my VB6 project I'm trying to create and use a RichTextBox on the form using only the API. Being that I figured out how to do all the controls using the C++ equivalent so far I figured it might be the same with the RichTextBox. After some further searching I found it, turns out RichEdit is what I was after.

http://tek-tips.com/viewthread.cfm?qid=826090

I'd still appreciate to see code for the AddChat in C++. Save me looking up all the .SelLength, .SelText, etc. individually to rewrite.
May 28, 2007, 11:25 AM
Quarantine
API calls are API calls. They're not language specific. It's a waste of time doing it in C++, if your target language is VB6 do it there from the get go.
May 28, 2007, 2:02 PM
FrOzeN
Actually, I think it's much easier if I do it by getting the C++ code and converting it over. I can't even find a single source or really any helpful information about how to create controls and such with API in Visual Basic. I used this C++ tutorial to build to basic form and just converted the code over as I did it.

As many people in C++ would have used a RichEdit box it's much less hassle using their code as reference to what needs to be done, rather than fiddling around trying to find out all the calls and such that are needed to work with it in VB6.
May 28, 2007, 10:41 PM
Quarantine
You call the APIs..and handle the results..what's not to get?
May 29, 2007, 4:15 AM
FrOzeN
There isn't any documentation for it in VB6, as almost all VB6 users use the .ocx control. Therefore I figured a fair amount of users would of done it in C++ without the use of MFC which can be very helpful to me as it's quite simple to convert over. It's quicker than having to go over all the MSDN documentation on it which is in C++ anyway.
May 29, 2007, 5:12 AM
Quarantine
You're right, it's easier to port when you have existing C++ code, thats a given. However if you're going off of nothing, explicitly writing it in C++ just to convert it has little or no benefits.
May 29, 2007, 10:41 AM
Zakath
An example that created a RTB in C:

[code]
//somewhere where it will be run once when the program starts up
HMODULE hmodRTB = LoadLibrary( "RICHED20.DLL" );

//when you want to create the window
HWND hwndRTB = CreateWindowEx( NULL, RICHEDIT_CLASS, (LPCTSTR)NULL, WS_CHILD | WS_VISIBLE | ES_MULTILINE, 0, 0, 400, 200, hwndMain, (HMENU) (int) (ID_RTB), hInstance, NULL);

//right before the program exits
FreeLibrary( hmodRTB );
[/code]
June 2, 2007, 2:49 AM

Search