lundi 26 avril 2021

How do I get a rectangle (or &rc) from a memory hdc without using a handle or HWND

I am using Microsoft Windows (32 bit). Please, no Visual Studio anything, or .net.

I have the following that works if I have a windows handle to use for it:

// I have a handle to a window.    
// HWND Handle_Of_SomeWindow
// I previously assigned a handle for that and use it.

// I have some Unicode text that I am using.
wstring SomeWideStringText = L"C++ stole my lunch money.";

// I convert that wstring to LPWSTR using 
LPWSTR Text_Being_Added = const_cast<wchar_t*>(SomeWideStringText.c_str());
    

//I create a rectangle to use in my DrawTextExW
RECT rc;    

// If I have a handle to a window then I can do this.
GetClientRect(Handle_Of_SomeWindow, & rc);

//But, if I do not have a handle to a window and if I only have a hdc, then that does not work.

When I have an HDC without a window handle (I think that this is a memory dc but I do not yet understand that so well) which I am using in double buffering, then there is no handle to use. And, I can not get a handle for it. Get handle from DC does not work.

So, my question is How do I get a rectangle or &rc for that to use in my command of :

DrawTextExW(HDC_of_FRONT_BUFFER_001, Text_Being_Added, -1, & rc, DT_WORDBREAK, nullptr);

?

Maybe there might be something else other than a rectangle &rc that I could use, but I have not found it.

I have been studying this and I do not understand how to get a rectangle or a &rc to use.

Aucun commentaire:

Enregistrer un commentaire