|
|
Is there a way to measure richedit height? I should put CRichedit into fixed width window, but I should avoid vertical scroll. So, I should calculate the CRichEdit(with text) height for a specified width. Is it possible?
Pavel Sokolov
|
|
|
|
|
You could use GetWindowPlacement[^] to determine the height; the rcNormalPosition member of the WINDOWPLACEMENT structure has the info you're after.
Then SetWindowPlacement[^] to adjust it if needed.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
I need it before creation of actual control.
Pavel Sokolov
|
|
|
|
|
Okay so instead of measuring it, it should be calculated.
What is known to base the calculation on? The number of lines that are going to be in the control?
If so, you should multiply the number of lines with the height of a line, depending on the font, and add an offset of a few pixels for the border.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Nothing. I have only width of the control. The lines can have different styles and fonts and even with pictures.
Pavel Sokolov
|
|
|
|
|
So what exactly decides then how high you want it to be?
modified 13-Sep-18 21:01pm.
|
|
|
|
|
The text in the control. I want to fit richedit into item of another control without vertical scrollbar.
The main idea is to build messages archive (history for IM). There can be a lot of messages and they are in rtf. Currently I'm trying to insert RichEdit into ListBoxItem and I need width and height for MeasureItem().
Pavel Sokolov
|
|
|
|
|
|
Pavel Sokolov wrote: Is there a way to measure richedit height?
You mean something like GetWindowRect() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Actually I want to display richedit inside the other control item. So, I know width, but I should set the height too. I deen something like: int m_Height = m_RichEditControl.CalculateControlHeightForThisWidth( m_intWidth )
Pavel Sokolov
|
|
|
|
|
На самом деле, варианта у тебя два:
- действительно создать скрытый рич-едит, вызывать у него RequestResize и ловить EN_REQUESTRESIZE. Вариант вполне нормальный.
- если делать совсем все правильно, то в твоем случае не надо встраивать рич-едиты в лист-контрол. Тебе надо копать в сторону windowless-ричедита, внимательно изучив ITextHost/ITextServices.
ЗЫ: Как жизнь вообще? Чем занимаешься? Твой логотип SWR оказался очень живуч )
Regards,
Nikolay
|
|
|
|
|
Мама дорогая, какие люди! Да ничего, всё тем же и занимаюсь. Ты то как? Я вас пытался найти как-то по соцсетям - да так и не нашёл.
А что мне даст безоконный ричедит? На самом деле у всех подобные контроллы есть (да почти во все месенджерах история сообщений), а тут такие сложности... Может вообще одним ограничиться и догружать нужное по кликам на скроллбарах, так наверняка будет мелькать противно.
Pavel Sokolov
|
|
|
|
|
Ну, смотря какой функционал тебе от этого списка нужен. Если просто "мертвый" список, то я бы ограничился первым вариантом. Т.е. создал бы невидимый ричедит, через него бы вычислял высоту каждого айтема в списке, через него же рендерил в битмап в памяти сам текст айтема. Потом при отрисовке айтема просто выводил бы уже готовый битмап.
Если же требуется какая-то интерактивность от списка, например, если ты хочешь, чтобы можно было бы кликнуть на линки, которые могуть быть в тексте, менять курсор, когда мышка поверх таких линков и т.п., то тут уже без безоконного ричедита обойтись будет трудно.
ЗЫ: я есть тут: http://vkontakte.ru/id1216693[^] или тут http://ru-ru.facebook.com/profile.php?id=1610591135[^]
Regards,
Nikolay
|
|
|
|
|
hello guys... I am actually recording a wave file. I have hardcoded the file path but the file name is provided by the user. Now I want to wave file to be stored at this combination of these two which in im successful. Here is what im trying
LPCSTR filePath = "d:\\Audios\\";
LPCSTR fileNamePath = strcat(filePath, strcat(fileName, ".wav"));
This is not successful, how can I do that?? thnx
|
|
|
|
|
overloaded Name wrote: This is not successful
Please be specific when asking a question. What doesn't work exactly ?
In your case, I would guess it is because you are using constant strings (LPCSTR, the C is for constant). Try using LPSTR instead, it should work. Don't forget that strcat will modify the destination string (check the documentation).
BTW, it is far more easier to use std::string instead of using raw char pointers.
|
|
|
|
|
strcat needs a writeable destination buffer.
where is all this text going to be stored? you need a buffer large enough to hold it, I see it nowhere.
Here is one way of doing it (C code):
char* result=malloc(1000);
strcpy(result, filePath);
strcat(result, fileName);
strcat(result, ".wav");
This is far from optimal, as the size is overestimated, and the string operations are unsafe, they could overrun the destination buffer. It would also fail if filePath doesn't end on a backslash, or fileName already has an extension.
But it would work.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You are using strcat() incorrectly so this code wll not work. However, you would also be better using the more secure versions[^] of these functions.
I must get a clever new signature for 2011.
|
|
|
|
|
You could use the PathCombine[^] and PathAddExtension[^] functions, they solve the problems mentioned by Luc Pattyn.
e.g.
PathCombine(fileNamePath,filePath,fileName);
PathAddExtension(FileNamePath,".wav");
Note the remark, make fileNamePath able to hold at least MAX_PATH characters.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Pretty handy functions, i did not know they existed.
To OP, if you do use them you will need to #include and link with Shlwapi.
|
|
|
|
|
Here is the C++ way to do this -
std::stringstream strm;
strm << filepath << filename << ".wav";
std::string str(strm.str());
|
|
|
|
|
I need a sample of how to load dialog resource from a dll
I found a sample here but it is not working.
http://www.codeproject.com/Messages/1212280/Re-how-to-load-dialog-resource-from-a-dll.aspx
HMODULE hModule = LoadLibrary("C:\\another_resource.dll");
if(hModule != NULL)
{
HWND hDialog = CreateDialog(hModule, MAKEINTRESOURCE(ID_DIALOG), , );
HBITMAP hBitmap = LoadBitmap(hModule, MAKEINTRESOURCE(IDB_BITMAP);
FreeLibrary(hModule);
}
thanx in advance please help
Some Day I Will Prove MySelf :: GOLD
|
|
|
|
|
please mention what is among LoadLibrary, CreateDialog and LaodBitmap is not working.
|
|
|
|
|
create dialog.. Is required,
I have the correct dialog id and i m able to load the dll using loadlibrary(). After this i m confused what to do next,
so i need a small example that demonstrate how to show the dialog from resource dll.
Thanx in advance.
Some Day I Will Prove MySelf :: GOLD
|
|
|
|
|