// Given the current dialog item and whether this is an extended dialog
	// return a pointer to the next DLGITEMTEMPLATE*
	static DLGITEMTEMPLATE* FindNextDlgItem(DLGITEMTEMPLATE* pItem, BOOL bDialogEx)
	{
		WORD* pw;

		// First skip fixed size header information, size of which depends
		// if this is a DLGITEMTEMPLATE or DLGITEMTEMPLATEEX
		if (bDialogEx)
			pw = (WORD*)((DLGITEMTEMPLATEEX*)pItem + 1);
		else
			pw = (WORD*)(pItem + 1);

		if (*pw == 0xFFFF)			// Skip class name ordinal or string
			pw += 2; // (WORDs)
		else
			while (*pw++);

		if (*pw == 0xFFFF)			// Skip title ordinal or string
			pw += 2; // (WORDs)
		else
			while (*pw++);

		WORD cbExtra = *pw++;		// Skip extra data

		// cbExtra includes the size WORD in DIALOG resource.
		if (cbExtra != 0 && !bDialogEx)
			cbExtra -= 2;

		// Dword-align and return
		return (DLGITEMTEMPLATE*)(lpwAlign(pw));
	}
	static DLGITEMTEMPLATE* FindFirstDlgItem(const DLGTEMPLATE* pTemplate)
	{
		BOOL bDialogEx = IsDialogEx(pTemplate);

		WORD* pw;
		DWORD dwStyle;
		if (bDialogEx)
		{
			pw = (WORD*)((DLGTEMPLATEEX*)pTemplate + 1);
			dwStyle = ((DLGTEMPLATEEX*)pTemplate)->style;
		}
		else
		{
			pw = (WORD*)(pTemplate + 1);
			dwStyle = pTemplate->style;
		}

		// Check for presence of menu and skip it if there is one
		// 0x0000 means there is no menu
		// 0xFFFF means there is a menu ID following
		// Everything else means that this is a NULL terminated Unicode string
		// which identifies the menu resource
		if (*pw == 0xFFFF)
			pw += 2;				// Has menu ID, so skip 2 words
		else
			while (*pw++);			// Either No menu, or string, skip past terminating NULL

		// Check for presence of class name string
		// 0x0000 means "Use system dialog class name"
		// 0xFFFF means there is a window class (atom) specified
		// Everything else means that this is a NULL terminated Unicode string
		// which identifies the menu resource
		if (*pw == 0xFFFF)
			pw += 2;				// Has class atom, so skip 2 words
		else
			while (*pw++);			// Either No class, or string, skip past terminating NULL

		// Skip caption string
		while (*pw++);

		// If we have DS_SETFONT, there is extra font information which we must now skip
		if (dwStyle & DS_SETFONT)
		{
			// If it is a regular DLGTEMPLATE there is only a short for the point size
			// and a string specifying the font (typefacename).  If this is a DLGTEMPLATEEX
			// then there is also the font weight, and bItalic which must be skipped
			if (bDialogEx)
				pw += 3;			// Skip font size, weight, (italic, charset)
			else
				pw += 1;			// Skip font size
			while (*pw++);			// Skip typeface name
		}

		// Dword-align and return
		return (DLGITEMTEMPLATE*)(lpwAlign(pw));
	}
