Example #1
0
LYRICSEARCH* LyricSearchInit(const MAINWND* main_wnd)
{
	HRSRC hsrc = FindResource(main_wnd->inst, MAKEINTRESOURCE(IDD_DIALOG_LYRICSEARCH), RT_DIALOG);
	if (hsrc == NULL)
		return NULL;

	HGLOBAL htemp = LoadResource(main_wnd->inst, hsrc);
	if (htemp == NULL)
		return NULL;

	LPCDLGTEMPLATE dialog = (LPCDLGTEMPLATE)LockResource(htemp);	
	lyric_search.hWnd = CreateDialogIndirect(main_wnd->inst, dialog, main_wnd->hWnd, LyricSearchProc);

	UnlockResource(htemp);
	FreeResource(htemp);
		
	lyric_search.httpreq.resolveTimeout = 10000;
	lyric_search.httpreq.connectTimeout = 10000;
	lyric_search.httpreq.sendTimeout = 10000;
	lyric_search.httpreq.receiveTimeout = 20000;
	lyric_search.exit = CreateEvent(NULL, FALSE, FALSE, NULL);
	lyric_search.thread = CreateThread(NULL, 0, LyricSearchThread, &lyric_search, 0, &lyric_search.thread_id);
	
	return &lyric_search;
}
Example #2
0
// horrible or what?
static void getbaseunits (int fullscreen)
{
	multx = multy = 100;
	struct newresource *nr, *nr2;
	HWND hwnd;
	nr = getresource (IDD_PANEL);
	if (!nr) {
		write_log (_T("getbaseunits fail!\n"));
		abort();
	}
	nr2 = scaleresource2(nr, NULL, -1, 0, 0);
	hwnd = CreateDialogIndirect (nr2->inst, nr2->resource, NULL, TestProc);
	if (hwnd) {
		DestroyWindow (hwnd);
	} else {
		baserect.left = baserect.top = 0;
		baserect.right = 800;
		baserect.bottom = 600;
		baseclientrect.left = baseclientrect.top = 0;
		baseclientrect.right = 800;
		baseclientrect.bottom = 600;
	}
	freescaleresource (nr2);
	freescaleresource (nr);
	basewidth = baserect.right - baserect.left;
	baseheight = baserect.bottom - baserect.top;
	baseclientwidth = baseclientrect.right - baseclientrect.left;
	baseclientheight = baseclientrect.bottom - baseclientrect.top;
	baseborderwidth = basewidth - baseclientwidth;
	baseborderheight = baseheight - baseclientheight;

	write_log (_T("GUIBase %dx%d (%dx%d)\n"), basewidth, baseheight, baseunitx, baseunity);
}
Example #3
0
void
init_window (HINSTANCE hInstance, int win_no, int nCmdShow)
{
    int w = win_no;

    Resize_Data* rd = &globals.win[w].rd;

    globals.win[w].hwin = CreateDialogIndirect (hInstance,
		    dialog_template,
		    (HWND) NULL,
		    dialog_callback);
    ShowWindow (globals.win[w].hwin, nCmdShow);
    UpdateWindow (globals.win[w].hwin);
    ise_resize_init (rd, globals.win[w].hwin);
    ise_resize_add (rd, IDC_PICTURE_WINDOW, BIND_TOP | BIND_BOT | BIND_RIGHT | BIND_LEFT);
    ise_resize_add (rd, IDC_SLIDER_BOT, BIND_TOP | BIND_BOT | BIND_LEFT);
    ise_resize_add (rd, IDC_SLIDER_TOP, BIND_TOP | BIND_BOT | BIND_LEFT);
    ise_resize_freeze (rd);
    globals.win[w].hpwin = GetDlgItem (globals.win[w].hwin, IDC_PICTURE_WINDOW);
    globals.win[w].hdc = GetDC(globals.win[w].hwin);
    globals.win[w].hpdc = GetDC(globals.win[w].hpwin);
    globals.win[w].is_zoomed;
    globals.win[w].zoomx = 1.0;
    globals.win[w].zoomy = 1.0;
    globals.win[w].panx = 0.0;
    globals.win[w].pany = 0.0;
    globals.win[w].findtrack_overlay_flag = 0;
    globals.win[w].findtrack_overlay_x = 0.0;
    globals.win[w].findtrack_overlay_y = 0.0;
}
Example #4
0
    STDMETHODIMP MyPropertyPage::Activate(HWND hParent, LPCRECT pRect, BOOL bModal)
    {
        CheckPointer(pRect, E_POINTER);

        m_hWindow = CreateDialogIndirect(GetModuleHandle(nullptr), (LPCDLGTEMPLATE)m_dialogData.data(), hParent, nullptr);

        return (m_hWindow != NULL) ? S_OK : E_UNEXPECTED;
    }
