Click here to Skip to main content
15,917,628 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: converting wide-character string to float? Pin
vikramlinux12-Feb-03 21:28
vikramlinux12-Feb-03 21:28 
GeneralRe: converting wide-character string to float? Pin
Hel12-Feb-03 21:34
Hel12-Feb-03 21:34 
GeneralRe: converting wide-character string to float? Pin
vikramlinux12-Feb-03 21:38
vikramlinux12-Feb-03 21:38 
GeneralRe: converting wide-character string to float? Pin
Hel12-Feb-03 21:58
Hel12-Feb-03 21:58 
Generalhelp needed displaying text Pin
raner12-Feb-03 19:57
raner12-Feb-03 19:57 
GeneralRe: help needed displaying text Pin
Roger Allen12-Feb-03 23:21
Roger Allen12-Feb-03 23:21 
GeneralRe: help needed displaying text Pin
raner13-Feb-03 4:29
raner13-Feb-03 4:29 
GeneralRe: help needed displaying text Pin
Roger Allen13-Feb-03 5:18
Roger Allen13-Feb-03 5:18 
If its in your on paint and your not using a CPaintDC object then you must call Validate() at the end of the procedure otherewise windows will send you another WM_PAINT message, and then another until the area is validated or is obscured completely by another window. CPaintDC does a validate() call for you automatically in its destructor, but if your using GetDC()/ReleaseDC() in the OnPaint, you need to call it.

Validate() syas to windows, this window is upto date and does not need to be-redrawn
Invalidate() says to windows that this window (or a rectangle of it) needs to be re-drawn. Windows will queue a WM_PAINT message for the window which had an invalidate() call on it.

GetTextExtent() is a function to be called on the DC

CString text = "I want to know my length!";
CSize textSize = pDC->GetTextExtent(text, text.GetLength());

textSize.cx = length of text in pixels for the current output font
textSize.cy = Height of text in pixels for the current output font

With this info you could centre you text using

CRect window;
GetWindowRect(&window);
x = (window.Width() - textSize.cx) / 2;
y = 500; // or whatever

pDC->TextOut(x, y, text, text.GetLength());



Roger Allen
Sonork 100.10016

Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
GeneralRe: help needed displaying text Pin
raner13-Feb-03 6:01
raner13-Feb-03 6:01 
GeneralRe: help needed displaying text Pin
raner13-Feb-03 6:11
raner13-Feb-03 6:11 
GeneralRe: help needed displaying text Pin
Roger Allen13-Feb-03 6:27
Roger Allen13-Feb-03 6:27 
GeneralRe: help needed displaying text Pin
raner13-Feb-03 7:07
raner13-Feb-03 7:07 
GeneralRe: help needed displaying text Pin
Roger Allen13-Feb-03 22:24
Roger Allen13-Feb-03 22:24 
GeneralRe: help needed displaying text Pin
raner15-Feb-03 2:31
raner15-Feb-03 2:31 
GeneralAPI Hooking Pin
vikramlinux12-Feb-03 19:50
vikramlinux12-Feb-03 19:50 
Generaldrag and drop Pin
Vikram Patwardhan12-Feb-03 19:22
Vikram Patwardhan12-Feb-03 19:22 
GeneralRe: drag and drop Pin
Tili12-Feb-03 19:52
Tili12-Feb-03 19:52 
GeneralRe: drag and drop Pin
xxhimanshu12-Feb-03 20:02
xxhimanshu12-Feb-03 20:02 
GeneralRecording avi files Pin
vin12-Feb-03 18:28
vin12-Feb-03 18:28 
GeneralRe: Recording avi files Pin
-Dy12-Feb-03 22:52
-Dy12-Feb-03 22:52 
GeneralRe: Recording avi files Pin
vin12-Feb-03 23:33
vin12-Feb-03 23:33 
GeneralRich Edit Control/Edit Control question Pin
paully12-Feb-03 13:17
paully12-Feb-03 13:17 
GeneralRe: Rich Edit Control/Edit Control question Pin
MAAK12-Feb-03 14:44
MAAK12-Feb-03 14:44 
GeneralRich Edit Control/Edit Control question - Another one Pin
Rage12-Feb-03 21:08
professionalRage12-Feb-03 21:08 
GeneralRe: Rich Edit Control/Edit Control question - Another one Pin
MAAK12-Feb-03 21:33
MAAK12-Feb-03 21:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.