MFC Programming Help - CView Window Width

  • Thread starter Thread starter pervect
  • Start date Start date
  • Tags Tags
    Programming
AI Thread Summary
For MFC programming help, particularly with version 6.0, users are seeking effective methods to determine the width of a CView window for proper line-breaking in the OnDraw() function. A common issue arises when using the device context pointer pDC and calling pDC->GetWindowExtent(), which returns a size of 1,1, leading to confusion about whether the correct function is being used or if there are setup issues with the window. To accurately obtain the window dimensions, utilizing the GetClientRect function is recommended. This involves defining a RECT structure, calling GetClientRect to fill it, and then calculating the width and height based on the RECT values. This approach ensures that the displayed text lines fit appropriately within the window.
pervect
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Messages
10,410
Reaction score
1,588
Are there any good sites for MFC programming help? (THat's Microsoft Foundation Classes - C++ version 6.0 to be specific).

In case anyone here can help:

I'm trying to find the width of a MFC CView window, so I can do line-breaking in the ondraw() function, so that my displayed text lines fit the window.

Unfortunately taking the device context pointer pDC and evaulating pDC->GetWindowExtent() gives me a size of 1,1. Since I was in the default mode MM_TEXT, I thought I should get a window size in pixels. I don't know if I'm using the wrong function, or have set anything up wrong in the window (but most everything about the window the APPwizard default for SDI (single document) application).
 
Computer science news on Phys.org
Try this:

RECT rect;
GetClientRect(&rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
 
This week, I saw a documentary done by the French called Les sacrifiés de l'IA, which was presented by a Canadian show Enquête. If you understand French I recommend it. Very eye-opening. I found a similar documentary in English called The Human Cost of AI: Data workers in the Global South. There is also an interview with Milagros Miceli (appearing in both documentaries) on Youtube: I also found a powerpoint presentation by the economist Uma Rani (appearing in the French documentary), AI...
Thread 'Urgent: Physically repair - or bypass - power button on Asus laptop'
Asus Vivobook S14 flip. The power button is wrecked. Unable to turn it on AT ALL. We can get into how and why it got wrecked later, but suffice to say a kitchen knife was involved: These buttons do want to NOT come off, not like other lappies, where they can snap in and out. And they sure don't go back on. So, in the absence of a longer-term solution that might involve a replacement, is there any way I can activate the power button, like with a paperclip or wire or something? It looks...
Back
Top