Example #5
0
HWND FBACreateDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc)
{
	// Try to load the translated dialog
	if (bLocalisationActive && hInstance == hAppInst && (unsigned int)lpTemplate < nMaxResources && FBAResourceInfo[(unsigned int)lpTemplate].pResourceTranslation) {
		return CreateDialogIndirect(hInstance, (LPCDLGTEMPLATE)FBAResourceInfo[(unsigned int)lpTemplate].pResourceTranslation, hWndParent, lpDialogFunc);
	}

	// Localisation disabled or couldn't lock resource, so use normal function
	return CreateDialog(hInstance, lpTemplate, hWndParent, lpDialogFunc);
}
Example #6
0
// Creates a dummy dialog that is used for converting units
HWND CDialogTemplate::CreateDummyDialog() {
	DWORD dwTemp;
	BYTE* pbDlg = Save(dwTemp);
	HWND hDlg = CreateDialogIndirect(GetModuleHandle(0), (DLGTEMPLATE*)pbDlg, 0, 0);
	delete [] pbDlg;
	if (!hDlg)
		throw runtime_error("Can't create dialog from template!");

	return hDlg;
}
Example #7
0
// CFG_OnSelChanged - processes the TCN_SELCHANGE notification. 
// hwndDlg - handle to the parent dialog box. 
VOID WINAPI CFG_OnSelChanged(HWND hwndDlg) 
{ 
	 DLGHDR *pHdr = (DLGHDR *) GetWindowLong( hwndDlg, GWLP_USERDATA); 
		 
	 if(pHdr==NULL)
		 return;

	HTREEITEM hTreeItem = TreeView_GetSelection(pHdr->hwndTab);
	
	TVITEM tvitem;
	memset(&tvitem,0,sizeof(TVITEM));
	tvitem.hItem = hTreeItem;
	tvitem.mask = TVIF_PARAM | TVIF_TEXT;

	TreeView_GetItem(g_hwndTree, &tvitem );

	UINT iSel = (UINT)tvitem.lParam;

	if((UINT)g_currSelCfg==iSel)
		return;

	if(iSel==-1)
		iSel = 0;
	if(iSel==GAME_CFG_INDEX)
		return;
	g_currSelCfg = iSel ;

	if(iSel>GAME_CFG_INDEX)
		iSel--;

    // Destroy the current child dialog box, if any. 
    if (pHdr->hwndDisplay != NULL) 
        DestroyWindow(pHdr->hwndDisplay); 
 
	if(iSel>=GAME_CFG_INDEX+gm.GamesInfo.size()) 
		return;
	else if(iSel>GAME_CFG_INDEX)
		iSel = GAME_CFG_INDEX;
	

	if(pHdr->apRes[iSel]==NULL)
		return;

    // Create the new child dialog box. 
    pHdr->hwndDisplay = CreateDialogIndirect(g_hInst, pHdr->apRes[iSel], hwndDlg, (DLGPROC)CFG_OnSelChangedProc); 

	ShowWindow(pHdr->hwndDisplay,SW_SHOWNORMAL);
} 
Example #8
0
static void WriteDialog( HWND parent, HANDLE csv, int id, HINSTANCE hInstance, const DLGTEMPLATE *pTemplate, CSettingsParser &parser )
{
	HWND dlg=CreateDialogIndirect(hInstance,pTemplate,parent,DefaultDlgProc);
	if (dlg)
	{
		wchar_t text[256];
		GetWindowText(dlg,text,_countof(text));
		if (*text)
			WriteString(csv,id,text,Strlen(text),parser,0);
		for (HWND child=GetWindow(dlg,GW_CHILD);child;child=GetWindow(child,GW_HWNDNEXT))
		{
			GetWindowText(child,text,_countof(text));
			if (*text)
				WriteString(csv,id,text,Strlen(text),parser,(int)GetWindowLong(child,GWL_ID));
		}
		DestroyWindow(dlg);
	}
}
Example #9
0
void httpInit() 
{
	WORD wVersionRequested = MAKEWORD(1, 0);
	WSADATA wsaData;

#ifdef INCLUDE_STATUS_WINDOW
    HRSRC dialogResource;
#endif

	iniFilename[0] = 0;

	if ( WSAStartup( wVersionRequested, &wsaData) != 0 )
	{
		MessageBox(hwndPlayer, "Error Initializing Windows Sockets", "Vorbis Plugin Init Error", MB_OK);
	}

	lastUrlChecked[0] = 0;
	proxy[0] = 0;

#ifdef INCLUDE_STATUS_WINDOW
	dialogResource = FindResource(	GetModuleHandle( "in_mpg123.dll" ),
									MAKEINTRESOURCE( IDD_MESSAGE ),
									RT_DIALOG );

	if ( dialogResource )
	{
		HGLOBAL hGlobal = LoadResource(GetModuleHandle( "in_mpg123.dll" ), dialogResource );

		if ( hGlobal )
		{
			hwndMessage = CreateDialogIndirect((HINSTANCE) GetWindowLong(hwndPlayer, GWL_HINSTANCE), LockResource(hGlobal), hwndPlayer, NullDialogProc);

			if (hwndMessage)
			{
				hwndText = GetDlgItem(hwndMessage, IDC_TEXT);
				hwndProgress = GetDlgItem(hwndMessage, IDC_PROGRESS);

//				SetTimer(hwndMessage, 1, 20, NULL);
			}
		}
	}
#endif
}
Example #10
0
HWND far pascal zCreateDialogIndirect( HANDLE pp1, LPSTR pp2, HWND pp3, FARPROC pp4 )
{
    HWND r;
    FARPROC fp ;

    SaveRegs();

    fp = pp4 ;

    /*
        Changed 6-12-91 by BobK- if WNDPROC is null, don't hook it- it's
        already hooked at a higher level!
    */
    if  (pp4) {
      pp4 = (FARPROC)HookAdd( (void far *)DlgMesgProc,
            (void far *)fp );
    }

    /*
    ** Log IN Parameters (No Create/Destroy Checking Yet!)
    */
    LogIn( (LPSTR)"APICALL:CreateDialogIndirect HANDLE+LPSTR+HWND+FARPROC+",
        pp1, pp2, pp3, pp4 );

    /*
    ** Call the API!
    */
    RestoreRegs();
    GrovelDS();
    r = CreateDialogIndirect(pp1,pp2,pp3,pp4);
    UnGrovelDS();
    SaveRegs();
    /*
    ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!)
    */
    LogOut( (LPSTR)"APIRET:CreateDialogIndirect HWND+++++",
        r, (short)0, (short)0, (short)0, (short)0 );

    RestoreRegs();
    return( r );
}
Example #11
0
static int createAboutBox( HINSTANCE hInstance, HWND hwnd )
{
    WORD*	p, *pdlgtemplate;
    int		nchar;
    DWORD	lStyle;
    HWND	hwndReturn;
    /*
     *	Allocate some memory to play with
     */
    pdlgtemplate = p = ( PWORD ) LocalAlloc( LPTR, 1000 );
    /*
     *	Start to fill in the dlgtemplate information.  addressing by WORDs
     */
    lStyle = WS_DLGFRAME | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | DS_SETFONT;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;          /* LOWORD (lExtendedStyle) */
    *p++ = 0;          /* HIWORD (lExtendedStyle) */
    *p++ = 7;          /* Number Of Items	*/
    *p++ = 210;        /* x */
    *p++ = 10;         /* y */
    *p++ = 200;        /* cx */
    *p++ = 100;        /* cy */
    *p++ = 0;          /* Menu */
    *p++ = 0;          /* Class */
    /*
     *	Copy the title of the dialog
     */
    nchar = nCopyAnsiToWideChar( p, "GoAhead WebServer" );
    p += nchar;
    /*
     *	Font information because of DS_SETFONT
     */
    *p++ = 11;     /* point size */
    nchar = nCopyAnsiToWideChar( p, T( "Arial Bold" ) );
    p += nchar;
    /*
     *	Make sure the first item starts on a DWORD boundary
     */
    p = lpwAlign( p );
    /*
     *	Now start with the first item (Product Identifier)
     */
    lStyle = SS_CENTER | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;			/* LOWORD (lExtendedStyle) */
    *p++ = 0;			/* HIWORD (lExtendedStyle) */
    *p++ = 10;			/* x */
    *p++ = 10;			/* y  */
    *p++ = 180;			/* cx */
    *p++ = 15;			/* cy */
    *p++ = 1;			/* ID */
    /*
     *	Fill in class i.d., this time by name
     */
    nchar = nCopyAnsiToWideChar( p, TEXT( "STATIC" ) );
    p += nchar;
    /*
     *	Copy the text of the first item
     */
    nchar = nCopyAnsiToWideChar( p,
                                 TEXT( "GoAhead WebServer 2.1.8" ) );
    p += nchar;
    /*
     *	Advance pointer over nExtraStuff WORD
     */
    *p++ = 0;
    /*
     *	Make sure the next item starts on a DWORD boundary
     */
    p = lpwAlign( p );
    /*
     *	Next, the Copyright Notice.
     */
    lStyle = SS_CENTER | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;			/* LOWORD (lExtendedStyle) */
    *p++ = 0;			/* HIWORD (lExtendedStyle) */
    *p++ = 10;			/* x */
    *p++ = 30;			/* y  */
    *p++ = 180;			/* cx */
    *p++ = 15;			/* cy */
    *p++ = 1;			/* ID */
    /*
     *	Fill in class i.d. by name
     */
    nchar = nCopyAnsiToWideChar( p, TEXT( "STATIC" ) );
    p += nchar;
    /*
     *	Copy the text of the item
     */
    nchar = nCopyAnsiToWideChar( p, GOAHEAD_COPYRIGHT );
    p += nchar;
    /*
     *	Advance pointer over nExtraStuff WORD
     */
    *p++ = 0;
    /*
     *	Make sure the next item starts on a DWORD boundary
     */
    p = lpwAlign( p );
    /*
     *	Add third item ("Version:")
     */
    lStyle = SS_RIGHT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;
    *p++ = 0;
    *p++ = 28;
    *p++ = 50;
    *p++ = 70;
    *p++ = 10;
    *p++ = 1;
    nchar = nCopyAnsiToWideChar( p, T( "STATIC" ) );
    p += nchar;
    nchar = nCopyAnsiToWideChar( p, T( "Version:" ) );
    p += nchar;
    *p++ = 0;
    /*
     *	Add fourth Item (IDC_VERSION)
     */
    p = lpwAlign( p );
    lStyle = SS_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;
    *p++ = 0;
    *p++ = 102;
    *p++ = 50;
    *p++ = 70;
    *p++ = 10;
    *p++ = IDC_VERSION;
    nchar = nCopyAnsiToWideChar( p, T( "STATIC" ) );
    p += nchar;
    nchar = nCopyAnsiToWideChar( p, T( "version" ) );
    p += nchar;
    *p++ = 0;
    /*
     *	Add fifth item ("Build Date:")
     */
    p = lpwAlign( p );
    lStyle = SS_RIGHT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;
    *p++ = 0;
    *p++ = 28;
    *p++ = 65;
    *p++ = 70;
    *p++ = 10;
    *p++ = 1;
    nchar = nCopyAnsiToWideChar( p, T( "STATIC" ) );
    p += nchar;
    nchar = nCopyAnsiToWideChar( p, T( "Build Date:" ) );
    p += nchar;
    *p++ = 0;
    /*
     *	Add sixth item (IDC_BUILDDATE)
     */
    p = lpwAlign( p );
    lStyle = SS_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;
    *p++ = 0;
    *p++ = 102;
    *p++ = 65;
    *p++ = 70;
    *p++ = 10;
    *p++ = IDC_BUILDDATE;
    nchar = nCopyAnsiToWideChar( p, T( "STATIC" ) );
    p += nchar;
    nchar = nCopyAnsiToWideChar( p, T( "Build Date" ) );
    p += nchar;
    *p++ = 0;
    /*
     *	Add seventh item (IDOK)
     */
    p = lpwAlign( p );
    lStyle = BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
    *p++ = LOWORD( lStyle );
    *p++ = HIWORD( lStyle );
    *p++ = 0;
    *p++ = 0;
    *p++ = 80;
    *p++ = 80;
    *p++ = 40;
    *p++ = 10;
    *p++ = IDOK;
    nchar = nCopyAnsiToWideChar( p, T( "BUTTON" ) );
    p += nchar;
    nchar = nCopyAnsiToWideChar( p, T( "OK" ) );
    p += nchar;
    *p++ = 0;
    hwndReturn = CreateDialogIndirect( hInstance,
                                       ( LPDLGTEMPLATE ) pdlgtemplate, hwnd, ( DLGPROC ) websAboutProc );
    LocalFree( LocalHandle( pdlgtemplate ) );
    return 0;
}
Example #12
0
// Here you can process the Npp Messages 
// I will make the messages accessible little by little, according to the need of plugin development.
// Please let me know if you need to access to some messages :
// http://sourceforge.net/forum/forum.php?forum_id=482781
//
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch (Message){
		case WM_CREATE:
		hInst = GetModuleHandle(NULL);

		//Create PopupMenu Dynamically
		HGLOBAL hgbl;
		LPDLGTEMPLATE lpdt;
		LPWORD lpw;
		hwndEdit = nppData._scintillaMainHandle;
		hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);

		lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);

		// Define a dialog box.

		lpdt->style = WS_POPUP | WS_BORDER ;
		lpdt->cdit = 0;         // Number of controls = 0
		lpdt->x  = 10;  lpdt->y  = 10;
		lpdt->cx = 100; lpdt->cy = 100;

		lpw = (LPWORD)(lpdt + 1);
		*lpw++ = 0;             // No menu
		*lpw++ = 0;             // Predefined dialog box class (by default)

		GlobalUnlock(hgbl);
		hwndPopupMenu = CreateDialogIndirect(hInst,
			(LPDLGTEMPLATE)hgbl,
			nppData._nppHandle,
			(DLGPROC)PopupMenuProc);
		GlobalFree(hgbl);
		
		//End PopupMenuDialog

		hfontCurrent = MyCreateFont(nppData._nppHandle, 10,L"Zawgyi-One");
		EditProc =(WNDPROC)GetWindowLongW(nppData._scintillaMainHandle, GWL_WNDPROC);
		SetWindowLong(nppData._scintillaMainHandle, GWL_WNDPROC, (long)SubEditProc);
		hMenu = GetMenu(nppData._nppHandle);
		CheckMenuItem(hMenu,funcItem[1]._cmdID,MF_BYCOMMAND|MF_CHECKED);//Check Disable Menu
		break;
		case WM_MOVE:
			//move menu along with the main window
			if(IsWindowVisible(hwndPopupMenu))
			{
				RECT rctWinMain;
				GetWindowRect(hwndEdit,&rctWinMain);

				int height=(burmese.menuLength>MROW?10:burmese.menuLength)*MHEIGHT+MHEIGHT+10;
				int width=((burmese.menuLength/MROW)+1)*MWIDTH;

				MoveWindow (hwndPopupMenu,
					rctWinMain.left + pointEditCursor.x + 10,
					rctWinMain.top + pointEditCursor.y + 20 ,
					width,
					height,
					TRUE) ;
			}
	        
			break;
		}
	return true;
}
Example #13
0
int WINAPI ExtMsgBox (HWND hWndPar, const char *psText, const char *psTitle,	UINT uStyle, long lHelp, const char *psButtons, LOOPPROC lpFn)
{
volatile int iRtn=-1;
MBDATA mbd;

	ASSERT (AfxGetInstanceHandle () != NULL);

	memset (&mbd, 0, sizeof (mbd));
	mbd.piRtn = &iRtn;

	// Lets build up the button string
	CString sBtn;
	UINT uTmp = uStyle & MB_TYPEMASK;
	if ((uTmp == MB_OK) && (psButtons == NULL))
		sBtn += sOk;
	else
		if (uTmp == MB_OKCANCEL)
			sBtn += sOC;
		else
			if (uTmp == MB_ABORTRETRYIGNORE)
				sBtn += sARI;
			else
				if (uTmp == MB_YESNOCANCEL)
					sBtn += sYNC;
				else
					if (uTmp == MB_YESNO)
						sBtn += sYN;
					else
						if (uTmp == MB_RETRYCANCEL)
							sBtn += sRC;
	if ((psButtons != NULL) && (*psButtons != 0))
		{
		sBtn += psButtons;
		if (sBtn[sBtn.GetLength() - 1] != '\n')
			sBtn += "\n";
		}
	if (lHelp != -1)
		sBtn += sHelp;
	else
		while (sBtn[sBtn.GetLength() - 1] == '\n')
			sBtn.ReleaseBuffer (sBtn.GetLength() - 1);

	// lets get the text size
	//   get the font size
	HDC hDc = GetDC (NULL);
	SelectObject (hDc, GetStockObject (SYSTEM_FONT));
	TEXTMETRIC tm;
	GetTextMetrics (hDc, &tm);
	int iWid = GetSystemMetrics (SM_CXFULLSCREEN);
	CRect rText (0,0,iWid,0), rBtn (0,0,iWid,0);
	DrawText (hDc, psText, -1, &rText, MB_DT_FLAGS | DT_CALCRECT);
	DrawText (hDc, sBtn, -1, &rBtn, DT_LEFT | DT_CALCRECT);
	ReleaseDC (NULL, hDc);

	// Determine the spacing between things
	int iYxtra = tm.tmHeight;
	int iXxtra = tm.tmMaxCharWidth;
	int iBtnHt = tm.tmHeight * 2;
	int iXbtnSpc = tm.tmAveCharWidth * 4;
	int iBtnWid = rBtn.right + tm.tmMaxCharWidth * 2;

	// set rText location
	rText.right += tm.tmMaxCharWidth;
	rText += CPoint (iXxtra, iYxtra);

	// determine the window size
	CRect rWin (rText);
	rWin.left = rWin.top = 0;
	rWin.right += iXxtra;
	rWin.bottom += iYxtra;

	// Add in icons
	if (uStyle & MB_ICONMASK)
	  {
		int iXshft = GetSystemMetrics (SM_CXICON) + iXxtra;
		rText += CPoint (iXshft, 0);
		rWin.right += iXshft;
		rWin.bottom = __max (rWin.bottom,
												GetSystemMetrics (SM_CYICON) + iYxtra * 2);
	  }

	// get the number of buttons
	int iNumBtns=1;
	const char * pBufOn = sBtn.GetBuffer (0);
	while ((pBufOn = strchr (pBufOn+1, '\n')) != NULL)
		iNumBtns++;
	ASSERT (iNumBtns <= 253);
	if (iNumBtns > 253)
		return (-2);

	// add in space for buttons (icon goes above buttons)
	rWin.bottom += iBtnHt + iYxtra;
	int iBtnLen = iNumBtns * (iBtnWid + iXbtnSpc) + iXbtnSpc;
	rWin.right = __max (iBtnLen, rWin.right);

	// create the dlg struct
	CGlobal cgDlg (sizeof (DLGBOXHDR) + strlen (psTitle) + sizeof (DLGCTRLDATA) + strlen (psText),
									GPTR);
	DLGBOXHDR FAR *pDbh = (DLGBOXHDR FAR *) cgDlg.GetPtr ();	// 4/26/96 BobP
	if (pDbh == NULL)
		return (-3);
	pDbh->lStyle = WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE;
	if (uStyle & MB_SYSTEMMODAL)
		pDbh->lStyle |=	DS_SYSMODAL;
	pDbh->cdit = (WORD) (iNumBtns + 1);
	pDbh->x = (WORD) ((rWin.left * 4) / tm.tmAveCharWidth);
	pDbh->y = (WORD) ((rWin.top * 8) / tm.tmHeight);
	pDbh->cx = (WORD) ((rWin.Width () * 4) / tm.tmAveCharWidth);
	pDbh->cy = (WORD) ((rWin.Height () * 8) / tm.tmHeight);
	strcpy (pDbh->szCaption, psTitle);

	// Add the text window
	// center it in its available space (rText.right - rWin.right)
	DLGCTRLDATA FAR *pDcd = (DLGCTRLDATA FAR *) (pDbh->szCaption + strlen (psTitle) + 1);
	rText += CPoint ((rWin.Width () - rText.right) / 2, 0);
	pDcd->x = (WORD) ((rText.left * 4) / tm.tmAveCharWidth);
	pDcd->y = (WORD) ((rText.top * 8) / tm.tmHeight);
	pDcd->cx = (WORD) ((rText.Width () * 4) / tm.tmAveCharWidth);
	pDcd->cy = (WORD) ((rText.Height () * 8) / tm.tmHeight);
	pDcd->wID = (WORD) -1;
	pDcd->lStyle = WS_CHILD | SS_LEFT | SS_NOPREFIX | WS_VISIBLE;
	pDcd->bCtrlClass = 0x82;
	strcpy (pDcd->szText, psText);
	pDcd->szText[strlen (psText) + 1] = 0;		// bEnd

	// add the icon data
	if (uStyle & MB_ICONMASK)
	  {
		LPCSTR id = IDI_ASTERISK;
		switch (uStyle & MB_ICONMASK)
			{
			case MB_ICONHAND :
				id = IDI_HAND;
				break;
			case MB_ICONQUESTION :
				id = IDI_QUESTION;
				break;
			case MB_ICONEXCLAMATION :
				id = IDI_EXCLAMATION;
				break;
			}
		if ((mbd.hIcon = LoadIcon (NULL, id)) != NULL)
			{
			mbd.iXicon = iXxtra;
			mbd.iYicon = iYxtra;
			}
	  }

	// add the Help... stuff
	if ((mbd.lHelp = lHelp) == -1)
		mbd.wHelpBtn = (WORD) -2;
	else
		mbd.wHelpBtn = (WORD) (iNumBtns - 1 + 10);

	// get the default button number
	int iDefButton = 0;
	switch (uStyle & MB_DEFMASK)
		{
		case MB_DEFBUTTON2 :
			iDefButton = 1;
			break;
		case MB_DEFBUTTON3 :
			iDefButton = 2;
			break;
		}

	// lets make the buttons
	pBufOn = sBtn.GetBuffer (0);
	int iBtnOn = 0;
	int iAddBtn =  iBtnWid + iXbtnSpc;
	int iXbtn = (rWin.Width() - iNumBtns * iAddBtn + iXbtnSpc) / 2;
	int iYbtn = rText.bottom + iYxtra;

	while (*pBufOn != 0)
	  {
		const char *pEnd = strchr (pBufOn, '\n');
		if (pEnd == NULL)
			pEnd = pBufOn + strlen (pBufOn);
		int iLen = pEnd - pBufOn;

		// set up the dialog template
		DWORD dwOff = cgDlg.Size ();
		cgDlg.ReAlloc (dwOff + sizeof (DLGCTRLDATA) + iLen);
		if ((pDcd = (DLGCTRLDATA FAR *) cgDlg.GetPtr (dwOff)) == NULL)	// 4/26/96 BobP
			return (-3);

		pDcd->x = (WORD) ((iXbtn * 4) / tm.tmAveCharWidth);
		pDcd->y = (WORD) ((iYbtn * 8) / tm.tmHeight);
		pDcd->cx = (WORD) ((iBtnWid * 4) / tm.tmAveCharWidth);
		pDcd->cy = (WORD) ((iBtnHt * 8) / tm.tmHeight);
		pDcd->lStyle = WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP;
		if (iBtnOn == iDefButton)
			pDcd->lStyle |= BS_DEFPUSHBUTTON;
		pDcd->bCtrlClass = 0x80;
		memcpy (pDcd->szText, pBufOn, iLen);
		pDcd->szText[iLen] = 0;
		pDcd->szText[iLen+1] = 0;		// bEnd

		// get the button return
		pDcd->wID = (WORD) (iBtnOn + 10);
		if (stricmp (pDcd->szText, "ok") == 0)
			pDcd->wID = IDOK;
		else
			if (stricmp (pDcd->szText, "cancel") == 0)
				pDcd->wID = IDCANCEL;
			else
				if (stricmp (pDcd->szText, "&yes") == 0)
					pDcd->wID = IDYES;
				else
					if (stricmp (pDcd->szText, "&no") == 0)
						pDcd->wID = IDNO;
					else
						if (stricmp (pDcd->szText, "&abort") == 0)
							pDcd->wID = IDABORT;
						else
							if (stricmp (pDcd->szText, "&retry") == 0)
								pDcd->wID = IDRETRY;
							else
								if (stricmp (pDcd->szText, "&ignore") == 0)
									pDcd->wID = IDIGNORE;

		iBtnOn++;
		iXbtn += iAddBtn;
		pBufOn = *pEnd == 0 ? pEnd : pEnd + 1;
		}

	// add 32 bytes of 0 (or CreateDialogInd GP faults)
	DWORD dwOff = cgDlg.Size ();
	cgDlg.ReAlloc (dwOff + 32);
	void FAR *pBuf;
	if ((pBuf = cgDlg.GetPtr (dwOff)) != NULL)						// 4/26/96 BobP
		memset (pBuf, 0, 32);

	HWND hDlg = CreateDialogIndirect (AfxGetInstanceHandle (),		// 4/26/96 BobP
					(const DLGTEMPLATE *) cgDlg.GetPtr (), hWndPar, MsgBoxDlgProc);
	if (hDlg == NULL)
		{
		ASSERT (FALSE);
		return (MessageBox (hWndPar, psText, psTitle, uStyle));
		}

	SetWindowLong (hDlg, DWL_USER, (LONG) (void FAR *) (&mbd));
	cgDlg.Free ();

	// disable parent
	if ((uStyle & (MB_SYSTEMMODAL | MB_TASKMODAL)) == 0)
		{
		HWND hParOn = hWndPar;
		while (hParOn != NULL)
			{
			SetProp (hParOn, sApplProp, (HANDLE) IsWindowEnabled (hParOn));
			EnableWindow (hParOn, FALSE);
			hParOn = GetParent (hParOn);
			}
		}

	if (uStyle & MB_TASKMODAL)
		EnableAllWindows (hDlg, FALSE);

	// get this puppy up
  EnableWindow (hDlg, TRUE);
  ShowWindow (hDlg, SW_SHOW);
	SetForegroundWindow (hDlg);

	// if we have an icon we need to invalidate it's area cause &mbd
	//   was set AFTER the WM_PAINT
	if (mbd.hIcon != 0)
	  {
	  CRect rIcon (mbd.iXicon, mbd.iYicon,
	  				mbd.iXicon + GetSystemMetrics (SM_CXICON) + 1,
	  				mbd.iYicon + GetSystemMetrics (SM_CYICON) + 1);
		InvalidateRect (hDlg, &rIcon, FALSE);
	  }

	while (iRtn < 0)
		{
		MSG Msg;
		if (PeekMessage (&Msg, NULL, 0, 0, PM_NOREMOVE))
			{
			if (Msg.message == WM_QUIT)
				{
				iRtn = -1;
				break;
				}

			// process the message
			if (PeekMessage (&Msg, NULL, 0, 0, PM_REMOVE))
				if ((hDlgBox == NULL) || (! IsDialogMessage (hDlgBox, &Msg)))
					{
					TranslateMessage (&Msg);
					DispatchMessage (&Msg);
					}
			}

		// call the idle processing
		if ((lpFn != NULL) && (iRtn < 0))
			iRtn = (*lpFn) ();
		}

	// enable parent
	if ((uStyle & (MB_SYSTEMMODAL | MB_TASKMODAL)) == 0)
		{
		HWND hParOn = hWndPar;
		while (hParOn != NULL)
			{
			if ((BOOL) GetProp (hParOn, sApplProp) == TRUE)
				EnableWindow (hParOn, TRUE);
			RemoveProp (hParOn, sApplProp);
			hParOn = GetParent (hParOn);
			}
		}

	if (uStyle & MB_TASKMODAL)
		EnableAllWindows (hDlg, TRUE);

	DestroyWindow (hDlg);
	return (iRtn);
}