//-----------------------------------------------------------------------------------------------------------------------------------------
//  Create the Dialog Box to get input from the user
//-----------------------------------------------------------------------------------------------------------------------------------------
LRESULT DisplayMiniDumpDialog(HINSTANCE hinst, HWND hwndOwner)
{
   HGLOBAL hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
   if (!hgbl) return -1;

   //-----------------------------------------------------------------
   // Define the dialog box
   //-----------------------------------------------------------------
   LPDLGTEMPLATE lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);
   lpdt->style = WS_POPUP | WS_BORDER | DS_MODALFRAME | WS_CAPTION;
   lpdt->cdit = 3;         // Number of controls
   lpdt->x  = 100;  
   lpdt->y  = 100;
   lpdt->cx = 300; 
   lpdt->cy = 90;

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

   LPWSTR lpwsz = (LPWSTR)lpw;
   S32 nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "MiniDump Crash Report", -1, lpwsz, 50);
   lpw += nchar;

   //-----------------------------------------------------------------
   // Define a static text message
   //-----------------------------------------------------------------
   lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
   LPDLGITEMTEMPLATE lpdit = (LPDLGITEMTEMPLATE)lpw;
   lpdit->x  = 10; 
   lpdit->y  = 10;
   lpdit->cx = 290; 
   lpdit->cy = 10;
   lpdit->id = ID_TEXT;    // Text identifier
   lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;

   lpw = (LPWORD)(lpdit + 1);
   *lpw++ = 0xFFFF;
   *lpw++ = 0x0082;        // Static class

   LPSTR msg = "The program has crashed.  Please describe what was happening:";
   for (lpwsz = (LPWSTR)lpw; *lpwsz++ = (WCHAR)*msg++;);
   lpw = (LPWORD)lpwsz;

   *lpw++ = 0;             // No creation data        

   //-----------------------------------------------------------------
   // Define a DONE button
   //-----------------------------------------------------------------
   lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
   lpdit = (LPDLGITEMTEMPLATE)lpw;
   lpdit->x  = 265; 
   lpdit->y  = 75;
   lpdit->cx = 25; 
   lpdit->cy = 12;
   lpdit->id = ID_DONE;       // OK button identifier
   lpdit->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP;// | BS_DEFPUSHBUTTON;

   lpw = (LPWORD)(lpdit + 1);
   *lpw++ = 0xFFFF;
   *lpw++ = 0x0080;        // Button class

   lpwsz = (LPWSTR)lpw;
   nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "Done", -1, lpwsz, 50);
   lpw += nchar;
   *lpw++ = 0;					// No creation data

   //-----------------------------------------------------------------
   // Define a text entry message
   //-----------------------------------------------------------------
   lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
   lpdit = (LPDLGITEMTEMPLATE)lpw;
   lpdit->x  = 10; 
   lpdit->y  = 22;
   lpdit->cx = 280; 
   lpdit->cy = 50;
   lpdit->id = ID_USERTEXT;    // Text identifier
   lpdit->style = ES_LEFT | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;

   lpw = (LPWORD)(lpdit + 1);
   *lpw++ = 0xFFFF;
   *lpw++ = 0x0081;        // Text edit class

   *lpw++ = 0;             // No creation data



   GlobalUnlock(hgbl); 
   LRESULT ret = DialogBoxIndirect(	hinst, 
      (LPDLGTEMPLATE)hgbl, 
      hwndOwner, 
      (DLGPROC)MiniDumpDialogProc); 
   GlobalFree(hgbl); 
   return ret; 
}
Exemple #4
0
int
wCreateSplash( char *appname, char *appver )
{
	HGLOBAL hgbl;
    LPDLGTEMPLATE lpdt;
	LPWORD lpw;
	LPDLGITEMTEMPLATE lpdit;
	int cxDlgUnit, cyDlgUnit;
	int cx, cy;
	char *pszBuf;
	HBITMAP hBmp;
	BITMAP bmp;
	char logoPath[MAX_PATH];

	/* find the size of a dialog unit */
	cxDlgUnit = LOWORD(GetDialogBaseUnits());
	cyDlgUnit = HIWORD(GetDialogBaseUnits());

	/* load the logo bitmap */
	sprintf( logoPath, "%s\\logo.bmp", wGetAppLibDir());
	hBmp = LoadImage( mswHInst, logoPath, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE );
	if( !hBmp )
		return( 0 );

	/* get info about the loaded logo file */	
	GetObject( hBmp, sizeof(BITMAP), (LPVOID)&bmp );

	/* calculate the size of dialog box */
	cx = (bmp.bmWidth * 4) / cxDlgUnit;			/* start with the size of the bitmap */
	cy = (bmp.bmHeight * 8) / cyDlgUnit + 20;	/* 20 is enough for two lines of text and some room */

	/* allocate memory block for dialog template */
	hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
    if (!hgbl)
		return -1;
    lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);

    /* Define a dialog box. */
    lpdt->style = WS_POPUP | WS_BORDER | WS_VISIBLE | DS_MODALFRAME | DS_CENTER;
    lpdt->cdit = 3;  // number of controls
    lpdt->x  = 0;  lpdt->y  = 0;
    lpdt->cx = cx; lpdt->cy = cy;

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

	/* add the static control for the logo bitmap */
	lpdit = (LPDLGITEMTEMPLATE)lpwAlign(lpw);
	lpdit->x  = 0; lpdit->y  = 0;
    lpdit->cx = (SHORT)((bmp.bmWidth * 4) / cxDlgUnit); 
	lpdit->cy = (SHORT)((bmp.bmHeight * 8) / cyDlgUnit);

    lpdit->id = IDBITMAP;  
    lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;
    lpw = (LPWORD) (lpdit + 1);
    *lpw++ = 0xFFFF;
    *lpw++ = 0x0082;		/* static class */

	lpw  += 1+MultiByteToWideChar (CP_ACP, 0, "Logo should be here...", -1, (LPWSTR)lpw, 50);

	/* add the static control for the program title */
	lpdit = (LPDLGITEMTEMPLATE)lpwAlign(lpw);

	lpdit->x  = 2; lpdit->y  = (short)( 1 + (bmp.bmHeight * 8) / cyDlgUnit );
    lpdit->cx = cx - 2; lpdit->cy = cyDlgUnit;
    lpdit->id = IDAPPNAME;  
    lpdit->style = WS_CHILD | WS_VISIBLE | SS_CENTER;
    lpw = (LPWORD) (lpdit + 1);
    *lpw++ = 0xFFFF;
    *lpw++ = 0x0082;		/* static class */

	/* create the title string */	
	pszBuf = malloc( strlen( appname ) + strlen( appver ) + 2 );
	if( !pszBuf )
		return( 0 );
	sprintf( pszBuf, "%s %s", appname, appver );

	lpw  += 1+MultiByteToWideChar (CP_ACP, 0, pszBuf, -1, (LPWSTR)lpw, 50);

	/* add the static control for the loading message */
	lpdit = (LPDLGITEMTEMPLATE)lpwAlign(lpw);
	lpdit->x  = 2; lpdit->y  = (short)(bmp.bmHeight * 8) / cyDlgUnit  + 10;
    lpdit->cx = cx - 2; lpdit->cy = cyDlgUnit;
    lpdit->id = IDMESSAGE;  
    lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;
    lpw = (LPWORD) (lpdit + 1);
    *lpw++ = 0xFFFF;
    *lpw++ = 0x0082;		/* static class */

	lpw  += 1+MultiByteToWideChar (CP_ACP, 0, "Starting Application...", -1, (LPWSTR)lpw, 50);

	/* create the dialog */
    GlobalUnlock(hgbl); 
    hSplash = CreateDialogIndirectParam( mswHInst, (LPDLGTEMPLATE) hgbl, 
        mswHWnd, (DLGPROC)SplashDlgProc, (LPARAM)hBmp ); 
	GetLastError();
	
	/* free allocated memory */
	GlobalFree(hgbl);     
	free( pszBuf );

	/* that's it */
	return 1; 
}
Exemple #5
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;
}
Exemple #6
0
static BOOL Dialog_Create(void)
{
BOOL fRes = FALSE;
LPDLGTEMPLATE lpdt;
LPDLGITEMTEMPLATE lpdit;
LPWORD lpw;
LPWSTR lpwsz;
int nchar;
hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
if (hgbl == NULL)
  return(fRes);
lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);
// Define a dialog box.
lpdt->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | DS_SETFONT;
lpdt->cdit = 4;  // number of controls
lpdt->x  = 0;  lpdt->y  = 0;
lpdt->cx = 205; lpdt->cy = 204;
lpw = (LPWORD) (lpdt + 1);
*lpw++ = 0;       // no menu
*lpw++ = 0;       // predefined dialog box class (by default)
*lpw++ = 0;       // no caption text
*lpw++ = 0x0008;  // font size
lpwsz = (LPWSTR) lpw;
nchar = 1+ MultiByteToWideChar (CP_ACP, 0, "MS Sans Serif", -1, lpwsz, 50);
lpw   += nchar;

