Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
LRESULT CDialogbox::InitDialog(HWND hwndDlg, HWND hwndControl, LPARAM lParam)
//Handles the WM_INITDIALOG message.
{
LOCK(&m_csVars);
HWND hwndOwner=NULL;
HICON hIcon=NULL;
RECT rcOwner={0}, rcDlg={0};
VARIANT_BOOL bResult=VARIANT_TRUE;
m_hWnd = hwndDlg; //This one we must save for future messages.
m_sWndMap[hwndDlg]=this; //Store in the window map, so we can find the object in future messages as well.
//Set title:
if(m_lcTitle.Length()>0)
SetWindowText(m_hWnd, m_lcTitle);
else {
//If a title id was not specified, load the title text into the member variable:
m_lcTitle.Reserve(GetWindowTextLength(m_hWnd)+1);
GetWindowText(m_hWnd, m_lcTitle.GetBuffer(), m_lcTitle.BufferSize());
}
//Set small icon:
if(m_nSmallIcon>0 && (hIcon=m_pRes->LoadResIcon(m_nSmallIcon, lsdIcon_Small))!=NULL) SendMessage(m_hWnd, WM_SETICON, static_cast<WPARAM>(ICON_SMALL), reinterpret_cast<LPARAM>(hIcon));
//Set large icon:
if(m_nLargeIcon>0 && (hIcon=m_pRes->LoadResIcon(m_nLargeIcon, lsdIcon_Big))!=NULL) SendMessage(m_hWnd, WM_SETICON, static_cast<WPARAM>(ICON_BIG), reinterpret_cast<LPARAM>(hIcon));
//Add extra windowstyles:
if(m_nStyles>0) SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE)|m_nStyles);
if(m_nExtraStyles>0) SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE)|m_nExtraStyles);
//Fire the event:
Fire_Initialize(m_enmPosition, m_nXPos, m_nYPos, &bResult);
//If necessary, position the dialogbox:
switch(m_enmPosition) {
case lsdResDlg_CenterOwner:
if((hwndOwner=GetParent(m_hWnd))==NULL) hwndOwner=GetDesktopWindow();
case lsdResDlg_CenterScreen:
if(hwndOwner==NULL) hwndOwner=GetDesktopWindow();
GetWindowRect(hwndOwner, &rcOwner);
GetWindowRect(m_hWnd, &rcDlg);
SetWindowPos(m_hWnd, HWND_TOP, rcOwner.left+(((rcOwner.right-rcOwner.left)-(rcDlg.right-rcDlg.left))/2), rcOwner.top+(((rcOwner.bottom-rcOwner.top)-(rcDlg.bottom-rcDlg.top))/2), 0, 0, SWP_NOSIZE);
break;
case lsdResDlg_Specific:
SetWindowPos(m_hWnd, HWND_TOP, m_nXPos, m_nYPos, 0, 0, SWP_NOSIZE);
break;
}
//And to be absolutely sure it will ALWAYS be entirely visible:
SendMessage(m_hWnd, DM_REPOSITION, NULL, NULL);
UNLOCK(&m_csVars);
return bResult==VARIANT_TRUE;
}