Click here to Skip to main content
15,897,891 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Windows Service Help Pin
myshketer11-Dec-07 21:21
myshketer11-Dec-07 21:21 
GeneralRe: Windows Service Help Pin
led mike12-Dec-07 6:29
led mike12-Dec-07 6:29 
GeneralSeeking advice on proper use of some c/c++ stuff, on my code. [modified] Pin
Dexterus6-Dec-07 0:49
Dexterus6-Dec-07 0:49 
GeneralRe: Seeking advice on proper use of some c/c++ stuff, on my code. [modified] Pin
Dexterus6-Dec-07 0:52
Dexterus6-Dec-07 0:52 
GeneralVista's Explorer toolbar control Pin
yarp5-Dec-07 23:31
yarp5-Dec-07 23:31 
GeneralRe: Vista's Explorer toolbar control Pin
Michael Dunn6-Jan-08 11:20
sitebuilderMichael Dunn6-Jan-08 11:20 
GeneralRe: Vista's Explorer toolbar control Pin
yarp6-Jan-08 19:18
yarp6-Jan-08 19:18 
QuestionProlem with rich edit control. ITextService's TxGetNaturalSize doesnt give me the right value.. [modified] Pin
Arif Siddiquee5-Dec-07 1:25
Arif Siddiquee5-Dec-07 1:25 
Hi all,
I have been trying to determine the ideal rectangle for the rich edit control text. but failed.

Here is the thing that i did..

Method 1:
HRESULT SetToNaturalSize(LONG w) {
  HDC hdc = ::GetDC(parent_window_);
  LONG x_per_inch = GetDeviceCaps(hdc, LOGPIXELSX);
  LONG y_per_inch = GetDeviceCaps(hdc, LOGPIXELSY);

  LONG width = (w * HIMETRIC_PER_INCH + x_per_inch - 1) / x_per_inch;
  LONG height = LONG_MAX;
  SIZEL sizel = { LONG_MAX, LONG_MAX };

  SetMapMode(hdc, MM_ANISOTROPIC);
  SetWindowExtEx(hdc, HIMETRIC_PER_INCH, HIMETRIC_PER_INCH, NULL);
  SetViewportExtEx(hdc, x_per_inch, y_per_inch, NULL);

  HRESULT hr = text_services_->TxGetNaturalSize(DVASPECT_CONTENT, hdc, NULL,
      NULL, TXTNS_FITTOCONTENT, &sizel, &width, &height);

  SetMapMode(hdc, MM_TEXT);
  ::ReleaseDC(parent_window_, hdc);

  if (SUCCEEDED(hr)) {
    width = (width * x_per_inch + HIMETRIC_PER_INCH - 1) / HIMETRIC_PER_INCH;
    height = (height * y_per_inch + HIMETRIC_PER_INCH - 1) / HIMETRIC_PER_INCH;

    text_rc_.left = 0;
    text_rc_.right = width;
    text_rc_.top = 0;
    text_rc_.bottom = height;
  }

  return hr;
}


Method 2:
HRESULT SetToNaturalSize(LONG w) {
  HDC hdc = ::GetDC(parent_window_);
  long width;
  long height;
  width = w;
  height = 1;
  SIZEL sz;
  sz.cx = width;
  sz.cy = height;

  HRESULT hr = text_services_->TxGetNaturalSize(DVASPECT_CONTENT, hdc, NULL, NULL,
                                                TXTNS_FITTOCONTENT, &sz, &width, &height);

  ::ReleaseDC(parent_window_, hdc);

  if (SUCCEDED(hr)) {
    text_rc_.SetRectEmpty();
    text_rc_.right = width;
    text_rc_.bottom = height;
  }

  return hr;
}


After that i call the TxDraw to draw the text with the rectangle text_rc_.
Both of them works fine(most times) under DPI set at 96, but when i set it to 120 then some of the text doesnt get drawn. I also observed that the function TxGetNaturalSize() doesnt return the same value for the same text each time.
Any idea where i could go wrong? Its driving me crazy..

modified on Wednesday, December 05, 2007 7:48:36 AM

QuestionContextMenu HWND in a Shell Extension Dll Pin
Jeffrey Walton30-Nov-07 23:45
Jeffrey Walton30-Nov-07 23:45 
GeneralRe: ContextMenu HWND in a Shell Extension Dll Pin
Michael Dunn6-Jan-08 11:22
sitebuilderMichael Dunn6-Jan-08 11:22 
QuestionC++ String split Pin
Mustafa Ismail Mustafa30-Nov-07 0:22
Mustafa Ismail Mustafa30-Nov-07 0:22 
AnswerRe: C++ String split Pin
Stuart Dootson30-Nov-07 3:36
professionalStuart Dootson30-Nov-07 3:36 
JokeRe: C++ String split Pin
Florin Crişan30-Nov-07 4:00
Florin Crişan30-Nov-07 4:00 
GeneralRe: C++ String split Pin
Mustafa Ismail Mustafa30-Nov-07 7:25
Mustafa Ismail Mustafa30-Nov-07 7:25 
AnswerRe: C++ String split Pin
Florin Crişan5-Dec-07 5:59
Florin Crişan5-Dec-07 5:59 
GeneralRe: C++ String split Pin
Mustafa Ismail Mustafa5-Dec-07 9:38
Mustafa Ismail Mustafa5-Dec-07 9:38 
GeneralRe: C++ String split Pin
Stuart Dootson5-Dec-07 20:19
professionalStuart Dootson5-Dec-07 20:19 
GeneralRe: C++ String split Pin
Mustafa Ismail Mustafa5-Dec-07 23:49
Mustafa Ismail Mustafa5-Dec-07 23:49 
AnswerRe: C++ String split Pin
Florin Crişan6-Dec-07 3:11
Florin Crişan6-Dec-07 3:11 
AnswerRe: C++ String split Pin
Florin Crişan30-Nov-07 3:46
Florin Crişan30-Nov-07 3:46 
QuestionWTL Web Scrapper Pin
Kuryn27-Nov-07 9:50
Kuryn27-Nov-07 9:50 
AnswerRe: WTL Web Scrapper Pin
Michael Dunn27-Nov-07 16:39
sitebuilderMichael Dunn27-Nov-07 16:39 
QuestionInclude ActiveX in a ATL service using .Net Pin
Alpa Agarwal26-Nov-07 2:53
Alpa Agarwal26-Nov-07 2:53 
Questionhow to get class name from an object of CSnapInItem Object Pin
alien888825-Nov-07 18:26
alien888825-Nov-07 18:26 
AnswerRe: how to get class name from an object of CSnapInItem Object Pin
Florin Crişan26-Nov-07 5:34
Florin Crişan26-Nov-07 5:34 

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.