// Define an OK button.
lpw = lpwAlign (lpw);
lpdit = (LPDLGITEMTEMPLATE) lpw;
lpdit->x  = 152; lpdit->y  = 182;
lpdit->cx = 50; lpdit->cy = 14;
lpdit->id = IDOK;  // OK button identifier
lpdit->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP;
lpw = (LPWORD) (lpdit + 1);
*lpw++ = 0xFFFF;
*lpw++ = 0x0080;    // button class
*lpw++ = 0x0000;    // no caption
*lpw++ = 0;         // no creation data
// Define a Cancel button.
lpw = lpwAlign (lpw);
lpdit = (LPDLGITEMTEMPLATE) lpw;
lpdit->x  = 97; lpdit->y  = 182;
lpdit->cx = 50; lpdit->cy = 14;
lpdit->id = IDCANCEL; //Cancel button identifier
lpdit->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP;
lpw = (LPWORD) (lpdit + 1);
*lpw++ = 0xFFFF;
*lpw++ = 0x0080;    // button class atom
*lpw++ = 0x0000;    // no caption
*lpw++ = 0;         // no creation data
// Define a groupbox control.
lpw = lpwAlign (lpw);
lpdit = (LPDLGITEMTEMPLATE) lpw;
lpdit->x  = 0; lpdit->y  = 2;
lpdit->cx = 205; lpdit->cy = 173;
lpdit->id = IDC_GROUPBOX; // groupbox identifier
lpdit->style = BS_GROUPBOX | WS_VISIBLE;
lpw = (LPWORD) (lpdit + 1);
*lpw++ = 0xFFFF;
*lpw++ = 0x0080;   // listbox
*lpw++ = 0x0000;   // no caption
*lpw++ = 0;                      // no creation data
// Define a listbox control.
lpw = lpwAlign (lpw);
lpdit = (LPDLGITEMTEMPLATE) lpw;
lpdit->x  = 4; lpdit->y  = 12;
lpdit->cx = 197; lpdit->cy = 158;
lpdit->id = IDC_LISTVIEW; // listbox identifier
lpdit->style = LBS_USETABSTOPS | LBS_NOTIFY | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | LBS_NOINTEGRALHEIGHT | WS_BORDER;
lpw = (LPWORD) (lpdit + 1);
*lpw++ = 0xFFFF;
*lpw++ = 0x0083;   // listbox
*lpw++ = 0x0000;   // no caption
//if caption exist, delete previous line and remove next 3 lines comments
//lpwsz = (LPWSTR) lpw;
//nchar = 1+MultiByteToWideChar (CP_ACP, 0, "", -1, lpwsz, 50);
//lpw   += nchar;
*lpw++ = 0;                      // no creation data
GlobalUnlock(hgbl);
fRes = TRUE;
return(fRes);
}
Exemple #7
0
static LRESULT
MultiInputDialog( HINSTANCE hinst, HWND hwndOwner,
                  char * ptext[], int numlines, int width,
                  int tb_cnt, struct textField * tb)
{
    HGLOBAL hgbl;
    LPDLGTEMPLATE lpdt;
    LPDLGITEMTEMPLATE lpdit;
    LPWORD lpw;
    LPWSTR lpwsz;
    LRESULT ret;
    int nchar, i;
    size_t pwid;

    hgbl = GlobalAlloc(GMEM_ZEROINIT, 4096);
    if (!hgbl)
        return -1;

    mid_cnt = tb_cnt;
    mid_tb = tb;

    lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);

    // Define a dialog box.

    lpdt->style = WS_POPUP | WS_BORDER | WS_SYSMENU
                   | DS_MODALFRAME | WS_CAPTION | DS_CENTER
                   | DS_SETFOREGROUND | DS_3DLOOK
                   | DS_SHELLFONT | DS_NOFAILCREATE;
    lpdt->cdit = numlines + (2 * tb_cnt) + 2;  // number of controls
    lpdt->x  = 10;
    lpdt->y  = 10;
    lpdt->cx = 20 + width * 4;
    lpdt->cy = 20 + (numlines + tb_cnt + 4) * 14;

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

    lpwsz = (LPWSTR) lpw;
    nchar = MultiByteToWideChar (CP_ACP, 0, "", -1, lpwsz, 128);
    lpw   += nchar;
    *lpw++ = 8;                        // font size (points)
    lpwsz = (LPWSTR) lpw;
    nchar = MultiByteToWideChar (CP_ACP, 0, "MS Shell Dlg",
                                    -1, lpwsz, 128);
    lpw   += nchar;

    //-----------------------
    // Define an OK button.
    //-----------------------
    lpw = lpwAlign (lpw); // align DLGITEMTEMPLATE on DWORD boundary
    lpdit = (LPDLGITEMTEMPLATE) lpw;
    lpdit->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_BORDER;
    lpdit->dwExtendedStyle = 0;
    lpdit->x  = (lpdt->cx - 14)/4 - 20;
    lpdit->y  = 10 + (numlines + tb_cnt + 2) * 14;
    lpdit->cx = 40;
    lpdit->cy = 14;
    lpdit->id = IDOK;  // OK button identifier

    lpw = (LPWORD) (lpdit + 1);
    *lpw++ = 0xFFFF;
    *lpw++ = 0x0080;    // button class

    lpwsz = (LPWSTR) lpw;
    nchar = MultiByteToWideChar (CP_ACP, 0, "OK", -1, lpwsz, 50);
    lpw   += nchar;
    *lpw++ = 0;           // no creation data

    //-----------------------
    // Define an Cancel button.
    //-----------------------
    lpw = lpwAlign (lpw); // align DLGITEMTEMPLATE on DWORD boundary
    lpdit = (LPDLGITEMTEMPLATE) lpw;
    lpdit->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP | WS_BORDER;
    lpdit->dwExtendedStyle = 0;
    lpdit->x  = (lpdt->cx - 14)*3/4 - 20;
    lpdit->y  = 10 + (numlines + tb_cnt + 2) * 14;
    lpdit->cx = 40;
    lpdit->cy = 14;
    lpdit->id = IDCANCEL;  // CANCEL button identifier

    lpw = (LPWORD) (lpdit + 1);
    *lpw++ = 0xFFFF;
    *lpw++ = 0x0080;    // button class

    lpwsz = (LPWSTR) lpw;
    nchar = MultiByteToWideChar (CP_ACP, 0, "Cancel", -1, lpwsz, 50);
    lpw   += nchar;
    *lpw++ = 0;           // no creation data

    /* Add controls for preface data */
    for ( i=0; i<numlines; i++) {
        /*-----------------------
         * Define a static text control.
         *-----------------------*/
        lpw = lpwAlign (lpw); /* align DLGITEMTEMPLATE on DWORD boundary */
        lpdit = (LPDLGITEMTEMPLATE) lpw;
        lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;
        lpdit->dwExtendedStyle = 0;
        lpdit->x  = 10;
        lpdit->y  = 10 + i * 14;
        lpdit->cx = strlen(ptext[i]) * 4 + 10;
        lpdit->cy = 14;
        lpdit->id = ID_TEXT + i;  // text identifier

        lpw = (LPWORD) (lpdit + 1);
        *lpw++ = 0xFFFF;
        *lpw++ = 0x0082;                         // static class

        lpwsz = (LPWSTR) lpw;
        nchar = MultiByteToWideChar (CP_ACP, 0, ptext[i],
                                         -1, lpwsz, 2*width);
        lpw   += nchar;
        *lpw++ = 0;           // no creation data
    }

    for ( i=0, pwid = 0; i<tb_cnt; i++) {
        if ( pwid < strlen(tb[i].label) )
            pwid = strlen(tb[i].label);
    }

    for ( i=0; i<tb_cnt; i++) {
        /* Prompt */
        /*-----------------------
         * Define a static text control.
         *-----------------------*/
        lpw = lpwAlign (lpw); /* align DLGITEMTEMPLATE on DWORD boundary */
        lpdit = (LPDLGITEMTEMPLATE) lpw;
        lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;
        lpdit->dwExtendedStyle = 0;
        lpdit->x  = 10;
        lpdit->y  = 10 + (numlines + i + 1) * 14;
        lpdit->cx = pwid * 4;
        lpdit->cy = 14;
        lpdit->id = ID_TEXT + numlines + i;  // text identifier

        lpw = (LPWORD) (lpdit + 1);
        *lpw++ = 0xFFFF;
        *lpw++ = 0x0082;                         // static class

        lpwsz = (LPWSTR) lpw;
        nchar = MultiByteToWideChar (CP_ACP, 0, tb[i].label ? tb[i].label : "",
                                     -1, lpwsz, 128);
        lpw   += nchar;
        *lpw++ = 0;           // no creation data

        /*-----------------------
         * Define an edit control.
         *-----------------------*/
        lpw = lpwAlign (lpw); /* align DLGITEMTEMPLATE on DWORD boundary */
        lpdit = (LPDLGITEMTEMPLATE) lpw;
        lpdit->style = WS_CHILD | WS_VISIBLE | ES_LEFT | WS_TABSTOP | WS_BORDER | (tb[i].echo == 1 ? 0L : ES_PASSWORD);
        lpdit->dwExtendedStyle = 0;
        lpdit->x  = 10 + (pwid + 1) * 4;
        lpdit->y  = 10 + (numlines + i + 1) * 14;
        lpdit->cx = (width - (pwid + 1)) * 4;
        lpdit->cy = 14;
        lpdit->id = ID_MID_TEXT + i;             // identifier

        lpw = (LPWORD) (lpdit + 1);
        *lpw++ = 0xFFFF;
        *lpw++ = 0x0081;                         // edit class

        lpwsz = (LPWSTR) lpw;
        nchar = MultiByteToWideChar (CP_ACP, 0, tb[i].def ? tb[i].def : "",
                                     -1, lpwsz, 128);
        lpw   += nchar;
        *lpw++ = 0;           // no creation data
    }

    GlobalUnlock(hgbl);
    ret = DialogBoxIndirect(hinst, (LPDLGTEMPLATE) hgbl,
							hwndOwner, (DLGPROC) MultiInputDialogProc);
    GlobalFree(hgbl);

    switch ( ret ) {
    case 0:     /* Timeout */
        return -1;
    case IDOK:
        return 1;
    case IDCANCEL:
        return 0;
    default: {
        char buf[256];
        sprintf(buf,"DialogBoxIndirect() failed: %d",GetLastError());
        MessageBox(hwndOwner,
                    buf,
                    "GetLastError()",
                    MB_OK | MB_ICONINFORMATION | MB_TASKMODAL);
        return -1;
    }
    }
}
Exemple #8
0
LPCDLGTEMPLATE event_dialog::DlgTemplate(void *mem)
{
  LPDLGTEMPLATE lpdt;
  LPDLGITEMTEMPLATE lpdit;
  
  LPWORD lpw;
  LPWSTR lpwsz;
  int nchar;

  lpdt = (LPDLGTEMPLATE)mem;
  
  // Define a dialog box.
  lpdt->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | DS_SETFONT | WS_CAPTION;
  lpdt->cdit = 14;         // Number of controls
  lpdt->x  = 10;  lpdt->y  = 10;
  lpdt->cx = 150; lpdt->cy = 200;

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

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Issue Event", -1, lpwsz, 50);
  lpw += nchar;

  *lpw++ = 9;  //9 pt font
  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, lpwsz, 50);
  lpw += nchar;
  
  //-----------------------
  // Define an OK button.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  10; lpdit->y  = 170;
  lpdit->cx = 130;  lpdit->cy = 20;
  lpdit->id = IDOK;       // OK button identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
  
  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0080;        // Button class

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "OK", -1, lpwsz, 50);
  lpw += nchar;
  *lpw++ = 0;             // No creation data

  //-----------------------
  // Define a static text control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  = 10; lpdit->y  = 10;
  lpdit->cx = 40; lpdit->cy = 10;
  lpdit->id = ID_TEXT;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0082;        // Static class

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Event:", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data

  //-----------------------
  // Define a list box control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  = 60; lpdit->y  = 10;
  lpdit->cx = 80; lpdit->cy = 80;
  lpdit->id = ID_EVENTBOX;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL | CBS_HASSTRINGS;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0085;        

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Event", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define a list box control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  = 10; lpdit->y  = 30;
  lpdit->cx = 60; lpdit->cy = 80;
  lpdit->id = ID_EVENTSENDER;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0085;        

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Sender", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  
  //-----------------------
  // Define a list box control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  = 80; lpdit->y  = 30;
  lpdit->cx = 60; lpdit->cy = 80;
  lpdit->id = ID_EVENTRECIPIENT;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0085;        // List box class

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Recipient", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  40; lpdit->y  = 65;
  lpdit->cx = 100; lpdit->cy = 12;
  lpdit->id = ID_EVENTARG1;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE;
  lpdit->dwExtendedStyle = WS_EX_CLIENTEDGE;
  
  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0081;       

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Argument 1", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  40; lpdit->y  = 80;
  lpdit->cx = 100; lpdit->cy = 12;
  lpdit->id = ID_EVENTARG2;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE;
  lpdit->dwExtendedStyle = WS_EX_CLIENTEDGE;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0081;        // List box class

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Argument 2", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  40; lpdit->y  = 95;
  lpdit->cx = 100; lpdit->cy = 12;
  lpdit->id = ID_EVENTARG3;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE;
  lpdit->dwExtendedStyle = WS_EX_CLIENTEDGE;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0081;        // List box class

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Argument 3", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  40; lpdit->y  = 110;
  lpdit->cx = 100; lpdit->cy =  12;
  lpdit->id = ID_EVENTARG4;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE;
  lpdit->dwExtendedStyle = WS_EX_CLIENTEDGE;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0081;        // List box class

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Argument 4", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =   10; lpdit->y  = 50;
  lpdit->cx =  130; lpdit->cy = 12;
  lpdit->id = ID_RADIOARGN;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON;
  
  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0080;       

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "No Arguments", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  10; lpdit->y  = 65;
  lpdit->cx =  30; lpdit->cy = 12;
  lpdit->id = ID_RADIOARG1;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON;
  
  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0080;       

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Arg 1", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  10; lpdit->y  = 80;
  lpdit->cx =  30; lpdit->cy = 12;
  lpdit->id = ID_RADIOARG2;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0080;        

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Arg 2", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  10; lpdit->y  = 95;
  lpdit->cx =  30; lpdit->cy = 12;
  lpdit->id = ID_RADIOARG3;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0080;        

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Arg 3", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
    //-----------------------
  // Define an edit control.
  //-----------------------
  lpw = lpwAlign(lpw);    // Align DLGITEMTEMPLATE on DWORD boundary
  lpdit = (LPDLGITEMTEMPLATE)lpw;
  lpdit->x  =  10; lpdit->y  =  110;
  lpdit->cx =  30; lpdit->cy =  12;
  lpdit->id = ID_RADIOARG4;    // Text identifier
  lpdit->style = WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON;

  lpw = (LPWORD)(lpdit + 1);
  *lpw++ = 0xFFFF;
  *lpw++ = 0x0080;        // List box class

  lpwsz = (LPWSTR)lpw;
  nchar = MultiByteToWideChar(CP_ACP, 0, "Arg 4", -1, lpwsz, 150);
  lpw += nchar;
  *lpw++ = 0;             // No creation data
  
  return (LPCDLGTEMPLATE)lpdt;
}