Display HTML content without a window in WIN32 - c++

I want to display HTML text inside a RECT structure within a win32 window. I have found a lot of APIs which helps me render HTML in a separate window, but my requirement is that we dont have to assign a separate window handle for the HTML being displayed.

The RECT structure is basically two points representing a rectangle, as documented here. You can't store any other kind of information inside of a RECT.
Perhaps what you need to do requires creating an EDITTEXT control, described here and use it display the HTML as text. You can use the values from the RECT to define the x, y, width and height parameters of the EDITTEXT.

Related

CListCtrl SetIconSpacing include text

I'm using SetIconSpacing() in my CListCtrl icon view and the spacing is fine except I'm also displaying the image name under the image. Right now I'm forcing the spacing to m_ctrlList.SetIconSpacing(CSize(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT+20)); where the 20 represents the text height. Is there a way to get the text height from the control?
I'm using the standard control, no funny biz.
Many thanks
You can use GetTextExtentPoint32() function. Here's what you have to do.
Use/Create any DeviceContext(CClientDC is best).
Get the font from the CListCtrl and assign the font to dc using SelectObject() function.
Now use GetTextExtentPoint32() function and get the font height.
Now set the old font back to dc.
That's it.

Program that displays content on screen but no window

In windows: I would like to know if it is possible (and if so, how) to make a program in C++ that displays images/text on the screen directly, meaning no window; if you are still confused about what I am after some examples are: Rocketdock and Rainmeter.
you can do it certainly without using Qt or any other framework. Just Win32 API helps you do that and internally, every framework calls these API so there is no magic in any of these frameworks
First of all, understand that no image or text can be displayed without a window. Every program uses some kind of window to display text or image. You can verify it using the Spy++ that comes with windows SDK. click the cross-hair sign, click the image or text you think is displayed without any windows. The Spy++ will show you the window it is contained in.
Now how to display such image or text that seems like not contained in any window. Well you have to perform certain steps.
Create a window with no caption bar, resize border, control box, minimize, maximize or close buttons. Use the CreateWindowEx() and see the various windows style WS_EX_XXX, WS_XXX for the desired window style.
Once the window is there you need to cut the window. Much like a cookie cutter. for this you need to define an area. This area is called region and you can define it using many functions like CreateEllipticRgn(), CreatePolygonRgn(), CreateRectRgn(), CreateRoundRectRgn() etc. all these functions return a HRGN which is the handle to the region. Elliptical or rectangle regions are OK as starter.
Now the last part. You have to cut the window like that particular region. Use the SetWindowRgn() function which requires a handle to your window and a handle to that region (HRGN). This function will cut the window into your desired shape.
Now for the image or text. Draw the image or text inside the window. I assume you must have cut the window according to your image, You just need to give window a face. so just draw the image either on WM_ERRASE BACKGROUND or WM_PAINT messages
Use the SetWindowPos() to move the window to the location you wish to on screen. If you have used correct parameters in CreateWindowEx() then this step is not necessary
You can set any further styles of windows using SetWindowLong() function.
Congratulations, you have your image displayed without using any windows ;)

How to detect the control text's line number?

The dialog contains the static text control. When intializing the dialog the application sets a custom text to this static text control:
HWND hWnd = GetDlgItem(IDC_MY_STATIC_TEXT);
::SetWindowText(hWnd, szMyCustomText);
I need to know the number of the lines that the specified text will be broken into and this text width when it is displayed in UI. Could you please share your idea?
This will depend on the font, DPI and other settings. I recommend looking up static text controls which says:
The system displays as much text as it can in the static control and clips whatever does not fit. To calculate an appropriate size for the control, retrieve the font metrics for the text. For more information about fonts and font metrics, see Fonts and Text.
Combined with this post about calculating the size of the resulting text should get you on your way to calculating the text width (and with knowledge of the text height the number of lines).

Setting item height of a list view? (using custom draw)

How can I set the row height of a custom drawn list view? Or does it require an owner drawn list view?
It depends on the mode you are using it in. In some modes, you can use the LVM_SETITEMHEIGHT message. In others some modes, the item height is dictated by the height of an associated ImageList, if any, followed by the height of the assigned Font.
Update: turns out that LVM_SETITEMHEIGHT is part of the MiniGUI library, not part of the Win32 API. In that case, you would have to use the LVS_OWNERDRAWFIXED window style and then subclass the ListView to handle the WM_MEASUREITEM message.

Custom draw CTreeCtrl: how to add font strike through?

I have implemented custom draw for an CTreeCtrl in my MFC Smart Device program. I have successfully changed the color of specific nodes of the CTreeCtrl. I am now trying to understand how to get the default font used to draw text in the control so I can add a strike-through to the font for certain nodes. How would I go about getting the default font used to draw text in the CTreeCtrl and apply a font strike-through to the font?
Use GetFont() to get the font of the control. Strike-through can't be done with ::DrawText AFAIK, but it's easy to just add a GoTo()/LineTo(). You can use GetTextExtent() to get the size of the bounding rectangle and derive the left/right of the strike through line from that.