Here is a working code that resizes dialog window to the size of the body. Note that you should set body margin to 0 (e.g. with CSS). Note that if you would want to also set width then you would have to set it first and recalculate and set height afterwards.
// Called by the framework to notify an application when a document has achieved the READYSTATE_COMPLETE state.
void CYourDialogClassDlg::OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl)
{
CDHtmlDialog::OnDocumentComplete(pDisp, szUrl);
// get document height (note - you need to set body margin to 0!)
LONG nHeight;
IHTMLDocument2 \*pDocument;
IHTMLElement \*pElement;
GetDHtmlDocument(&pDocument);
pDocument->get\_body(&pElement);
pElement->get\_offsetHeight(&nHeight);
// get client to real window height difference
LONG nHeightDiff;
CRect rectClient;
GetClientRect(&rectClient);
CRect rectWindow;
GetWindowRect(&rectWindow);
nHeightDiff = rectWindow.Height() - rectClient.Height();
// set height to fit body
SetWindowPos(NULL, 0, 0, rectWindow.Width(), nHeight+nHeightDiff, SWP\_NOMOVE | SWP\_NOZORDER);
}
Of course you'll also need declaration in your h:
virtual void OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl);
Nux